Skip to content

Commit

Permalink
Added Tests for ParameterResolver in the ParameterResolverTest class
Browse files Browse the repository at this point in the history
Added more automated tests for ParameterResolverTest class
  • Loading branch information
yashpal2104 committed Oct 27, 2024
1 parent f29a920 commit e9024ed
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,55 @@ void shouldResolveSubjectWithVariables(String queryParameter, String expectedPar
String resolvedParameter = new ParameterResolver().resolve(Mockito.mock(Actionable.class), queryParameter);
assertThat(resolvedParameter, is(expectedParameter));
}

void shouldResolveNullParameter() {
String resolvedParameter = new ParameterResolver().resolve(Mockito.mock(Actionable.class), null);
assertThat(resolvedParameter, is(null));
}

void shouldResolveEmptyParameter() {
String resolvedParameter = new ParameterResolver().resolve(Mockito.mock(Actionable.class), "");
assertThat(resolvedParameter, is(""));
}

void shouldResolveParameterWithoutVariables() {
String resolvedParameter = new ParameterResolver().resolve(Mockito.mock(Actionable.class), "Build");
assertThat(resolvedParameter, is("Build"));
}

void shouldResolveParameterWithVariables() {
String resolvedParameter =
new ParameterResolver().resolve(Mockito.mock(Actionable.class), "Build ${params.BUILD_BRANCH}");
assertThat(resolvedParameter, is("Build params.BUILD_BRANCH"));
}

void shouldResolveParameterWithVariablesAndText() {
String resolvedParameter = new ParameterResolver()
.resolve(Mockito.mock(Actionable.class), "Build ${params.BUILD_BRANCH} (${displayName})");
assertThat(resolvedParameter, is("Build params.BUILD_BRANCH (displayName)"));
}

void shouldResolveParameterWithVariablesAndTextAndDefault() {
String resolvedParameter = new ParameterResolver()
.resolve(Mockito.mock(Actionable.class), "Build ${params.BUILD_BRANCH|master} (${displayName})");
assertThat(resolvedParameter, is("Build params.BUILD_BRANCH|master (displayName)"));
}

void shouldNotResolveParameterOfVaryingLengthInRegex() {
ParameterResolver resolver = new ParameterResolver();
String resolvedParameter = resolver.resolve(Mockito.mock(Actionable.class), "(?<=\\w*)");
assertThat(resolvedParameter, is("(?<=\\w*)"));
}

void shouldNotResolveParameterWithFullRangeUnicode(){
String resolvedParameter = new ParameterResolver()
.resolve(Mockito.mock(Actionable.class), "\\p{InGreek}");
assertThat(resolvedParameter, is("\\p{InGreek}"));
}

void shouldNotResolveParameterWithRegexInlineFlags(){
String resolvedParameter = new ParameterResolver()
.resolve(Mockito.mock(Actionable.class), "(${\\Build(?i) params\\b})");
assertThat(resolvedParameter, is("(${\\Build(?i) params\\b})"));
}
}

0 comments on commit e9024ed

Please sign in to comment.