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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user