Replace assertThat(x.iterator().next()) with assertThat(x).element(0)
Search for : assertThat\((.+).iterator\(\).next\(\)\) Replace with : assertThat($1).element(0)
This commit is contained in:
@@ -472,7 +472,7 @@ public class MvcNamespaceTests {
|
||||
PathResourceResolver pathResolver = (PathResourceResolver) resolvers.get(3);
|
||||
Map<Resource, Charset> locationCharsets = pathResolver.getLocationCharsets();
|
||||
assertThat(locationCharsets).hasSize(1);
|
||||
assertThat(locationCharsets.values().iterator().next()).isEqualTo(StandardCharsets.ISO_8859_1);
|
||||
assertThat(locationCharsets.values()).element(0).isEqualTo(StandardCharsets.ISO_8859_1);
|
||||
|
||||
List<ResourceTransformer> transformers = handler.getResourceTransformers();
|
||||
assertThat(transformers).hasSize(2);
|
||||
|
||||
@@ -232,7 +232,7 @@ public class ResourceHandlerRegistryTests {
|
||||
PathResourceResolver resolver = (PathResourceResolver) resolvers.get(resolvers.size()-1);
|
||||
Map<Resource, Charset> locationCharsets = resolver.getLocationCharsets();
|
||||
assertThat(locationCharsets).hasSize(1);
|
||||
assertThat(locationCharsets.values().iterator().next()).isEqualTo(StandardCharsets.ISO_8859_1);
|
||||
assertThat(locationCharsets.values()).element(0).isEqualTo(StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -36,13 +36,13 @@ public class PathPatternsRequestConditionTests {
|
||||
|
||||
@Test
|
||||
void prependSlash() {
|
||||
assertThat(createCondition("foo").getPatternValues().iterator().next())
|
||||
assertThat(createCondition("foo").getPatternValues()).element(0)
|
||||
.isEqualTo("/foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void prependNonEmptyPatternsOnly() {
|
||||
assertThat(createCondition("").getPatternValues().iterator().next())
|
||||
assertThat(createCondition("").getPatternValues()).element(0).asString()
|
||||
.as("Do not prepend empty patterns (SPR-8255)").isEmpty();
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class PathPatternsRequestConditionTests {
|
||||
PathPatternsRequestCondition match = condition.getMatchingCondition(request);
|
||||
|
||||
assertThat(match).isNotNull();
|
||||
assertThat(match.getPatternValues().iterator().next()).as("Should match by default").isEqualTo("/foo");
|
||||
assertThat(match.getPatternValues()).element(0).as("Should match by default").isEqualTo("/foo");
|
||||
|
||||
PathPatternParser strictParser = new PathPatternParser();
|
||||
strictParser.setMatchOptionalTrailingSeparator(false);
|
||||
|
||||
@@ -35,13 +35,13 @@ class PatternsRequestConditionTests {
|
||||
|
||||
@Test
|
||||
void prependSlash() {
|
||||
assertThat(new PatternsRequestCondition("foo").getPatterns().iterator().next())
|
||||
assertThat(new PatternsRequestCondition("foo").getPatterns()).element(0)
|
||||
.isEqualTo("/foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void prependNonEmptyPatternsOnly() {
|
||||
assertThat(new PatternsRequestCondition("").getPatterns().iterator().next())
|
||||
assertThat(new PatternsRequestCondition("").getPatterns()).element(0).asString()
|
||||
.as("Do not prepend empty patterns (SPR-8255)").isEmpty();
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ class PatternsRequestConditionTests {
|
||||
PatternsRequestCondition match = condition.getMatchingCondition(request);
|
||||
|
||||
assertThat(match).isNotNull();
|
||||
assertThat(match.getPatterns().iterator().next()).isEqualTo("/{foo}.*");
|
||||
assertThat(match.getPatterns()).element(0).isEqualTo("/{foo}.*");
|
||||
|
||||
useSuffixPatternMatch = false;
|
||||
condition = new PatternsRequestCondition(
|
||||
@@ -130,7 +130,7 @@ class PatternsRequestConditionTests {
|
||||
match = condition.getMatchingCondition(request);
|
||||
|
||||
assertThat(match).isNotNull();
|
||||
assertThat(match.getPatterns().iterator().next()).isEqualTo("/{foo}");
|
||||
assertThat(match.getPatterns()).element(0).isEqualTo("/{foo}");
|
||||
}
|
||||
|
||||
@Test // SPR-8410
|
||||
@@ -143,13 +143,13 @@ class PatternsRequestConditionTests {
|
||||
PatternsRequestCondition match = condition.getMatchingCondition(request);
|
||||
|
||||
assertThat(match).isNotNull();
|
||||
assertThat(match.getPatterns().iterator().next()).isEqualTo("/jobs/{jobName}");
|
||||
assertThat(match.getPatterns()).element(0).isEqualTo("/jobs/{jobName}");
|
||||
|
||||
request = initRequest("/jobs/my.job.json");
|
||||
match = condition.getMatchingCondition(request);
|
||||
|
||||
assertThat(match).isNotNull();
|
||||
assertThat(match.getPatterns().iterator().next()).isEqualTo("/jobs/{jobName}.json");
|
||||
assertThat(match.getPatterns()).element(0).isEqualTo("/jobs/{jobName}.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -177,13 +177,13 @@ class PatternsRequestConditionTests {
|
||||
PatternsRequestCondition match = condition.getMatchingCondition(request);
|
||||
|
||||
assertThat(match).isNotNull();
|
||||
assertThat(match.getPatterns().iterator().next()).as("Should match by default").isEqualTo("/foo/");
|
||||
assertThat(match.getPatterns()).element(0).as("Should match by default").isEqualTo("/foo/");
|
||||
|
||||
condition = new PatternsRequestCondition(new String[] {"/foo"}, true, null);
|
||||
match = condition.getMatchingCondition(request);
|
||||
|
||||
assertThat(match).isNotNull();
|
||||
assertThat(match.getPatterns().iterator().next())
|
||||
assertThat(match.getPatterns()).element(0)
|
||||
.as("Trailing slash should be insensitive to useSuffixPatternMatch settings (SPR-6164, SPR-5636)")
|
||||
.isEqualTo("/foo/");
|
||||
|
||||
|
||||
@@ -354,11 +354,11 @@ public class RequestMappingHandlerMappingTests {
|
||||
|
||||
Set<String> paths = info.getPatternValues();
|
||||
assertThat(paths).hasSize(1);
|
||||
assertThat(paths.iterator().next()).isEqualTo(path);
|
||||
assertThat(paths).element(0).isEqualTo(path);
|
||||
|
||||
Set<RequestMethod> methods = info.getMethodsCondition().getMethods();
|
||||
assertThat(methods).hasSize(1);
|
||||
assertThat(methods.iterator().next()).isEqualTo(requestMethod);
|
||||
assertThat(methods).element(0).isEqualTo(requestMethod);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user