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:
parent
3f9a809c32
commit
785ad399e9
|
|
@ -526,9 +526,9 @@ class BeanWrapperGenericsTests {
|
|||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("genericProperty", "10");
|
||||
bw.setPropertyValue("genericListProperty", new String[] {"20", "30"});
|
||||
assertThat(gb.getGenericProperty().iterator().next()).isEqualTo(10);
|
||||
assertThat(gb.getGenericListProperty().get(0).iterator().next()).isEqualTo(20);
|
||||
assertThat(gb.getGenericListProperty().get(1).iterator().next()).isEqualTo(30);
|
||||
assertThat(gb.getGenericProperty()).element(0).isEqualTo(10);
|
||||
assertThat(gb.getGenericListProperty().get(0)).element(0).isEqualTo(20);
|
||||
assertThat(gb.getGenericListProperty().get(1)).element(0).isEqualTo(30);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class AotServicesTests {
|
|||
AotServices<?> loaded = AotServices
|
||||
.factories(new TestSpringFactoriesClassLoader("aot-services.factories"))
|
||||
.load(TestService.class);
|
||||
assertThat(loaded.iterator().next()).isInstanceOf(TestServiceImpl.class);
|
||||
assertThat(loaded).element(0).isInstanceOf(TestServiceImpl.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
|
|||
compile((actual, compiled) -> {
|
||||
Object value = actual.getPropertyValues().get("value");
|
||||
assertThat(value).isInstanceOf(ManagedSet.class);
|
||||
assertThat(((Set<?>) value).iterator().next()).isInstanceOf(BeanReference.class);
|
||||
assertThat(((Set<?>) value)).element(0).isInstanceOf(BeanReference.class);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class PropertyPathFactoryBeanTests {
|
|||
TestBean tbWithInner = (TestBean) xbf.getBean("tbWithInner");
|
||||
assertThat(tbWithInner.getSpouse()).isSameAs(spouse);
|
||||
assertThat(tbWithInner.getFriends().isEmpty()).isFalse();
|
||||
assertThat(tbWithInner.getFriends().iterator().next()).isSameAs(spouse);
|
||||
assertThat(tbWithInner.getFriends()).element(0).isSameAs(spouse);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -405,7 +405,7 @@ public class PropertyResourceConfigurerTests {
|
|||
assertThat(tb2.getStringArray()[0]).isEqualTo(System.getProperty("os.name"));
|
||||
assertThat(tb2.getStringArray()[1]).isEqualTo("98");
|
||||
assertThat(tb2.getFriends()).hasSize(2);
|
||||
assertThat(tb2.getFriends().iterator().next()).isEqualTo("na98me");
|
||||
assertThat(tb2.getFriends()).element(0).isEqualTo("na98me");
|
||||
assertThat(tb2.getFriends().toArray()[1]).isEqualTo(tb2);
|
||||
assertThat(tb2.getSomeSet()).hasSize(3);
|
||||
assertThat(tb2.getSomeSet().contains("na98me")).isTrue();
|
||||
|
|
|
|||
|
|
@ -574,9 +574,9 @@ class BeanFactoryGenericsTests {
|
|||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
new ClassPathResource("genericBeanTests.xml", getClass()));
|
||||
GenericSetOfIntegerBean gb = (GenericSetOfIntegerBean) bf.getBean("setOfIntegerBean");
|
||||
assertThat(gb.getGenericProperty().iterator().next()).isEqualTo(10);
|
||||
assertThat(gb.getGenericListProperty().get(0).iterator().next()).isEqualTo(20);
|
||||
assertThat(gb.getGenericListProperty().get(1).iterator().next()).isEqualTo(30);
|
||||
assertThat(gb.getGenericProperty()).element(0).isEqualTo(10);
|
||||
assertThat(gb.getGenericListProperty().get(0)).element(0).isEqualTo(20);
|
||||
assertThat(gb.getGenericListProperty().get(1)).element(0).isEqualTo(30);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class CustomCollectionEditorTests {
|
|||
Collection<?> value = (Collection<?>) editor.getValue();
|
||||
assertThat(value).isNotNull();
|
||||
assertThat(value).as("There must be 1 element in the converted collection").hasSize(1);
|
||||
assertThat(value.iterator().next()).isEqualTo("0, 1, 2");
|
||||
assertThat(value).element(0).isEqualTo("0, 1, 2");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public abstract class AbstractCacheOperationTests<O extends JCacheOperation<?>>
|
|||
assertThat(operation.getCacheName()).as("Wrong cache name").isEqualTo("simpleCache");
|
||||
assertThat(operation.getAnnotations()).as("Unexpected number of annotation on " + operation.getMethod())
|
||||
.hasSize(1);
|
||||
assertThat(operation.getAnnotations().iterator().next()).as("Wrong method annotation").isEqualTo(operation.getCacheAnnotation());
|
||||
assertThat(operation.getAnnotations()).element(0).as("Wrong method annotation").isEqualTo(operation.getCacheAnnotation());
|
||||
|
||||
assertThat(operation.getCacheResolver()).as("cache resolver should be set").isNotNull();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class AnnotationCacheOperationSourceTests {
|
|||
@Test
|
||||
public void singularAnnotation() {
|
||||
Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singular", 1);
|
||||
assertThat(ops.iterator().next()).isInstanceOf(CacheableOperation.class);
|
||||
assertThat(ops).element(0).isInstanceOf(CacheableOperation.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -76,7 +76,7 @@ public class AnnotationCacheOperationSourceTests {
|
|||
@Test
|
||||
public void singularStereotype() {
|
||||
Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singleStereotype", 1);
|
||||
assertThat(ops.iterator().next()).isInstanceOf(CacheEvictOperation.class);
|
||||
assertThat(ops).element(0).isInstanceOf(CacheEvictOperation.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -307,8 +307,8 @@ class AnnotationConfigApplicationContextTests {
|
|||
assertThat(ObjectUtils.containsElement(context.getBeanNamesForType(BeanC.class), "c")).isTrue();
|
||||
|
||||
assertThat(context.getBeansOfType(BeanA.class)).isEmpty();
|
||||
assertThat(context.getBeansOfType(BeanB.class).values().iterator().next()).isSameAs(context.getBean(BeanB.class));
|
||||
assertThat(context.getBeansOfType(BeanC.class).values().iterator().next()).isSameAs(context.getBean(BeanC.class));
|
||||
assertThat(context.getBeansOfType(BeanB.class).values()).element(0).isSameAs(context.getBean(BeanB.class));
|
||||
assertThat(context.getBeansOfType(BeanC.class).values()).element(0).isSameAs(context.getBean(BeanC.class));
|
||||
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
|
||||
.isThrownBy(() -> context.getBeanFactory().resolveNamedBean(BeanA.class));
|
||||
|
|
|
|||
|
|
@ -1069,7 +1069,7 @@ class ConfigurationClassPostProcessorTests {
|
|||
MapArgumentConfiguration bean = ctx.getBean(MapArgumentConfiguration.class);
|
||||
assertThat(bean.testBeans).isNotNull();
|
||||
assertThat(bean.testBeans).hasSize(1);
|
||||
assertThat(bean.testBeans.values().iterator().next()).isSameAs(ctx.getBean(Runnable.class));
|
||||
assertThat(bean.testBeans.values()).element(0).isSameAs(ctx.getBean(Runnable.class));
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public class ImportSelectorTests {
|
|||
ordered.verify(beanFactory).registerBeanDefinition(eq("d"), any());
|
||||
assertThat(TestImportGroup.instancesCount.get()).isEqualTo(1);
|
||||
assertThat(TestImportGroup.imports).hasSize(1);
|
||||
assertThat(TestImportGroup.imports.values().iterator().next()).hasSize(2);
|
||||
assertThat(TestImportGroup.imports.values()).element(0).asList().hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ class NestedConfigurationClassTests {
|
|||
TestBean pb1 = ctx.getBean("prototypeBean", TestBean.class);
|
||||
TestBean pb2 = ctx.getBean("prototypeBean", TestBean.class);
|
||||
assertThat(pb1).isNotSameAs(pb2);
|
||||
assertThat(pb1.getFriends().iterator().next()).isNotSameAs(pb2.getFriends().iterator().next());
|
||||
assertThat(pb1.getFriends()).element(0).isNotSameAs(pb2.getFriends());
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ class NestedConfigurationClassTests {
|
|||
TestBean pb1 = ctx.getBean("prototypeBean", TestBean.class);
|
||||
TestBean pb2 = ctx.getBean("prototypeBean", TestBean.class);
|
||||
assertThat(pb1).isNotSameAs(pb2);
|
||||
assertThat(pb1.getFriends().iterator().next()).isNotSameAs(pb2.getFriends().iterator().next());
|
||||
assertThat(pb1.getFriends()).element(0).isNotSameAs(pb2.getFriends());
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ class NestedConfigurationClassTests {
|
|||
TestBean pb1 = ctx.getBean("prototypeBean", TestBean.class);
|
||||
TestBean pb2 = ctx.getBean("prototypeBean", TestBean.class);
|
||||
assertThat(pb1).isNotSameAs(pb2);
|
||||
assertThat(pb1.getFriends().iterator().next()).isNotSameAs(pb2.getFriends().iterator().next());
|
||||
assertThat(pb1.getFriends()).element(0).isNotSameAs(pb2.getFriends());
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -318,16 +318,16 @@ public class ClassPathXmlApplicationContextTests {
|
|||
|
||||
Map<?, StaticMessageSource> beansOfType = ctx.getBeansOfType(StaticMessageSource.class);
|
||||
assertThat(beansOfType).hasSize(1);
|
||||
assertThat(beansOfType.values().iterator().next()).isSameAs(myMessageSource);
|
||||
assertThat(beansOfType.values()).element(0).isSameAs(myMessageSource);
|
||||
beansOfType = ctx.getBeansOfType(StaticMessageSource.class, true, true);
|
||||
assertThat(beansOfType).hasSize(1);
|
||||
assertThat(beansOfType.values().iterator().next()).isSameAs(myMessageSource);
|
||||
assertThat(beansOfType.values()).element(0).isSameAs(myMessageSource);
|
||||
beansOfType = BeanFactoryUtils.beansOfTypeIncludingAncestors(ctx, StaticMessageSource.class);
|
||||
assertThat(beansOfType).hasSize(1);
|
||||
assertThat(beansOfType.values().iterator().next()).isSameAs(myMessageSource);
|
||||
assertThat(beansOfType.values()).element(0).isSameAs(myMessageSource);
|
||||
beansOfType = BeanFactoryUtils.beansOfTypeIncludingAncestors(ctx, StaticMessageSource.class, true, true);
|
||||
assertThat(beansOfType).hasSize(1);
|
||||
assertThat(beansOfType.values().iterator().next()).isSameAs(myMessageSource);
|
||||
assertThat(beansOfType.values()).element(0).isSameAs(myMessageSource);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -142,8 +142,8 @@ class ConversionServiceFactoryBeanTests {
|
|||
|
||||
ComplexConstructorArgument(Map<String, Class<?>> map) {
|
||||
assertThat(map.isEmpty()).isFalse();
|
||||
assertThat(map.keySet().iterator().next()).isInstanceOf(String.class);
|
||||
assertThat(map.values().iterator().next()).isInstanceOf(Class.class);
|
||||
assertThat(map.keySet()).element(0).isInstanceOf(String.class);
|
||||
assertThat(map.values()).element(0).isInstanceOf(Class.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -242,9 +242,9 @@ class GenericApplicationContextTests {
|
|||
assertThat(context.getBeanNamesForType(BeanB.class)).containsExactly("b");
|
||||
assertThat(context.getBeanNamesForType(BeanC.class)).containsExactly("c");
|
||||
assertThat(context.getBeansOfType(BeanA.class)).isEmpty();
|
||||
assertThat(context.getBeansOfType(BeanB.class).values().iterator().next())
|
||||
assertThat(context.getBeansOfType(BeanB.class).values()).element(0)
|
||||
.isSameAs(context.getBean(BeanB.class));
|
||||
assertThat(context.getBeansOfType(BeanC.class).values().iterator().next())
|
||||
assertThat(context.getBeansOfType(BeanC.class).values()).element(0)
|
||||
.isSameAs(context.getBean(BeanC.class));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public class PropertySourcesPlaceholderConfigurerTests {
|
|||
ppc.setPropertySources(propertySources);
|
||||
ppc.postProcessBeanFactory(bf);
|
||||
assertThat(bf.getBean(TestBean.class).getName()).isEqualTo("foo");
|
||||
assertThat(propertySources.iterator().next()).isEqualTo(ppc.getAppliedPropertySources().iterator().next());
|
||||
assertThat(propertySources).element(0).isEqualTo(ppc.getAppliedPropertySources().iterator().next());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -132,7 +132,7 @@ public class PropertySourcesPlaceholderConfigurerTests {
|
|||
ppc.setIgnoreUnresolvablePlaceholders(true);
|
||||
ppc.postProcessBeanFactory(bf);
|
||||
assertThat(bf.getBean(TestBean.class).getName()).isEqualTo("${my.name}");
|
||||
assertThat(propertySources.iterator().next()).isEqualTo(ppc.getAppliedPropertySources().iterator().next());
|
||||
assertThat(propertySources).element(0).isEqualTo(ppc.getAppliedPropertySources().iterator().next());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class AsyncResultTests {
|
|||
throw new AssertionError("Failure callback not expected: " + ex, ex);
|
||||
}
|
||||
});
|
||||
assertThat(values.iterator().next()).isSameAs(value);
|
||||
assertThat(values).element(0).isSameAs(value);
|
||||
assertThat(future.get()).isSameAs(value);
|
||||
assertThat(future.completable().get()).isSameAs(value);
|
||||
future.completable().thenAccept(v -> assertThat(v).isSameAs(value));
|
||||
|
|
@ -69,7 +69,7 @@ public class AsyncResultTests {
|
|||
values.add(ex);
|
||||
}
|
||||
});
|
||||
assertThat(values.iterator().next()).isSameAs(ex);
|
||||
assertThat(values).element(0).isSameAs(ex);
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(future::get)
|
||||
.withCause(ex);
|
||||
|
|
@ -85,7 +85,7 @@ public class AsyncResultTests {
|
|||
final Set<String> values = new HashSet<>(1);
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = AsyncResult.forValue(value);
|
||||
future.addCallback(values::add, ex -> new AssertionError("Failure callback not expected: " + ex));
|
||||
assertThat(values.iterator().next()).isSameAs(value);
|
||||
assertThat(values).element(0).isSameAs(value);
|
||||
assertThat(future.get()).isSameAs(value);
|
||||
assertThat(future.completable().get()).isSameAs(value);
|
||||
future.completable().thenAccept(v -> assertThat(v).isSameAs(value));
|
||||
|
|
@ -98,7 +98,7 @@ public class AsyncResultTests {
|
|||
final Set<Throwable> values = new HashSet<>(1);
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = AsyncResult.forExecutionException(ex);
|
||||
future.addCallback(result -> new AssertionError("Success callback not expected: " + result), values::add);
|
||||
assertThat(values.iterator().next()).isSameAs(ex);
|
||||
assertThat(values).element(0).isSameAs(ex);
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(future::get)
|
||||
.withCause(ex);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class JmsListenerEndpointRegistrarTests {
|
|||
this.registrar.afterPropertiesSet();
|
||||
assertThat(this.registry.getListenerContainer("some id")).as("Container not created").isNotNull();
|
||||
assertThat(this.registry.getListenerContainers()).hasSize(1);
|
||||
assertThat(this.registry.getListenerContainerIds().iterator().next()).isEqualTo("some id");
|
||||
assertThat(this.registry.getListenerContainerIds()).element(0).isEqualTo("some id");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -97,7 +97,7 @@ public class JmsListenerEndpointRegistrarTests {
|
|||
this.registrar.afterPropertiesSet();
|
||||
assertThat(this.registry.getListenerContainer("myEndpoint")).as("Container not created").isNotNull();
|
||||
assertThat(this.registry.getListenerContainers()).hasSize(1);
|
||||
assertThat(this.registry.getListenerContainerIds().iterator().next()).isEqualTo("myEndpoint");
|
||||
assertThat(this.registry.getListenerContainerIds()).element(0).isEqualTo("myEndpoint");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class DestinationPatternsMessageConditionTests {
|
|||
@Test
|
||||
public void prependSlash() {
|
||||
DestinationPatternsMessageCondition c = condition("foo");
|
||||
assertThat(c.getPatterns().iterator().next()).isEqualTo("/foo");
|
||||
assertThat(c.getPatterns()).element(0).isEqualTo("/foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -42,7 +42,7 @@ public class DestinationPatternsMessageConditionTests {
|
|||
DestinationPatternsMessageCondition c =
|
||||
new DestinationPatternsMessageCondition(new String[] {"foo"}, new AntPathMatcher("."));
|
||||
|
||||
assertThat(c.getPatterns().iterator().next()).as("Pre-pending should be disabled when not using '/' as path separator").isEqualTo("foo");
|
||||
assertThat(c.getPatterns()).element(0).as("Pre-pending should be disabled when not using '/' as path separator").isEqualTo("foo");
|
||||
}
|
||||
|
||||
// SPR-8255
|
||||
|
|
@ -50,7 +50,7 @@ public class DestinationPatternsMessageConditionTests {
|
|||
@Test
|
||||
public void prependNonEmptyPatternsOnly() {
|
||||
DestinationPatternsMessageCondition c = condition("");
|
||||
assertThat(c.getPatterns().iterator().next()).isEmpty();
|
||||
assertThat(c.getPatterns()).element(0).asString().isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
|
||||
assertThat(actual.getSourceDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations().iterator().next()).isEqualTo("/queue/foo-user123");
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-user123");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getUser()).isEqualTo(user.getName());
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations().iterator().next()).isEqualTo("jms.queue.call-user123");
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("jms.queue.call-user123");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo(destination);
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations().iterator().next()).isEqualTo("/queue/foo-user456");
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-user456");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -105,7 +105,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
|
||||
assertThat(actual.getSourceDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations().iterator().next()).isEqualTo(("/queue/foo-user" + "123"));
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo(("/queue/foo-user" + "123"));
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getUser()).isNull();
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations().iterator().next()).isEqualTo("/queue/foo-user123");
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-user123");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -138,7 +138,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
|
||||
assertThat(actual.getSourceDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations().iterator().next()).isEqualTo("/queue/foo-user123");
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-user123");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo("/user/queue/foo");
|
||||
assertThat(actual.getUser()).isEqualTo(user.getName());
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations().iterator().next()).isEqualTo("jms.queue.call-user123");
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("jms.queue.call-user123");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo("/user/jms.queue.call");
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
|
||||
assertThat(actual.getSourceDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations().iterator().next()).isEqualTo("/queue/foo-user456");
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-user456");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo("/user/queue/foo");
|
||||
assertThat(actual.getUser()).isEqualTo(otherUser.getName());
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations().iterator().next()).isEqualTo("/queue/foo-useropenid123");
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-useropenid123");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -203,7 +203,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
|
||||
assertThat(actual.getSourceDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations().iterator().next()).isEqualTo("/queue/foo-user123");
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-user123");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo("/user/queue/foo");
|
||||
assertThat(actual.getUser()).isNull();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ class MockHttpServletResponseTests {
|
|||
Collection<String> responseHeaders = response.getHeaderNames();
|
||||
assertThat(responseHeaders).isNotNull();
|
||||
assertThat(responseHeaders).hasSize(1);
|
||||
assertThat(responseHeaders.iterator().next()).as("HTTP header casing not being preserved").isEqualTo(headerName);
|
||||
assertThat(responseHeaders).element(0).as("HTTP header casing not being preserved").isEqualTo(headerName);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ class RequestMappingHandlerMappingTests {
|
|||
|
||||
Set<RequestMethod> methods = info.getMethodsCondition().getMethods();
|
||||
assertThat(methods).hasSize(1);
|
||||
assertThat(methods.iterator().next()).isEqualTo(requestMethod);
|
||||
assertThat(methods).element(0).isEqualTo(requestMethod);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue