28
28
import static org .assertj .core .api .Assertions .assertThat ;
29
29
import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
30
30
import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
31
+ import static org .assertj .core .api .Assertions .assertThatThrownBy ;
31
32
import static org .assertj .core .api .Assertions .fail ;
32
33
33
34
/**
@@ -128,12 +129,12 @@ public void regexPathElementPatterns() {
128
129
pathPattern = checkStructure ("/{var:\\ \\ }" );
129
130
PathElement next = pathPattern .getHeadSection ().next ;
130
131
assertThat (next .getClass ().getName ()).isEqualTo (CaptureVariablePathElement .class .getName ());
131
- assertMatches (pathPattern ,"/\\ " );
132
+ assertMatches (pathPattern , "/\\ " );
132
133
133
134
pathPattern = checkStructure ("/{var:\\ /}" );
134
135
next = pathPattern .getHeadSection ().next ;
135
136
assertThat (next .getClass ().getName ()).isEqualTo (CaptureVariablePathElement .class .getName ());
136
- assertNoMatch (pathPattern ,"/aaa" );
137
+ assertNoMatch (pathPattern , "/aaa" );
137
138
138
139
pathPattern = checkStructure ("/{var:a{1,2}}" );
139
140
next = pathPattern .getHeadSection ().next ;
@@ -142,25 +143,25 @@ public void regexPathElementPatterns() {
142
143
pathPattern = checkStructure ("/{var:[^\\ /]*}" );
143
144
next = pathPattern .getHeadSection ().next ;
144
145
assertThat (next .getClass ().getName ()).isEqualTo (CaptureVariablePathElement .class .getName ());
145
- PathPattern .PathMatchInfo result = matchAndExtract (pathPattern ,"/foo" );
146
+ PathPattern .PathMatchInfo result = matchAndExtract (pathPattern , "/foo" );
146
147
assertThat (result .getUriVariables ().get ("var" )).isEqualTo ("foo" );
147
148
148
149
pathPattern = checkStructure ("/{var:\\ [*}" );
149
150
next = pathPattern .getHeadSection ().next ;
150
151
assertThat (next .getClass ().getName ()).isEqualTo (CaptureVariablePathElement .class .getName ());
151
- result = matchAndExtract (pathPattern ,"/[[[" );
152
+ result = matchAndExtract (pathPattern , "/[[[" );
152
153
assertThat (result .getUriVariables ().get ("var" )).isEqualTo ("[[[" );
153
154
154
155
pathPattern = checkStructure ("/{var:[\\ {]*}" );
155
156
next = pathPattern .getHeadSection ().next ;
156
157
assertThat (next .getClass ().getName ()).isEqualTo (CaptureVariablePathElement .class .getName ());
157
- result = matchAndExtract (pathPattern ,"/{{{" );
158
+ result = matchAndExtract (pathPattern , "/{{{" );
158
159
assertThat (result .getUriVariables ().get ("var" )).isEqualTo ("{{{" );
159
160
160
161
pathPattern = checkStructure ("/{var:[\\ }]*}" );
161
162
next = pathPattern .getHeadSection ().next ;
162
163
assertThat (next .getClass ().getName ()).isEqualTo (CaptureVariablePathElement .class .getName ());
163
- result = matchAndExtract (pathPattern ,"/}}}" );
164
+ result = matchAndExtract (pathPattern , "/}}}" );
164
165
assertThat (result .getUriVariables ().get ("var" )).isEqualTo ("}}}" );
165
166
166
167
pathPattern = checkStructure ("*" );
@@ -249,10 +250,10 @@ public void illegalCapturePatterns() {
249
250
PathPattern pp = parse ("/{abc:foo(bar)}" );
250
251
assertThatIllegalArgumentException ().isThrownBy (() ->
251
252
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)" );
253
254
assertThatIllegalArgumentException ().isThrownBy (() ->
254
255
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)" );
256
257
}
257
258
258
259
@ Test
@@ -414,12 +415,12 @@ public void compareTests() {
414
415
assertThat (patterns .get (1 )).isEqualTo (p2 );
415
416
}
416
417
417
- @ Test // Should be updated with gh-24952
418
- public void doubleWildcardWithinPatternNotSupported () {
418
+ @ Test
419
+ public void captureTheRestWithinPatternNotSupported () {
419
420
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 );
423
424
}
424
425
425
426
@ Test
@@ -461,16 +462,16 @@ private void checkError(String pattern, int expectedPos, PatternMessage expected
461
462
String ... expectedInserts ) {
462
463
463
464
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
+ });
474
475
}
475
476
476
477
@ SafeVarargs
0 commit comments