Polish "Use idiomatic AssertJ map assertions"
See gh-31752
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -145,16 +145,14 @@ public class ConfigurationClassWithConditionTests {
|
||||
public void noConditionOnOverriddenMethodHonored() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithBeanReactivated.class);
|
||||
Map<String, ExampleBean> beans = context.getBeansOfType(ExampleBean.class);
|
||||
assertThat(beans).hasSize(1);
|
||||
assertThat(beans.keySet().iterator().next()).isEqualTo("baz");
|
||||
assertThat(beans).containsOnlyKeys("baz");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configWithAlternativeBeans() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithAlternativeBeans.class);
|
||||
Map<String, ExampleBean> beans = context.getBeansOfType(ExampleBean.class);
|
||||
assertThat(beans).hasSize(1);
|
||||
assertThat(beans.keySet().iterator().next()).isEqualTo("baz");
|
||||
assertThat(beans).containsOnlyKeys("baz");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,7 +24,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@@ -141,10 +140,8 @@ public class ImportSelectorTests {
|
||||
ordered.verify(beanFactory).registerBeanDefinition(eq("c"), any());
|
||||
ordered.verify(beanFactory).registerBeanDefinition(eq("d"), any());
|
||||
assertThat(TestImportGroup.instancesCount.get()).isEqualTo(1);
|
||||
assertThat(TestImportGroup.imports).hasSize(2);
|
||||
Iterator<AnnotationMetadata> iterator = TestImportGroup.imports.keySet().iterator();
|
||||
assertThat(iterator.next().getClassName()).isEqualTo(GroupedConfig2.class.getName());
|
||||
assertThat(iterator.next().getClassName()).isEqualTo(GroupedConfig1.class.getName());
|
||||
assertThat(TestImportGroup.imports.keySet().stream().map(AnnotationMetadata::getClassName))
|
||||
.containsExactly(GroupedConfig2.class.getName(),GroupedConfig1.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -57,12 +57,10 @@ public class Spr8954Tests {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map<String, FactoryBean> fbBeans = bf.getBeansOfType(FactoryBean.class);
|
||||
assertThat(fbBeans.size()).isEqualTo(1);
|
||||
assertThat(fbBeans.keySet().iterator().next()).isEqualTo("&foo");
|
||||
assertThat(fbBeans).containsOnlyKeys("&foo");
|
||||
|
||||
Map<String, AnInterface> aiBeans = bf.getBeansOfType(AnInterface.class);
|
||||
assertThat(aiBeans.size()).isEqualTo(1);
|
||||
assertThat(aiBeans.keySet().iterator().next()).isEqualTo("&foo");
|
||||
assertThat(aiBeans).containsOnlyKeys("&foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -76,12 +74,10 @@ public class Spr8954Tests {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map<String, FactoryBean> fbBeans = bf.getBeansOfType(FactoryBean.class);
|
||||
assertThat(fbBeans.size()).isEqualTo(1);
|
||||
assertThat(fbBeans.keySet().iterator().next()).isEqualTo("&foo");
|
||||
assertThat(fbBeans).containsOnlyKeys("&foo");
|
||||
|
||||
Map<String, AnInterface> aiBeans = bf.getBeansOfType(AnInterface.class);
|
||||
assertThat(aiBeans.size()).isEqualTo(1);
|
||||
assertThat(aiBeans.keySet().iterator().next()).isEqualTo("&foo");
|
||||
assertThat(aiBeans).containsOnlyKeys("&foo");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user