diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/validation/ValidationErrorsTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/validation/ValidationErrorsTests.java index 28643775916..f6f17ce6753 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/validation/ValidationErrorsTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/validation/ValidationErrorsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 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. @@ -101,7 +101,7 @@ public class ValidationErrorsTests { allErrors.add(new ObjectError("foo", "bar")); ValidationErrors errors = new ValidationErrors(NAME, Collections.emptySet(), allErrors); - assertThat(errors.iterator()).containsExactlyElementsOf(allErrors); + assertThat(errors.iterator()).toIterable().containsExactlyElementsOf(allErrors); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesTests.java index 9466f99fee2..56d367696de 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 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. @@ -127,7 +127,7 @@ public class ConfigurationPropertySourcesTests { new MapPropertySource("baz", Collections.singletonMap("baz", "barf"))); Iterable configurationSources = ConfigurationPropertySources .from(sources); - assertThat(configurationSources.iterator()).hasSize(5); + assertThat(configurationSources.iterator()).toIterable().hasSize(5); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/DefaultPropertyMapperTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/DefaultPropertyMapperTests.java index 7a9e7b4e9b8..dae75cbbe30 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/DefaultPropertyMapperTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/DefaultPropertyMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 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. @@ -35,33 +35,45 @@ public class DefaultPropertyMapperTests extends AbstractPropertyMapperTests { @Test public void mapFromStringShouldReturnBestGuess() { - assertThat(namesFromString("server")).containsExactly("server"); - assertThat(namesFromString("server.port")).containsExactly("server.port"); - assertThat(namesFromString("host[0]")).containsExactly("host[0]"); - assertThat(namesFromString("host[0][1]")).containsExactly("host[0][1]"); - assertThat(namesFromString("host[0].name")).containsExactly("host[0].name"); - assertThat(namesFromString("host.f00.name")).containsExactly("host.f00.name"); - assertThat(namesFromString("my.host-name")).containsExactly("my.host-name"); - assertThat(namesFromString("my.hostName")).containsExactly("my.hostname"); - assertThat(namesFromString("my.HOST_NAME")).containsExactly("my.hostname"); - assertThat(namesFromString("s[!@#$%^&*()=+]e-rVeR")) + assertThat(namesFromString("server")).toIterable().containsExactly("server"); + assertThat(namesFromString("server.port")).toIterable() + .containsExactly("server.port"); + assertThat(namesFromString("host[0]")).toIterable().containsExactly("host[0]"); + assertThat(namesFromString("host[0][1]")).toIterable() + .containsExactly("host[0][1]"); + assertThat(namesFromString("host[0].name")).toIterable() + .containsExactly("host[0].name"); + assertThat(namesFromString("host.f00.name")).toIterable() + .containsExactly("host.f00.name"); + assertThat(namesFromString("my.host-name")).toIterable() + .containsExactly("my.host-name"); + assertThat(namesFromString("my.hostName")).toIterable() + .containsExactly("my.hostname"); + assertThat(namesFromString("my.HOST_NAME")).toIterable() + .containsExactly("my.hostname"); + assertThat(namesFromString("s[!@#$%^&*()=+]e-rVeR")).toIterable() .containsExactly("s[!@#$%^&*()=+].e-rver"); - assertThat(namesFromString("host[FOO].name")).containsExactly("host[FOO].name"); + assertThat(namesFromString("host[FOO].name")).toIterable() + .containsExactly("host[FOO].name"); } @Test public void mapFromConfigurationShouldReturnBestGuess() { - assertThat(namesFromConfiguration("server")).containsExactly("server"); - assertThat(namesFromConfiguration("server.port")).containsExactly("server.port"); - assertThat(namesFromConfiguration("host[0]")).containsExactly("host[0]"); - assertThat(namesFromConfiguration("host[0][1]")).containsExactly("host[0][1]"); - assertThat(namesFromConfiguration("host[0].name")) + assertThat(namesFromConfiguration("server")).toIterable() + .containsExactly("server"); + assertThat(namesFromConfiguration("server.port")).toIterable() + .containsExactly("server.port"); + assertThat(namesFromConfiguration("host[0]")).toIterable() + .containsExactly("host[0]"); + assertThat(namesFromConfiguration("host[0][1]")).toIterable() + .containsExactly("host[0][1]"); + assertThat(namesFromConfiguration("host[0].name")).toIterable() .containsExactly("host[0].name"); - assertThat(namesFromConfiguration("host.f00.name")) + assertThat(namesFromConfiguration("host.f00.name")).toIterable() .containsExactly("host.f00.name"); - assertThat(namesFromConfiguration("my.host-name")) + assertThat(namesFromConfiguration("my.host-name")).toIterable() .containsExactly("my.host-name"); - assertThat(namesFromConfiguration("host[FOO].name")) + assertThat(namesFromConfiguration("host[FOO].name")).toIterable() .containsExactly("host[FOO].name"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java index 7e406109368..336ad38093d 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 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. @@ -33,7 +33,8 @@ public class FilteredIterableConfigurationPropertiesSourceTests public void iteratorShouldFilterNames() { MockConfigurationPropertySource source = (MockConfigurationPropertySource) createTestSource(); IterableConfigurationPropertySource filtered = source.filter(this::noBrackets); - assertThat(filtered.iterator()).extracting(ConfigurationPropertyName::toString) + assertThat(filtered.iterator()).toIterable() + .extracting(ConfigurationPropertyName::toString) .containsExactly("a", "b", "c"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java index 7bc05a938e0..aeffb3bff7a 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java @@ -88,7 +88,7 @@ public class MapConfigurationPropertySourceTests { MapConfigurationPropertySource source = new MapConfigurationPropertySource(); source.put("foo.BAR", "spring"); source.put("foo.baz", "boot"); - assertThat(source.iterator()).containsExactly( + assertThat(source.iterator()).toIterable().containsExactly( ConfigurationPropertyName.of("foo.bar"), ConfigurationPropertyName.of("foo.baz")); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySourcesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySourcesTests.java index 6890a35753d..76f77ec2d86 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySourcesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySourcesTests.java @@ -155,7 +155,7 @@ public class SpringConfigurationPropertySourcesTests { new MapPropertySource("baz", Collections.singletonMap("baz", "barf"))); SpringConfigurationPropertySources configurationSources = new SpringConfigurationPropertySources( sources); - assertThat(configurationSources.iterator()).hasSize(5); + assertThat(configurationSources.iterator()).toIterable().hasSize(5); } @Test @@ -163,15 +163,15 @@ public class SpringConfigurationPropertySourcesTests { MutablePropertySources sources = new MutablePropertySources(); SpringConfigurationPropertySources configurationSources = new SpringConfigurationPropertySources( sources); - assertThat(configurationSources.iterator()).hasSize(0); + assertThat(configurationSources.iterator()).toIterable().hasSize(0); MapPropertySource source1 = new MapPropertySource("test1", Collections.singletonMap("a", "b")); sources.addLast(source1); - assertThat(configurationSources.iterator()).hasSize(1); + assertThat(configurationSources.iterator()).toIterable().hasSize(1); MapPropertySource source2 = new MapPropertySource("test2", Collections.singletonMap("b", "c")); sources.addLast(source2); - assertThat(configurationSources.iterator()).hasSize(2); + assertThat(configurationSources.iterator()).toIterable().hasSize(2); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySourceTests.java index f4fc744b345..ff3b32bc6dd 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySourceTests.java @@ -71,7 +71,7 @@ public class SpringIterableConfigurationPropertySourceTests { mapper.addFromPropertySource("key4", "my.key4"); SpringIterableConfigurationPropertySource adapter = new SpringIterableConfigurationPropertySource( propertySource, mapper); - assertThat(adapter.iterator()).extracting(Object::toString) + assertThat(adapter.iterator()).toIterable().extracting(Object::toString) .containsExactly("my.key1", "my.key2a", "my.key2b", "my.key4"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java index ed90af79f0c..489bc1797c0 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 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. @@ -35,26 +35,35 @@ public class SystemEnvironmentPropertyMapperTests extends AbstractPropertyMapper @Test public void mapFromStringShouldReturnBestGuess() { - assertThat(namesFromString("SERVER")).containsExactly("server"); - assertThat(namesFromString("SERVER_PORT")).containsExactly("server.port"); - assertThat(namesFromString("HOST_0")).containsExactly("host[0]"); - assertThat(namesFromString("HOST_0_1")).containsExactly("host[0][1]"); - assertThat(namesFromString("HOST_0_NAME")).containsExactly("host[0].name"); - assertThat(namesFromString("HOST_F00_NAME")).containsExactly("host.f00.name"); - assertThat(namesFromString("S-ERVER")).containsExactly("s-erver"); + assertThat(namesFromString("SERVER")).toIterable().containsExactly("server"); + assertThat(namesFromString("SERVER_PORT")).toIterable() + .containsExactly("server.port"); + assertThat(namesFromString("HOST_0")).toIterable().containsExactly("host[0]"); + assertThat(namesFromString("HOST_0_1")).toIterable() + .containsExactly("host[0][1]"); + assertThat(namesFromString("HOST_0_NAME")).toIterable() + .containsExactly("host[0].name"); + assertThat(namesFromString("HOST_F00_NAME")).toIterable() + .containsExactly("host.f00.name"); + assertThat(namesFromString("S-ERVER")).toIterable().containsExactly("s-erver"); } @Test public void mapFromConfigurationShouldReturnBestGuess() { - assertThat(namesFromConfiguration("server")).containsExactly("SERVER"); - assertThat(namesFromConfiguration("server.port")).containsExactly("SERVER_PORT"); - assertThat(namesFromConfiguration("host[0]")).containsExactly("HOST_0"); - assertThat(namesFromConfiguration("host[0][1]")).containsExactly("HOST_0_1"); - assertThat(namesFromConfiguration("host[0].name")).containsExactly("HOST_0_NAME"); - assertThat(namesFromConfiguration("host.f00.name")) + assertThat(namesFromConfiguration("server")).toIterable() + .containsExactly("SERVER"); + assertThat(namesFromConfiguration("server.port")).toIterable() + .containsExactly("SERVER_PORT"); + assertThat(namesFromConfiguration("host[0]")).toIterable() + .containsExactly("HOST_0"); + assertThat(namesFromConfiguration("host[0][1]")).toIterable() + .containsExactly("HOST_0_1"); + assertThat(namesFromConfiguration("host[0].name")).toIterable() + .containsExactly("HOST_0_NAME"); + assertThat(namesFromConfiguration("host.f00.name")).toIterable() .containsExactly("HOST_F00_NAME"); - assertThat(namesFromConfiguration("foo.the-bar")).containsExactly("FOO_THEBAR", - "FOO_THE_BAR"); + assertThat(namesFromConfiguration("foo.the-bar")).toIterable() + .containsExactly("FOO_THEBAR", "FOO_THE_BAR"); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletContextInitializerBeansTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletContextInitializerBeansTests.java index fd316220e00..caddc789a28 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletContextInitializerBeansTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletContextInitializerBeansTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 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. @@ -48,7 +48,8 @@ public class ServletContextInitializerBeansTests { ServletContextInitializerBeans initializerBeans = new ServletContextInitializerBeans( this.context.getBeanFactory()); assertThat(initializerBeans.size()).isEqualTo(1); - assertThat(initializerBeans.iterator()).hasOnlyElementsOfType(TestServlet.class); + assertThat(initializerBeans.iterator()).toIterable() + .hasOnlyElementsOfType(TestServlet.class); } @Test @@ -57,7 +58,8 @@ public class ServletContextInitializerBeansTests { ServletContextInitializerBeans initializerBeans = new ServletContextInitializerBeans( this.context.getBeanFactory()); assertThat(initializerBeans.size()).isEqualTo(1); - assertThat(initializerBeans.iterator()).hasOnlyElementsOfType(TestFilter.class); + assertThat(initializerBeans.iterator()).toIterable() + .hasOnlyElementsOfType(TestFilter.class); } @Test @@ -66,7 +68,7 @@ public class ServletContextInitializerBeansTests { ServletContextInitializerBeans initializerBeans = new ServletContextInitializerBeans( this.context.getBeanFactory(), TestServletContextInitializer.class); assertThat(initializerBeans.size()).isEqualTo(1); - assertThat(initializerBeans.iterator()) + assertThat(initializerBeans.iterator()).toIterable() .hasOnlyElementsOfType(TestServletContextInitializer.class); }