Skip to content

Commit 87d696d

Browse files
committed
Align with breaking API change in AssertJ 3.12
Closes gh-16145
1 parent c2e9f98 commit 87d696d

9 files changed

+76
-52
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/validation/ValidationErrorsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -101,7 +101,7 @@ public void iteratorShouldIterateErrors() {
101101
allErrors.add(new ObjectError("foo", "bar"));
102102
ValidationErrors errors = new ValidationErrors(NAME, Collections.emptySet(),
103103
allErrors);
104-
assertThat(errors.iterator()).containsExactlyElementsOf(allErrors);
104+
assertThat(errors.iterator()).toIterable().containsExactlyElementsOf(allErrors);
105105
}
106106

107107
@Test

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -127,7 +127,7 @@ public String getProperty(String key) {
127127
new MapPropertySource("baz", Collections.singletonMap("baz", "barf")));
128128
Iterable<ConfigurationPropertySource> configurationSources = ConfigurationPropertySources
129129
.from(sources);
130-
assertThat(configurationSources.iterator()).hasSize(5);
130+
assertThat(configurationSources.iterator()).toIterable().hasSize(5);
131131
}
132132

133133
}

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/DefaultPropertyMapperTests.java

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,33 +35,45 @@ protected PropertyMapper getMapper() {
3535

3636
@Test
3737
public void mapFromStringShouldReturnBestGuess() {
38-
assertThat(namesFromString("server")).containsExactly("server");
39-
assertThat(namesFromString("server.port")).containsExactly("server.port");
40-
assertThat(namesFromString("host[0]")).containsExactly("host[0]");
41-
assertThat(namesFromString("host[0][1]")).containsExactly("host[0][1]");
42-
assertThat(namesFromString("host[0].name")).containsExactly("host[0].name");
43-
assertThat(namesFromString("host.f00.name")).containsExactly("host.f00.name");
44-
assertThat(namesFromString("my.host-name")).containsExactly("my.host-name");
45-
assertThat(namesFromString("my.hostName")).containsExactly("my.hostname");
46-
assertThat(namesFromString("my.HOST_NAME")).containsExactly("my.hostname");
47-
assertThat(namesFromString("s[!@#$%^&*()=+]e-rVeR"))
38+
assertThat(namesFromString("server")).toIterable().containsExactly("server");
39+
assertThat(namesFromString("server.port")).toIterable()
40+
.containsExactly("server.port");
41+
assertThat(namesFromString("host[0]")).toIterable().containsExactly("host[0]");
42+
assertThat(namesFromString("host[0][1]")).toIterable()
43+
.containsExactly("host[0][1]");
44+
assertThat(namesFromString("host[0].name")).toIterable()
45+
.containsExactly("host[0].name");
46+
assertThat(namesFromString("host.f00.name")).toIterable()
47+
.containsExactly("host.f00.name");
48+
assertThat(namesFromString("my.host-name")).toIterable()
49+
.containsExactly("my.host-name");
50+
assertThat(namesFromString("my.hostName")).toIterable()
51+
.containsExactly("my.hostname");
52+
assertThat(namesFromString("my.HOST_NAME")).toIterable()
53+
.containsExactly("my.hostname");
54+
assertThat(namesFromString("s[!@#$%^&*()=+]e-rVeR")).toIterable()
4855
.containsExactly("s[!@#$%^&*()=+].e-rver");
49-
assertThat(namesFromString("host[FOO].name")).containsExactly("host[FOO].name");
56+
assertThat(namesFromString("host[FOO].name")).toIterable()
57+
.containsExactly("host[FOO].name");
5058
}
5159

5260
@Test
5361
public void mapFromConfigurationShouldReturnBestGuess() {
54-
assertThat(namesFromConfiguration("server")).containsExactly("server");
55-
assertThat(namesFromConfiguration("server.port")).containsExactly("server.port");
56-
assertThat(namesFromConfiguration("host[0]")).containsExactly("host[0]");
57-
assertThat(namesFromConfiguration("host[0][1]")).containsExactly("host[0][1]");
58-
assertThat(namesFromConfiguration("host[0].name"))
62+
assertThat(namesFromConfiguration("server")).toIterable()
63+
.containsExactly("server");
64+
assertThat(namesFromConfiguration("server.port")).toIterable()
65+
.containsExactly("server.port");
66+
assertThat(namesFromConfiguration("host[0]")).toIterable()
67+
.containsExactly("host[0]");
68+
assertThat(namesFromConfiguration("host[0][1]")).toIterable()
69+
.containsExactly("host[0][1]");
70+
assertThat(namesFromConfiguration("host[0].name")).toIterable()
5971
.containsExactly("host[0].name");
60-
assertThat(namesFromConfiguration("host.f00.name"))
72+
assertThat(namesFromConfiguration("host.f00.name")).toIterable()
6173
.containsExactly("host.f00.name");
62-
assertThat(namesFromConfiguration("my.host-name"))
74+
assertThat(namesFromConfiguration("my.host-name")).toIterable()
6375
.containsExactly("my.host-name");
64-
assertThat(namesFromConfiguration("host[FOO].name"))
76+
assertThat(namesFromConfiguration("host[FOO].name")).toIterable()
6577
.containsExactly("host[FOO].name");
6678
}
6779

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,8 @@ public class FilteredIterableConfigurationPropertiesSourceTests
3333
public void iteratorShouldFilterNames() {
3434
MockConfigurationPropertySource source = (MockConfigurationPropertySource) createTestSource();
3535
IterableConfigurationPropertySource filtered = source.filter(this::noBrackets);
36-
assertThat(filtered.iterator()).extracting(ConfigurationPropertyName::toString)
36+
assertThat(filtered.iterator()).toIterable()
37+
.extracting(ConfigurationPropertyName::toString)
3738
.containsExactly("a", "b", "c");
3839
}
3940

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void iteratorShouldGetFromMemory() {
8888
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
8989
source.put("foo.BAR", "spring");
9090
source.put("foo.baz", "boot");
91-
assertThat(source.iterator()).containsExactly(
91+
assertThat(source.iterator()).toIterable().containsExactly(
9292
ConfigurationPropertyName.of("foo.bar"),
9393
ConfigurationPropertyName.of("foo.baz"));
9494
}

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySourcesTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,23 +155,23 @@ public String getProperty(String key) {
155155
new MapPropertySource("baz", Collections.singletonMap("baz", "barf")));
156156
SpringConfigurationPropertySources configurationSources = new SpringConfigurationPropertySources(
157157
sources);
158-
assertThat(configurationSources.iterator()).hasSize(5);
158+
assertThat(configurationSources.iterator()).toIterable().hasSize(5);
159159
}
160160

161161
@Test
162162
public void shouldTrackChanges() {
163163
MutablePropertySources sources = new MutablePropertySources();
164164
SpringConfigurationPropertySources configurationSources = new SpringConfigurationPropertySources(
165165
sources);
166-
assertThat(configurationSources.iterator()).hasSize(0);
166+
assertThat(configurationSources.iterator()).toIterable().hasSize(0);
167167
MapPropertySource source1 = new MapPropertySource("test1",
168168
Collections.singletonMap("a", "b"));
169169
sources.addLast(source1);
170-
assertThat(configurationSources.iterator()).hasSize(1);
170+
assertThat(configurationSources.iterator()).toIterable().hasSize(1);
171171
MapPropertySource source2 = new MapPropertySource("test2",
172172
Collections.singletonMap("b", "c"));
173173
sources.addLast(source2);
174-
assertThat(configurationSources.iterator()).hasSize(2);
174+
assertThat(configurationSources.iterator()).toIterable().hasSize(2);
175175
}
176176

177177
@Test

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySourceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void iteratorShouldAdaptNames() {
7171
mapper.addFromPropertySource("key4", "my.key4");
7272
SpringIterableConfigurationPropertySource adapter = new SpringIterableConfigurationPropertySource(
7373
propertySource, mapper);
74-
assertThat(adapter.iterator()).extracting(Object::toString)
74+
assertThat(adapter.iterator()).toIterable().extracting(Object::toString)
7575
.containsExactly("my.key1", "my.key2a", "my.key2b", "my.key4");
7676
}
7777

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,26 +35,35 @@ protected PropertyMapper getMapper() {
3535

3636
@Test
3737
public void mapFromStringShouldReturnBestGuess() {
38-
assertThat(namesFromString("SERVER")).containsExactly("server");
39-
assertThat(namesFromString("SERVER_PORT")).containsExactly("server.port");
40-
assertThat(namesFromString("HOST_0")).containsExactly("host[0]");
41-
assertThat(namesFromString("HOST_0_1")).containsExactly("host[0][1]");
42-
assertThat(namesFromString("HOST_0_NAME")).containsExactly("host[0].name");
43-
assertThat(namesFromString("HOST_F00_NAME")).containsExactly("host.f00.name");
44-
assertThat(namesFromString("S-ERVER")).containsExactly("s-erver");
38+
assertThat(namesFromString("SERVER")).toIterable().containsExactly("server");
39+
assertThat(namesFromString("SERVER_PORT")).toIterable()
40+
.containsExactly("server.port");
41+
assertThat(namesFromString("HOST_0")).toIterable().containsExactly("host[0]");
42+
assertThat(namesFromString("HOST_0_1")).toIterable()
43+
.containsExactly("host[0][1]");
44+
assertThat(namesFromString("HOST_0_NAME")).toIterable()
45+
.containsExactly("host[0].name");
46+
assertThat(namesFromString("HOST_F00_NAME")).toIterable()
47+
.containsExactly("host.f00.name");
48+
assertThat(namesFromString("S-ERVER")).toIterable().containsExactly("s-erver");
4549
}
4650

4751
@Test
4852
public void mapFromConfigurationShouldReturnBestGuess() {
49-
assertThat(namesFromConfiguration("server")).containsExactly("SERVER");
50-
assertThat(namesFromConfiguration("server.port")).containsExactly("SERVER_PORT");
51-
assertThat(namesFromConfiguration("host[0]")).containsExactly("HOST_0");
52-
assertThat(namesFromConfiguration("host[0][1]")).containsExactly("HOST_0_1");
53-
assertThat(namesFromConfiguration("host[0].name")).containsExactly("HOST_0_NAME");
54-
assertThat(namesFromConfiguration("host.f00.name"))
53+
assertThat(namesFromConfiguration("server")).toIterable()
54+
.containsExactly("SERVER");
55+
assertThat(namesFromConfiguration("server.port")).toIterable()
56+
.containsExactly("SERVER_PORT");
57+
assertThat(namesFromConfiguration("host[0]")).toIterable()
58+
.containsExactly("HOST_0");
59+
assertThat(namesFromConfiguration("host[0][1]")).toIterable()
60+
.containsExactly("HOST_0_1");
61+
assertThat(namesFromConfiguration("host[0].name")).toIterable()
62+
.containsExactly("HOST_0_NAME");
63+
assertThat(namesFromConfiguration("host.f00.name")).toIterable()
5564
.containsExactly("HOST_F00_NAME");
56-
assertThat(namesFromConfiguration("foo.the-bar")).containsExactly("FOO_THEBAR",
57-
"FOO_THE_BAR");
65+
assertThat(namesFromConfiguration("foo.the-bar")).toIterable()
66+
.containsExactly("FOO_THEBAR", "FOO_THE_BAR");
5867
}
5968

6069
@Test

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletContextInitializerBeansTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,7 +48,8 @@ public void servletThatImplementsServletContextInitializerIsOnlyRegisteredOnce()
4848
ServletContextInitializerBeans initializerBeans = new ServletContextInitializerBeans(
4949
this.context.getBeanFactory());
5050
assertThat(initializerBeans.size()).isEqualTo(1);
51-
assertThat(initializerBeans.iterator()).hasOnlyElementsOfType(TestServlet.class);
51+
assertThat(initializerBeans.iterator()).toIterable()
52+
.hasOnlyElementsOfType(TestServlet.class);
5253
}
5354

5455
@Test
@@ -57,7 +58,8 @@ public void filterThatImplementsServletContextInitializerIsOnlyRegisteredOnce()
5758
ServletContextInitializerBeans initializerBeans = new ServletContextInitializerBeans(
5859
this.context.getBeanFactory());
5960
assertThat(initializerBeans.size()).isEqualTo(1);
60-
assertThat(initializerBeans.iterator()).hasOnlyElementsOfType(TestFilter.class);
61+
assertThat(initializerBeans.iterator()).toIterable()
62+
.hasOnlyElementsOfType(TestFilter.class);
6163
}
6264

6365
@Test
@@ -66,7 +68,7 @@ public void looksForInitializerBeansOfSpecifiedType() {
6668
ServletContextInitializerBeans initializerBeans = new ServletContextInitializerBeans(
6769
this.context.getBeanFactory(), TestServletContextInitializer.class);
6870
assertThat(initializerBeans.size()).isEqualTo(1);
69-
assertThat(initializerBeans.iterator())
71+
assertThat(initializerBeans.iterator()).toIterable()
7072
.hasOnlyElementsOfType(TestServletContextInitializer.class);
7173
}
7274

0 commit comments

Comments
 (0)