Fix unit tests
This commit is contained in:
@@ -159,7 +159,17 @@ There are two styles of entries:
|
||||
@Override
|
||||
public String[] getSplitPath() {
|
||||
String paths = requestPathSupplier.get();
|
||||
return Arrays.stream(paths.split("\\|\\|")).map(s -> s.trim()).toArray(String[]::new);
|
||||
return Arrays.stream(paths.split("\\|\\|"))
|
||||
.map(s -> s.trim())
|
||||
.filter(s -> !s.isEmpty())
|
||||
.map(s -> {
|
||||
if (s.charAt(0) != '/') {
|
||||
return '/' + s;
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
})
|
||||
.toArray(String[]::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,21 +38,21 @@ public class RequestMappingImp1Test {
|
||||
|
||||
@Test
|
||||
public void testSplitPathSimpleCase() {
|
||||
RequestMappingImpl1 rm = new RequestMappingImpl1("/superpath/mypath || mypath.json", null);
|
||||
RequestMappingImpl1 rm = new RequestMappingImpl1("{[/superpath/mypath || mypath.json]}", null);
|
||||
String[] splitPath = rm.getSplitPath();
|
||||
assertEquals(2, splitPath.length);
|
||||
assertEquals("/superpath/mypath", splitPath[0]);
|
||||
assertEquals("/superpath/mypath.json", splitPath[1]);
|
||||
assertEquals("/mypath.json", splitPath[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitPathMultipleCases() {
|
||||
RequestMappingImpl1 rm = new RequestMappingImpl1("/superpath/mypath || mypath.json || somethingelse.what", null);
|
||||
RequestMappingImpl1 rm = new RequestMappingImpl1("{[/superpath/mypath || mypath.json || somethingelse.what]}", null);
|
||||
String[] splitPath = rm.getSplitPath();
|
||||
assertEquals(3, splitPath.length);
|
||||
assertEquals("/superpath/mypath", splitPath[0]);
|
||||
assertEquals("/superpath/mypath.json", splitPath[1]);
|
||||
assertEquals("/superpath/somethingelse.what", splitPath[2]);
|
||||
assertEquals("/mypath.json", splitPath[1]);
|
||||
assertEquals("/somethingelse.what", splitPath[2]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user