2828import static org .assertj .core .api .Assertions .assertThat ;
2929import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
3030import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
31+ import static org .assertj .core .api .Assertions .assertThatThrownBy ;
3132import static org .assertj .core .api .Assertions .fail ;
3233
3334/**
@@ -128,12 +129,12 @@ public void regexPathElementPatterns() {
128129 pathPattern = checkStructure ("/{var:\\ \\ }" );
129130 PathElement next = pathPattern .getHeadSection ().next ;
130131 assertThat (next .getClass ().getName ()).isEqualTo (CaptureVariablePathElement .class .getName ());
131- assertMatches (pathPattern ,"/\\ " );
132+ assertMatches (pathPattern , "/\\ " );
132133
133134 pathPattern = checkStructure ("/{var:\\ /}" );
134135 next = pathPattern .getHeadSection ().next ;
135136 assertThat (next .getClass ().getName ()).isEqualTo (CaptureVariablePathElement .class .getName ());
136- assertNoMatch (pathPattern ,"/aaa" );
137+ assertNoMatch (pathPattern , "/aaa" );
137138
138139 pathPattern = checkStructure ("/{var:a{1,2}}" );
139140 next = pathPattern .getHeadSection ().next ;
@@ -142,25 +143,25 @@ public void regexPathElementPatterns() {
142143 pathPattern = checkStructure ("/{var:[^\\ /]*}" );
143144 next = pathPattern .getHeadSection ().next ;
144145 assertThat (next .getClass ().getName ()).isEqualTo (CaptureVariablePathElement .class .getName ());
145- PathPattern .PathMatchInfo result = matchAndExtract (pathPattern ,"/foo" );
146+ PathPattern .PathMatchInfo result = matchAndExtract (pathPattern , "/foo" );
146147 assertThat (result .getUriVariables ().get ("var" )).isEqualTo ("foo" );
147148
148149 pathPattern = checkStructure ("/{var:\\ [*}" );
149150 next = pathPattern .getHeadSection ().next ;
150151 assertThat (next .getClass ().getName ()).isEqualTo (CaptureVariablePathElement .class .getName ());
151- result = matchAndExtract (pathPattern ,"/[[[" );
152+ result = matchAndExtract (pathPattern , "/[[[" );
152153 assertThat (result .getUriVariables ().get ("var" )).isEqualTo ("[[[" );
153154
154155 pathPattern = checkStructure ("/{var:[\\ {]*}" );
155156 next = pathPattern .getHeadSection ().next ;
156157 assertThat (next .getClass ().getName ()).isEqualTo (CaptureVariablePathElement .class .getName ());
157- result = matchAndExtract (pathPattern ,"/{{{" );
158+ result = matchAndExtract (pathPattern , "/{{{" );
158159 assertThat (result .getUriVariables ().get ("var" )).isEqualTo ("{{{" );
159160
160161 pathPattern = checkStructure ("/{var:[\\ }]*}" );
161162 next = pathPattern .getHeadSection ().next ;
162163 assertThat (next .getClass ().getName ()).isEqualTo (CaptureVariablePathElement .class .getName ());
163- result = matchAndExtract (pathPattern ,"/}}}" );
164+ result = matchAndExtract (pathPattern , "/}}}" );
164165 assertThat (result .getUriVariables ().get ("var" )).isEqualTo ("}}}" );
165166
166167 pathPattern = checkStructure ("*" );
@@ -249,10 +250,10 @@ public void illegalCapturePatterns() {
249250 PathPattern pp = parse ("/{abc:foo(bar)}" );
250251 assertThatIllegalArgumentException ().isThrownBy (() ->
251252 pp .matchAndExtract (toPSC ("/foo" )))
252- .withMessage ("No capture groups allowed in the constraint regex: foo(bar)" );
253+ .withMessage ("No capture groups allowed in the constraint regex: foo(bar)" );
253254 assertThatIllegalArgumentException ().isThrownBy (() ->
254255 pp .matchAndExtract (toPSC ("/foobar" )))
255- .withMessage ("No capture groups allowed in the constraint regex: foo(bar)" );
256+ .withMessage ("No capture groups allowed in the constraint regex: foo(bar)" );
256257 }
257258
258259 @ Test
@@ -414,12 +415,12 @@ public void compareTests() {
414415 assertThat (patterns .get (1 )).isEqualTo (p2 );
415416 }
416417
417- @ Test // Should be updated with gh-24952
418- public void doubleWildcardWithinPatternNotSupported () {
418+ @ Test
419+ public void captureTheRestWithinPatternNotSupported () {
419420 PathPatternParser parser = new PathPatternParser ();
420- PathPattern pattern = parser .parse ("/resources/**/details" );
421- assertThat ( pattern . matches ( PathContainer . parsePath ( "/resources/test/details" ))). isTrue ();
422- assertThat ( pattern . matches ( PathContainer . parsePath ( "/resources/projects/spring/details" ))). isFalse ( );
421+ assertThatThrownBy (() -> parser .parse ("/resources/**/details" ))
422+ . isInstanceOf ( PatternParseException . class )
423+ . extracting ( "messageType" ). isEqualTo ( PatternMessage . NO_MORE_DATA_EXPECTED_AFTER_CAPTURE_THE_REST );
423424 }
424425
425426 @ Test
@@ -461,16 +462,16 @@ private void checkError(String pattern, int expectedPos, PatternMessage expected
461462 String ... expectedInserts ) {
462463
463464 assertThatExceptionOfType (PatternParseException .class )
464- .isThrownBy (() -> pathPattern = parse (pattern ))
465- .satisfies (ex -> {
466- if (expectedPos >= 0 ) {
467- assertThat (ex .getPosition ()).as (ex .toDetailedString ()).isEqualTo (expectedPos );
468- }
469- assertThat (ex .getMessageType ()).as (ex .toDetailedString ()).isEqualTo (expectedMessage );
470- if (expectedInserts .length != 0 ) {
471- assertThat (ex .getInserts ()).isEqualTo (expectedInserts );
472- }
473- });
465+ .isThrownBy (() -> pathPattern = parse (pattern ))
466+ .satisfies (ex -> {
467+ if (expectedPos >= 0 ) {
468+ assertThat (ex .getPosition ()).as (ex .toDetailedString ()).isEqualTo (expectedPos );
469+ }
470+ assertThat (ex .getMessageType ()).as (ex .toDetailedString ()).isEqualTo (expectedMessage );
471+ if (expectedInserts .length != 0 ) {
472+ assertThat (ex .getInserts ()).isEqualTo (expectedInserts );
473+ }
474+ });
474475 }
475476
476477 @ SafeVarargs
0 commit comments