Updated the fluent API calls for the AssertJ assertions.
This commit is contained in:
parent
580cce7abf
commit
c7326c23ca
|
@ -21,115 +21,99 @@ public class NonCapturingGroupUnitTest {
|
||||||
void givenSimpleUrlPattern_whenValidUrlProvided_thenMatches() {
|
void givenSimpleUrlPattern_whenValidUrlProvided_thenMatches() {
|
||||||
Matcher urlMatcher = SIMPLE_URL_PATTERN.matcher("http://www.microsoft.com/");
|
Matcher urlMatcher = SIMPLE_URL_PATTERN.matcher("http://www.microsoft.com/");
|
||||||
|
|
||||||
Assertions.assertThat(urlMatcher.matches())
|
Assertions.assertThat(urlMatcher.matches()).isTrue();
|
||||||
.isTrue();
|
Assertions.assertThatThrownBy(() -> urlMatcher.group(1)).isInstanceOf(IndexOutOfBoundsException.class);
|
||||||
Assertions.assertThatThrownBy(() -> urlMatcher.group(1))
|
|
||||||
.isInstanceOf(IndexOutOfBoundsException.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenSimpleUrlProvidedWithPathProvided_thenMatches() {
|
void whenSimpleUrlProvidedWithPathProvided_thenMatches() {
|
||||||
Matcher urlMatcher = SIMPLE_URL_PATTERN.matcher("http://www.microsoft.com/live");
|
Matcher urlMatcher = SIMPLE_URL_PATTERN.matcher("http://www.microsoft.com/live");
|
||||||
|
|
||||||
Assertions.assertThat(urlMatcher.matches())
|
Assertions.assertThat(urlMatcher.matches()).isTrue();
|
||||||
.isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenSimpleUrlProvidedWithPathEndingWithSlashProvided_thenMatches() {
|
void whenSimpleUrlProvidedWithPathEndingWithSlashProvided_thenMatches() {
|
||||||
Matcher urlMatcher = SIMPLE_URL_PATTERN.matcher("http://www.microsoft.com/live/");
|
Matcher urlMatcher = SIMPLE_URL_PATTERN.matcher("http://www.microsoft.com/live/");
|
||||||
|
|
||||||
Assertions.assertThat(urlMatcher.matches())
|
Assertions.assertThat(urlMatcher.matches()).isTrue();
|
||||||
.isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenSimpleUrlPattern_whenUrlWithMultiplePathSegmentsProvided_thenMatches() {
|
void givenSimpleUrlPattern_whenUrlWithMultiplePathSegmentsProvided_thenMatches() {
|
||||||
Matcher urlMatcher = SIMPLE_URL_PATTERN.matcher("http://www.microsoft.com/some/other/url/path");
|
Matcher urlMatcher = SIMPLE_URL_PATTERN.matcher("http://www.microsoft.com/some/other/url/path");
|
||||||
|
|
||||||
Assertions.assertThat(urlMatcher.matches())
|
Assertions.assertThat(urlMatcher.matches()).isTrue();
|
||||||
.isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenUrlWithUppercaseCharactersProvided_thenDoesNotMatch() {
|
void whenUrlWithUppercaseCharactersProvided_thenDoesNotMatch() {
|
||||||
Matcher urlMatcher = SIMPLE_URL_PATTERN.matcher("http://www.Microsoft.com/");
|
Matcher urlMatcher = SIMPLE_URL_PATTERN.matcher("http://www.Microsoft.com/");
|
||||||
|
|
||||||
Assertions.assertThat(urlMatcher.matches())
|
Assertions.assertThat(urlMatcher.matches()).isFalse();
|
||||||
.isFalse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenPatternWithCaseInsensitiveGroup_whenUrlHasUppercaseCharactersInsideOfScope_thenMatches() {
|
void givenPatternWithCaseInsensitiveGroup_whenUrlHasUppercaseCharactersInsideOfScope_thenMatches() {
|
||||||
Matcher urlMatcher = SCOPED_CASE_INSENSITIVE_URL_PATTERN.matcher("http://www.Microsoft.com/");
|
Matcher urlMatcher = SCOPED_CASE_INSENSITIVE_URL_PATTERN.matcher("http://www.Microsoft.com/");
|
||||||
|
|
||||||
Assertions.assertThat(urlMatcher.matches())
|
Assertions.assertThat(urlMatcher.matches()).isTrue();
|
||||||
.isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenCaseInsensitivePattern_whenUrlHasUppercaseCharacters_thenMatches() {
|
void givenCaseInsensitivePattern_whenUrlHasUppercaseCharacters_thenMatches() {
|
||||||
Matcher urlMatcher = CASE_INSENSITIVE_URL_PATTERN.matcher("http://www.Microsoft.com/Ending-path");
|
Matcher urlMatcher = CASE_INSENSITIVE_URL_PATTERN.matcher("http://www.Microsoft.com/Ending-path");
|
||||||
|
|
||||||
Assertions.assertThat(urlMatcher.matches())
|
Assertions.assertThat(urlMatcher.matches()).isTrue();
|
||||||
.isTrue();
|
Assertions.assertThat(urlMatcher.group(1)).isEqualTo("/Ending-path");
|
||||||
Assertions.assertThat(urlMatcher.group(1))
|
|
||||||
.isEqualTo("/Ending-path");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenPatternWithCaseInsensitiveGroup_whenUrlHasUppercaseCharactersOutsideOfScope_thenMatchFails() {
|
void givenPatternWithCaseInsensitiveGroup_whenUrlHasUppercaseCharactersOutsideOfScope_thenMatchFails() {
|
||||||
Matcher urlMatcher = SCOPED_CASE_INSENSTIIVE_URL_PATTERN_WITH_ENDING_PATH.matcher("http://www.Microsoft.com/Ending-path");
|
Matcher urlMatcher = SCOPED_CASE_INSENSTIIVE_URL_PATTERN_WITH_ENDING_PATH.matcher("http://www.Microsoft.com/Ending-path");
|
||||||
|
|
||||||
Assertions.assertThat(urlMatcher.matches())
|
Assertions.assertThat(urlMatcher.matches()).isFalse();
|
||||||
.isFalse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenPatternAllowingBacktracking_whenUrlWithEndingPathCausingBacktrackingProvided_thenMatches() {
|
void givenPatternAllowingBacktracking_whenUrlWithEndingPathCausingBacktrackingProvided_thenMatches() {
|
||||||
Matcher urlMatcher = SIMPLE_URL_PATTERN_WITH_SPECIFIC_ENDING_PATH.matcher("http://www.microsoft.com/ending-path");
|
Matcher urlMatcher = SIMPLE_URL_PATTERN_WITH_SPECIFIC_ENDING_PATH.matcher("http://www.microsoft.com/ending-path");
|
||||||
|
|
||||||
Assertions.assertThat(urlMatcher.matches())
|
Assertions.assertThat(urlMatcher.matches()).isTrue();
|
||||||
.isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenPatternWithIndependentNonCapturingGroup_whenBacktrackingOccurs_thenDoesNotMatch() {
|
void givenPatternWithIndependentNonCapturingGroup_whenBacktrackingOccurs_thenDoesNotMatch() {
|
||||||
Matcher independentMatcher = INDEPENDENT_URL_PATTERN_WITH_ENDING_PATH.matcher("http://www.microsoft.com/ending-path");
|
Matcher independentMatcher = INDEPENDENT_URL_PATTERN_WITH_ENDING_PATH.matcher("http://www.microsoft.com/ending-path");
|
||||||
|
|
||||||
Assertions.assertThat(independentMatcher.matches())
|
Assertions.assertThat(independentMatcher.matches()).isFalse();
|
||||||
.isFalse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenPatternWithIndependentNonCapturingGroup_whenBacktrackingDoesNotOccur_thenMatches() {
|
void givenPatternWithIndependentNonCapturingGroup_whenBacktrackingDoesNotOccur_thenMatches() {
|
||||||
Matcher independentMatcher = INDEPENDENT_URL_PATTERN_WITH_ENDING_PATH.matcher("http://www.microsoft.com//ending-path");
|
Matcher independentMatcher = INDEPENDENT_URL_PATTERN_WITH_ENDING_PATH.matcher("http://www.microsoft.com//ending-path");
|
||||||
|
|
||||||
Assertions.assertThat(independentMatcher.matches())
|
Assertions.assertThat(independentMatcher.matches()).isTrue();
|
||||||
.isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenPatternWithIndependentNonCapturingGroup_whenBacktrackingOccursInsideGroup_thenMatches() {
|
void givenPatternWithIndependentNonCapturingGroup_whenBacktrackingOccursInsideGroup_thenMatches() {
|
||||||
Matcher independentMatcher = INDEPENDENT_URL_PATTERN_WITH_ENDING_PATH_AND_BACKTRACKING.matcher("http://www.microsoft.com/ending-path");
|
Matcher independentMatcher = INDEPENDENT_URL_PATTERN_WITH_ENDING_PATH_AND_BACKTRACKING.matcher("http://www.microsoft.com/ending-path");
|
||||||
|
|
||||||
Assertions.assertThat(independentMatcher.matches())
|
Assertions.assertThat(independentMatcher.matches()).isTrue();
|
||||||
.isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenCaseInsensitivePatternWithCaseSensitivieSubPattern_whenUrlWithUppercaseCharactersOutsideOfScopeProvided_thenMatches() {
|
void givenCaseInsensitivePatternWithCaseSensitivieSubPattern_whenUrlWithUppercaseCharactersOutsideOfScopeProvided_thenMatches() {
|
||||||
Matcher urlMatcher = SCOPED_CASE_SENSITIVE_URL_PATTERN.matcher("http://www.microsoft.com/ENDING-PATH");
|
Matcher urlMatcher = SCOPED_CASE_SENSITIVE_URL_PATTERN.matcher("http://www.microsoft.com/ENDING-PATH");
|
||||||
|
|
||||||
Assertions.assertThat(urlMatcher.matches())
|
Assertions.assertThat(urlMatcher.matches()).isTrue();
|
||||||
.isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenCaseInsensitivePatternWithCaseSensitivieSubPattern_whenUrlWithUppercaseCharactersInsideOfScopeProvided_thenDoesNotMatch() {
|
void givenCaseInsensitivePatternWithCaseSensitivieSubPattern_whenUrlWithUppercaseCharactersInsideOfScopeProvided_thenDoesNotMatch() {
|
||||||
Matcher urlMatcher = SCOPED_CASE_SENSITIVE_URL_PATTERN.matcher("http://www.Microsoft.com/ending-path");
|
Matcher urlMatcher = SCOPED_CASE_SENSITIVE_URL_PATTERN.matcher("http://www.Microsoft.com/ending-path");
|
||||||
|
|
||||||
Assertions.assertThat(urlMatcher.matches())
|
Assertions.assertThat(urlMatcher.matches()).isFalse();
|
||||||
.isFalse();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue