http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java index 4ee8ada..9c69750 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java @@ -25,7 +25,7 @@ import org.apache.tamaya.TypeLiteral; import org.apache.tamaya.spi.ConversionContext; import org.junit.Test; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; /** * Tests the default converter for Shorts. @@ -41,8 +41,8 @@ public class ShortConverterTest { public void testConvert_Short_Decimal() throws Exception { Configuration config = ConfigurationProvider.getConfiguration(); Short valueRead = config.get("tests.converter.short.decimal", Short.class); - assertTrue(valueRead != null); - assertEquals(valueRead.intValue(), 101); + assertThat(valueRead != null).isTrue(); + assertThat(101).isEqualTo(valueRead.intValue()); } /** @@ -54,8 +54,8 @@ public class ShortConverterTest { public void testConvert_Short_Octal() throws Exception { Configuration config = ConfigurationProvider.getConfiguration(); Short valueRead = config.get("tests.converter.short.octal", Short.class); - assertTrue(valueRead != null); - assertEquals(valueRead.intValue(), Short.decode("02").intValue()); + assertThat(valueRead != null).isTrue(); + assertThat(Short.decode("02").intValue()).isEqualTo(valueRead.intValue()); } /** @@ -67,11 +67,11 @@ public class ShortConverterTest { public void testConvert_Short_Hex() throws Exception { Configuration config = ConfigurationProvider.getConfiguration(); Short valueRead = config.get("tests.converter.short.hex.lowerX", Short.class); - assertTrue(valueRead != null); - assertEquals(valueRead.intValue(), Short.decode("0x2F").intValue()); + assertThat(valueRead != null).isTrue(); + assertThat(Short.decode("0x2F").intValue()).isEqualTo(valueRead.intValue()); valueRead = config.get("tests.converter.short.hex.upperX", Short.class); - assertTrue(valueRead != null); - assertEquals(valueRead.intValue(), Short.decode("0X3F").intValue()); + assertThat(valueRead != null).isTrue(); + assertThat(Short.decode("0X3F").intValue()).isEqualTo(valueRead.intValue()); } /** @@ -83,7 +83,7 @@ public class ShortConverterTest { public void testConvert_NotPresent() throws Exception { Configuration config = ConfigurationProvider.getConfiguration(); Short valueRead = config.get("tests.converter.short.foo", Short.class); - assertFalse(valueRead != null); + assertThat(valueRead != null).isFalse(); } /** @@ -95,8 +95,8 @@ public class ShortConverterTest { public void testConvert_Short_MinValue() throws Exception { Configuration config = ConfigurationProvider.getConfiguration(); Short valueRead = config.get("tests.converter.short.min", Short.class); - assertTrue(valueRead != null); - assertEquals(Short.MIN_VALUE, valueRead.intValue()); + assertThat(valueRead != null).isTrue(); + assertThat(valueRead.intValue()).isEqualTo(Short.MIN_VALUE); } /** @@ -108,8 +108,8 @@ public class ShortConverterTest { public void testConvert_Short_MaxValue() throws Exception { Configuration config = ConfigurationProvider.getConfiguration(); Short valueRead = config.get("tests.converter.short.max", Short.class); - assertTrue(valueRead != null); - assertEquals(Short.MAX_VALUE, valueRead.intValue()); + assertThat(valueRead != null).isTrue(); + assertThat(valueRead.intValue()).isEqualTo(Short.MAX_VALUE); } @@ -125,14 +125,14 @@ public class ShortConverterTest { ShortConverter converter = new ShortConverter(); converter.convert("", context); - assertTrue(context.getSupportedFormats().contains("short (ShortConverter)")); - assertTrue(context.getSupportedFormats().contains("MIN_VALUE (ShortConverter)")); - assertTrue(context.getSupportedFormats().contains("MAX_VALUE (ShortConverter)")); + assertThat(context.getSupportedFormats().contains("short (ShortConverter)")).isTrue(); + assertThat(context.getSupportedFormats().contains("MIN_VALUE (ShortConverter)")).isTrue(); + assertThat(context.getSupportedFormats().contains("MAX_VALUE (ShortConverter)")).isTrue(); } @Test public void testHashCode() { ShortConverter instance = new ShortConverter(); - assertEquals(ShortConverter.class.hashCode(), instance.hashCode()); + assertThat(instance.hashCode()).isEqualTo(ShortConverter.class.hashCode()); } } \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/core/src/test/java/org/apache/tamaya/core/internal/converters/SupplierConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/SupplierConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/SupplierConverterTest.java index b14a506..5660c1d 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/SupplierConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/SupplierConverterTest.java @@ -26,7 +26,7 @@ import org.apache.tamaya.TypeLiteral; import org.apache.tamaya.spi.ConversionContext; import org.apache.tamaya.spi.PropertyConverter; import org.junit.Test; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; import static org.mockito.Matchers.any; import org.mockito.Mockito; @@ -47,10 +47,10 @@ public class SupplierConverterTest { ConversionContext stringContext = new ConversionContext.Builder(listStringTypeLiteral).build(); stringResult = instance.convert(null, stringContext); - assertNull(stringResult.get()); + assertThat(stringResult.get()).isNull(); stringResult = instance.convert("aString", stringContext); - assertEquals("aString", stringResult.get()); + assertThat(stringResult.get()).isEqualTo("aString"); Supplier<InetAddress> addressResult; @@ -63,14 +63,14 @@ public class SupplierConverterTest { .build(); addressResult = instance.convert("someKey", myConverterContext); - assertTrue(addressResult.get() instanceof InetAddress); + assertThat(addressResult.get() instanceof InetAddress).isTrue(); } @Test public void testHashCode(){ SupplierConverter instance = new SupplierConverter(); - assertEquals(SupplierConverter.class.hashCode(), instance.hashCode()); + assertThat(instance.hashCode()).isEqualTo(SupplierConverter.class.hashCode()); } private class MyConverter<T extends InetAddress> implements PropertyConverter<InetAddress> { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URIConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URIConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URIConverterTest.java index 373b979..ac727cf 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URIConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URIConverterTest.java @@ -25,11 +25,7 @@ import org.junit.Test; import java.net.URI; import org.apache.tamaya.ConfigException; -import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; /** * Tests conversion of the {@link URI}-converter. @@ -42,38 +38,38 @@ public class URIConverterTest { @Test public void testConvert_URI() throws Exception { URIConverter converter = new URIConverter(); - assertEquals(new URI("test:path"), converter.convert("test:path", context)); + assertThat(new URI("test:path")).isEqualTo(converter.convert("test:path", context)); } @Test public void testConvert_URI_WithSpaces() throws Exception { URIConverter converter = new URIConverter(); - assertEquals(new URI("test:path"), converter.convert(" test:path\t", context)); + assertThat(new URI("test:path")).isEqualTo(converter.convert(" test:path\t", context)); } @Test public void testConvert_URI_WithSpacesBefore() throws Exception { URIConverter converter = new URIConverter(); - assertEquals(new URI("test:path"), converter.convert(" test:path", context)); + assertThat(new URI("test:path")).isEqualTo(converter.convert(" test:path", context)); } @Test public void testConvert_URI_WithSpacesAfter() throws Exception { URIConverter converter = new URIConverter(); - assertEquals(new URI("test:path"), converter.convert("test:path ", context)); + assertThat(new URI("test:path")).isEqualTo(converter.convert("test:path ", context)); } @Test public void testConvert_NotPresent() throws Exception { URIConverter converter = new URIConverter(); - assertNull(converter.convert("", context)); - assertNull(converter.convert(null, context)); + assertThat(converter.convert("", context)).isNull(); + assertThat(converter.convert(null, context)).isNull(); } @Test public void testConvert_URIInvalid() throws ConfigException { URIConverter converter = new URIConverter(); - assertNull(converter.convert("not a uri", context)); + assertThat(converter.convert("not a uri", context)).isNull(); } @Test @@ -82,13 +78,13 @@ public class URIConverterTest { URIConverter converter = new URIConverter(); converter.convert("test:path", localcontext); - assertTrue(localcontext.getSupportedFormats().contains("<uri> -> new URI(uri) (URIConverter)")); + assertThat(localcontext.getSupportedFormats().contains("<uri> -> new URI(uri) (URIConverter)")).isTrue(); } @Test public void testHashCode() { URIConverter instance = new URIConverter(); - assertEquals(URIConverter.class.hashCode(), instance.hashCode()); + assertThat(instance.hashCode()).isEqualTo(URIConverter.class.hashCode()); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URLConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URLConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URLConverterTest.java index 80e5bc9..b4dbb1e 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URLConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URLConverterTest.java @@ -26,11 +26,7 @@ import java.net.URI; import java.net.URL; import org.apache.tamaya.ConfigException; -import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; /** * Tests conversion of the {@link URL}-converter. @@ -43,38 +39,38 @@ public class URLConverterTest { @Test public void testConvert_URL() throws Exception { URLConverter converter = new URLConverter(); - assertEquals(new URL("http://google.com:4000/path"), converter.convert("http://google.com:4000/path", context)); + assertThat(new URL("http://apache.org:4000/path")).isEqualTo(converter.convert("http://apache.org:4000/path", context)); } @Test public void testConvert_URL_WithSpaces() throws Exception { URLConverter converter = new URLConverter(); - assertEquals(new URL("http://google.com:4000/path"), converter.convert(" http://google.com:4000/path\t", context)); + assertThat(new URL("http://apache.org:4000/path")).isEqualTo(converter.convert(" http://apache.org:4000/path\t", context)); } @Test public void testConvert_URL_WithSpacesBefore() throws Exception { URLConverter converter = new URLConverter(); - assertEquals(new URL("http://google.com:4000/path"), converter.convert(" http://google.com:4000/path", context)); + assertThat(new URL("http://apache.org:4000/path")).isEqualTo(converter.convert(" http://apache.org:4000/path", context)); } @Test public void testConvert_URL_WithSpacesAfter() throws Exception { URLConverter converter = new URLConverter(); - assertEquals(new URL("http://google.com:4000/path"), converter.convert("http://google.com:4000/path ", context)); + assertThat(new URL("http://apache.org:4000/path")).isEqualTo(converter.convert("http://apache.org:4000/path ", context)); } @Test public void testConvert_NotPresent() throws Exception { URLConverter converter = new URLConverter(); - assertNull(converter.convert("", context)); - assertNull(converter.convert(null, context)); + assertThat(converter.convert("", context)).isNull(); + assertThat(converter.convert(null, context)).isNull(); } @Test public void testConvert_URLInvalid() throws ConfigException { URLConverter converter = new URLConverter(); - assertNull(converter.convert("not a url", context)); + assertThat(converter.convert("not a url", context)).isNull(); } @Test @@ -83,12 +79,12 @@ public class URLConverterTest { URLConverter converter = new URLConverter(); converter.convert("http://localhost", localcontext); - assertTrue(localcontext.getSupportedFormats().contains("<URL> (URLConverter)")); + assertThat(localcontext.getSupportedFormats().contains("<URL> (URLConverter)")).isTrue(); } @Test public void testHashCode() { URLConverter instance = new URLConverter(); - assertEquals(URLConverter.class.hashCode(), instance.hashCode()); + assertThat(instance.hashCode()).isEqualTo(URLConverter.class.hashCode()); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/spi-support/pom.xml ---------------------------------------------------------------------- diff --git a/code/spi-support/pom.xml b/code/spi-support/pom.xml index 6c4f94d..9172575 100644 --- a/code/spi-support/pom.xml +++ b/code/spi-support/pom.xml @@ -50,10 +50,6 @@ under the License. <artifactId>junit</artifactId> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>java-hamcrest</artifactId> - </dependency> - <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceProviderTest.java ---------------------------------------------------------------------- diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceProviderTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceProviderTest.java index 7f3cd7a..e3d8900 100644 --- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceProviderTest.java +++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceProviderTest.java @@ -24,7 +24,7 @@ import org.apache.tamaya.spisupport.propertysource.BuildablePropertySource; import org.apache.tamaya.spisupport.propertysource.BuildablePropertySourceProvider; import org.junit.Test; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; public class BuildablePropertySourceProviderTest { @@ -38,10 +38,10 @@ public class BuildablePropertySourceProviderTest { .withPropertySourcs(ps1) .withPropertySourcs(Arrays.asList(ps2)) .build(); - assertNotNull(prov); + assertThat(prov).isNotNull(); Iterator testable = prov.getPropertySources().iterator(); - assertEquals(testable.next(), ps1); - assertEquals(testable.next(), ps2); + assertThat(ps1).isEqualTo(testable.next()); + assertThat(ps2).isEqualTo(testable.next()); } @Test @@ -57,11 +57,11 @@ public class BuildablePropertySourceProviderTest { BuildablePropertySourceProvider prov3 = BuildablePropertySourceProvider.builder() .withPropertySourcs(ps2).build(); - assertEquals(prov1, prov1); - assertEquals(prov1, prov2); - assertNotEquals(prov1, prov3); - assertNotEquals(prov1, null); - assertNotEquals(prov1, "aString"); + assertThat(prov1).isEqualTo(prov1); + assertThat(prov2).isEqualTo(prov1); + assertThat(prov1).isNotEqualTo(prov3); + assertThat(prov1).isNotEqualTo(null); + assertThat(prov1).isNotEqualTo("aString"); } @Test @@ -72,19 +72,19 @@ public class BuildablePropertySourceProviderTest { .withPropertySourcs(ps).build(); BuildablePropertySourceProvider prov2 = BuildablePropertySourceProvider.builder() .withPropertySourcs(ps).build(); - assertEquals(prov1.hashCode(), prov2.hashCode()); + assertThat(prov2.hashCode()).isEqualTo(prov1.hashCode()); BuildablePropertySource ps2 = BuildablePropertySource.builder() .withName("test12").build(); prov2 = BuildablePropertySourceProvider.builder() .withPropertySourcs(ps2).build(); - assertNotEquals(prov1.hashCode(), prov2.hashCode()); + assertThat(prov1.hashCode()).isNotEqualTo(prov2.hashCode()); } @Test public void builder() throws Exception { - assertNotNull(BuildablePropertySource.builder()); - assertNotEquals(BuildablePropertySource.builder(), BuildablePropertySource.builder()); + assertThat(BuildablePropertySource.builder()).isNotNull(); + assertThat(BuildablePropertySource.builder()).isNotEqualTo(BuildablePropertySource.builder()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceTest.java ---------------------------------------------------------------------- diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceTest.java index 2983f5c..773c8ca 100644 --- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceTest.java +++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceTest.java @@ -24,45 +24,45 @@ import org.apache.tamaya.spi.PropertyValue; import org.apache.tamaya.spisupport.propertysource.BuildablePropertySource; import org.junit.Test; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; public class BuildablePropertySourceTest { @Test public void getOrdinal() throws Exception { BuildablePropertySource ps1 = BuildablePropertySource.builder() .withOrdinal(55).build(); - assertEquals(55, ps1.getOrdinal()); + assertThat(ps1.getOrdinal()).isEqualTo(55); } @Test public void getName() throws Exception { BuildablePropertySource ps1 = BuildablePropertySource.builder() .withName("test1").build(); - assertEquals("test1", ps1.getName()); + assertThat(ps1.getName()).isEqualTo("test1"); ps1 = BuildablePropertySource.builder().build(); - assertNotNull(ps1.getName()); + assertThat(ps1.getName()).isNotNull(); } @Test public void get() throws Exception { BuildablePropertySource ps1 = BuildablePropertySource.builder() .withSimpleProperty("a", "b").build(); - assertEquals("b", ps1.get("a").getValue()); + assertThat(ps1.get("a").getValue()).isEqualTo("b"); } @Test public void getProperties() throws Exception { BuildablePropertySource ps1 = BuildablePropertySource.builder() .withSimpleProperty("a", "b").build(); - assertNotNull(ps1.getProperties()); - assertEquals(1, ps1.getProperties().size()); - assertEquals("b", ps1.getProperties().get("a").getValue()); + assertThat(ps1.getProperties()).isNotNull(); + assertThat(ps1.getProperties()).hasSize(1); + assertThat(ps1.getProperties().get("a").getValue()).isEqualTo("b"); } @Test public void testScannable() { BuildablePropertySource bps = BuildablePropertySource.builder().build(); - assertTrue(bps.isScannable()); + assertThat(bps.isScannable()).isTrue(); } @Test @@ -73,8 +73,8 @@ public class BuildablePropertySourceTest { .withSimpleProperty("namedSourceKey", "namedSourceValue", "namedSource") .build(); - assertEquals("fakeSource", bps.get("defaultSourceKey").getSource()); - assertEquals("namedSource", bps.get("namedSourceKey").getSource()); + assertThat(bps.get("defaultSourceKey").getSource()).isEqualTo("fakeSource"); + assertThat(bps.get("namedSourceKey").getSource()).isEqualTo("namedSource"); } @Test @@ -94,11 +94,11 @@ public class BuildablePropertySourceTest { .withProperties(propertyThird) .build(); - assertNull(bps.get("firstKey")); - assertNull(bps.get("secondKey")); - assertEquals("thirdValue", bps.get("thirdKey").getValue()); - assertEquals("thirdSource", bps.get("thirdKey").getSource()); - assertNull(bps.get("thirdPVKey")); + assertThat(bps.get("firstKey")).isNull(); + assertThat(bps.get("secondKey")).isNull(); + assertThat(bps.get("thirdKey").getValue()).isEqualTo("thirdValue"); + assertThat(bps.get("thirdKey").getSource()).isEqualTo("thirdSource"); + assertThat(bps.get("thirdPVKey")).isNull(); bps = BuildablePropertySource.builder() .withProperties(propertyThird) @@ -106,12 +106,12 @@ public class BuildablePropertySourceTest { .withProperties(propertySecond, "secondSource") .build(); - assertEquals("firstValue", bps.get("firstKey").getValue()); - assertEquals("secondSource", bps.get("secondKey").getSource()); - assertEquals("secondValue", bps.get("secondKey").getValue()); - assertEquals("thirdValue", bps.get("thirdKey").getValue()); - assertEquals("thirdSource", bps.get("thirdKey").getSource()); - assertNull(bps.get("thirdPVKey")); + assertThat(bps.get("firstKey").getValue()).isEqualTo("firstValue"); + assertThat(bps.get("secondKey").getSource()).isEqualTo("secondSource"); + assertThat(bps.get("secondKey").getValue()).isEqualTo("secondValue"); + assertThat(bps.get("thirdKey").getValue()).isEqualTo("thirdValue"); + assertThat(bps.get("thirdKey").getSource()).isEqualTo("thirdSource"); + assertThat(bps.get("thirdPVKey")).isNull(); } @Test @@ -120,12 +120,12 @@ public class BuildablePropertySourceTest { .withName("test1").build(); BuildablePropertySource ps2 = BuildablePropertySource.builder() .withName("test1").build(); - assertEquals(ps1, ps2); + assertThat(ps2).isEqualTo(ps1); ps2 = BuildablePropertySource.builder() .withName("test2").build(); - assertNotEquals(ps1, ps2); - assertNotEquals(ps2, null); - assertNotEquals(ps1, "aString"); + assertThat(ps1).isNotEqualTo(ps2); + assertThat(ps2).isNotEqualTo(null); + assertThat(ps1).isNotEqualTo("aString"); } @Test @@ -134,17 +134,17 @@ public class BuildablePropertySourceTest { .withName("test1").build(); BuildablePropertySource ps2 = BuildablePropertySource.builder() .withName("test1").build(); - assertEquals(ps1.hashCode(), ps2.hashCode()); + assertThat(ps2.hashCode()).isEqualTo(ps1.hashCode()); ps2 = BuildablePropertySource.builder() .withName("test2").build(); - assertNotEquals(ps1.hashCode(), ps2.hashCode()); + assertThat(ps1.hashCode()).isNotEqualTo(ps2.hashCode()); } @Test public void builder() throws Exception { - assertNotNull(BuildablePropertySource.builder()); - assertNotNull(BuildablePropertySource.builder().but()); - assertNotEquals(BuildablePropertySource.builder(), BuildablePropertySource.builder()); + assertThat(BuildablePropertySource.builder()).isNotNull(); + assertThat(BuildablePropertySource.builder().but()).isNotNull(); + assertThat(BuildablePropertySource.builder()).isNotEqualTo(BuildablePropertySource.builder()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluatorTest.java ---------------------------------------------------------------------- diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluatorTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluatorTest.java index e77b99f..d14815a 100644 --- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluatorTest.java +++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluatorTest.java @@ -23,7 +23,7 @@ import org.apache.tamaya.Configuration; import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.spi.PropertyValue; import org.junit.Test; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; /** * @@ -40,9 +40,9 @@ public class DefaultConfigValueEvaluatorTest { Configuration config = ConfigurationProvider.getConfiguration(); DefaultConfigValueEvaluator instance = new DefaultConfigValueEvaluator(); PropertyValue result = instance.evaluteRawValue("confkey1", config.getContext()); - assertEquals("javaconf-value1", result.getValue()); + assertThat(result.getValue()).isEqualTo("javaconf-value1"); result = instance.evaluteRawValue("missing", config.getContext()); - assertNull(result); + assertThat(result).isNull(); } /** @@ -53,8 +53,8 @@ public class DefaultConfigValueEvaluatorTest { Configuration config = ConfigurationProvider.getConfiguration(); DefaultConfigValueEvaluator instance = new DefaultConfigValueEvaluator(); Map<String, PropertyValue> result = instance.evaluateRawValues(config.getContext()); - assertTrue(result.containsKey("confkey1")); - assertEquals("javaconf-value1", result.get("confkey1").getValue()); + assertThat(result.containsKey("confkey1")).isTrue(); + assertThat(result.get("confkey1").getValue()).isEqualTo("javaconf-value1"); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java ---------------------------------------------------------------------- diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java index a7f4088..9584037 100644 --- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java +++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java @@ -31,7 +31,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.Map; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; /** * Tests for {@link DefaultConfigurationBuilder} by atsticks on 06.09.16. @@ -46,7 +46,7 @@ public class DefaultConfigurationBuilderTest { ConfigurationContext context = ConfigurationProvider.getConfiguration().getContext(); ConfigurationBuilder b = new DefaultConfigurationBuilder() .setContext(context); - assertEquals(context, b.build().getContext()); + assertThat(b.build().getContext()).isEqualTo(context); } @Test @@ -54,7 +54,7 @@ public class DefaultConfigurationBuilderTest { Configuration cfg = ConfigurationProvider.getConfiguration(); ConfigurationBuilder b = new DefaultConfigurationBuilder() .setConfiguration(cfg); - assertEquals(cfg, b.build()); + assertThat(b.build()).isEqualTo(cfg); } @Test @@ -64,17 +64,17 @@ public class DefaultConfigurationBuilderTest { .addPropertySources(testPropertySource, testPS2); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); - assertEquals(2, ctx.getPropertySources().size()); - assertTrue(ctx.getPropertySources().contains(testPropertySource)); - assertTrue(ctx.getPropertySources().contains(testPS2)); + assertThat(ctx.getPropertySources()).hasSize(2); + assertThat(ctx.getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(ctx.getPropertySources().contains(testPS2)).isTrue(); b = new DefaultConfigurationBuilder() .addPropertySources(testPropertySource, testPS2); cfg = b.removePropertySources(testPropertySource).build(); ctx = cfg.getContext(); - assertEquals(1, ctx.getPropertySources().size()); - assertFalse(ctx.getPropertySources().contains(testPropertySource)); - assertTrue(ctx.getPropertySources().contains(testPS2)); + assertThat(ctx.getPropertySources()).hasSize(1); + assertThat(ctx.getPropertySources().contains(testPropertySource)).isFalse(); + assertThat(ctx.getPropertySources().contains(testPS2)).isTrue(); } @Test @@ -84,17 +84,17 @@ public class DefaultConfigurationBuilderTest { .addPropertySources(Arrays.asList(testPropertySource, testPS2)); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); - assertEquals(2, ctx.getPropertySources().size()); - assertTrue(ctx.getPropertySources().contains(testPropertySource)); - assertTrue(ctx.getPropertySources().contains(testPS2)); + assertThat(ctx.getPropertySources()).hasSize(2); + assertThat(ctx.getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(ctx.getPropertySources().contains(testPS2)).isTrue(); b = new DefaultConfigurationBuilder() .addPropertySources(testPropertySource, testPS2); cfg = b.removePropertySources(Arrays.asList(testPropertySource)).build(); ctx = cfg.getContext(); - assertEquals(1, ctx.getPropertySources().size()); - assertFalse(ctx.getPropertySources().contains(testPropertySource)); - assertTrue(ctx.getPropertySources().contains(testPS2)); + assertThat(ctx.getPropertySources()).hasSize(1); + assertThat(ctx.getPropertySources().contains(testPropertySource)).isFalse(); + assertThat(ctx.getPropertySources().contains(testPS2)).isTrue(); } @Test @@ -104,23 +104,23 @@ public class DefaultConfigurationBuilderTest { DefaultConfigurationBuilder b = new DefaultConfigurationBuilder(); Configuration cfg = b.addPropertyFilters(filter1, filter2).build(); ConfigurationContext ctx = cfg.getContext(); - assertTrue(ctx.getPropertyFilters().contains(filter1)); - assertTrue(ctx.getPropertyFilters().contains(filter2)); - assertEquals(2, ctx.getPropertyFilters().size()); + assertThat(ctx.getPropertyFilters().contains(filter1)).isTrue(); + assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); + assertThat(ctx.getPropertyFilters()).hasSize(2); b = new DefaultConfigurationBuilder(); b.addPropertyFilters(filter1, filter2); cfg = b.addPropertyFilters(filter1, filter2).build(); ctx = cfg.getContext(); - assertEquals(2, ctx.getPropertyFilters().size()); + assertThat(ctx.getPropertyFilters()).hasSize(2); b = new DefaultConfigurationBuilder(); b.addPropertyFilters(filter1, filter2); cfg = b.removePropertyFilters(filter1).build(); ctx = cfg.getContext(); - assertEquals(1, ctx.getPropertyFilters().size()); - assertFalse(ctx.getPropertyFilters().contains(filter1)); - assertTrue(ctx.getPropertyFilters().contains(filter2)); + assertThat(ctx.getPropertyFilters()).hasSize(1); + assertThat(ctx.getPropertyFilters().contains(filter1)).isFalse(); + assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); } @@ -131,23 +131,23 @@ public class DefaultConfigurationBuilderTest { DefaultConfigurationBuilder b = new DefaultConfigurationBuilder(); Configuration cfg = b.addPropertyFilters(Arrays.asList(filter1, filter2)).build(); ConfigurationContext ctx = cfg.getContext(); - assertTrue(ctx.getPropertyFilters().contains(filter1)); - assertTrue(ctx.getPropertyFilters().contains(filter2)); - assertEquals(2, ctx.getPropertyFilters().size()); + assertThat(ctx.getPropertyFilters().contains(filter1)).isTrue(); + assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); + assertThat(ctx.getPropertyFilters()).hasSize(2); b = new DefaultConfigurationBuilder(); b.addPropertyFilters(Arrays.asList(filter1, filter2, filter1)); cfg = b.addPropertyFilters(Arrays.asList(filter1, filter2)).build(); ctx = cfg.getContext(); - assertEquals(2, ctx.getPropertyFilters().size()); + assertThat(ctx.getPropertyFilters()).hasSize(2); b = new DefaultConfigurationBuilder(); b.addPropertyFilters(Arrays.asList(filter1, filter2)); cfg = b.removePropertyFilters(Arrays.asList(filter1)).build(); ctx = cfg.getContext(); - assertEquals(1, ctx.getPropertyFilters().size()); - assertFalse(ctx.getPropertyFilters().contains(filter1)); - assertTrue(ctx.getPropertyFilters().contains(filter2)); + assertThat(ctx.getPropertyFilters()).hasSize(1); + assertThat(ctx.getPropertyFilters().contains(filter1)).isFalse(); + assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); } @@ -161,21 +161,21 @@ public class DefaultConfigurationBuilderTest { b.addPropertySources(propertySources); b.increasePriority(propertySources[propertySources.length - 1]); for (int i = 0; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } b.increasePriority(propertySources[propertySources.length - 2]).build(); for (int i = 0; i < propertySources.length - 2; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } - assertEquals(propertySources[propertySources.length - 1], b.getPropertySources().get(propertySources.length - 2)); - assertEquals(propertySources[propertySources.length - 2], b.getPropertySources().get(propertySources.length - 1)); + assertThat(b.getPropertySources().get(propertySources.length - 2)).isEqualTo(propertySources[propertySources.length - 1]); + assertThat(b.getPropertySources().get(propertySources.length - 1)).isEqualTo(propertySources[propertySources.length - 2]); boolean caughtAlreadyBuilt = false; try { b.increasePriority(propertySources[propertySources.length - 2]); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); } @Test @@ -188,21 +188,21 @@ public class DefaultConfigurationBuilderTest { b.addPropertySources(propertySources); b.decreasePriority(propertySources[0]); for (int i = 0; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } b.decreasePriority(propertySources[1]).build(); for (int i = 2; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } - assertEquals(propertySources[0], b.getPropertySources().get(1)); - assertEquals(propertySources[1], b.getPropertySources().get(0)); + assertThat(b.getPropertySources().get(1)).isEqualTo(propertySources[0]); + assertThat(b.getPropertySources().get(0)).isEqualTo(propertySources[1]); boolean caughtAlreadyBuilt = false; try { b.decreasePriority(propertySources[1]); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); } @Test @@ -217,23 +217,23 @@ public class DefaultConfigurationBuilderTest { // test b.lowestPriority(propertySources[0]); for (int i = 0; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } b.lowestPriority(propertySources[1]); for (int i = 2; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } - assertEquals(propertySources[0], b.getPropertySources().get(1)); - assertEquals(propertySources[1], b.getPropertySources().get(0)); + assertThat(b.getPropertySources().get(1)).isEqualTo(propertySources[0]); + assertThat(b.getPropertySources().get(0)).isEqualTo(propertySources[1]); b.lowestPriority(propertySources[5]).build(); - assertEquals(propertySources[5], b.getPropertySources().get(0)); + assertThat(b.getPropertySources().get(0)).isEqualTo(propertySources[5]); boolean caughtAlreadyBuilt = false; try { b.lowestPriority(propertySources[5]); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); } @Test @@ -248,23 +248,23 @@ public class DefaultConfigurationBuilderTest { // test b.highestPriority(propertySources[propertySources.length - 1]); for (int i = 0; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } b.highestPriority(propertySources[propertySources.length - 2]); for (int i = 0; i < propertySources.length - 2; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } - assertEquals(propertySources[propertySources.length - 2], b.getPropertySources().get(propertySources.length - 1)); - assertEquals(propertySources[propertySources.length - 1], b.getPropertySources().get(propertySources.length - 2)); + assertThat(b.getPropertySources().get(propertySources.length - 1)).isEqualTo(propertySources[propertySources.length - 2]); + assertThat(b.getPropertySources().get(propertySources.length - 2)).isEqualTo(propertySources[propertySources.length - 1]); b.highestPriority(propertySources[5]).build(); - assertEquals(propertySources[5], b.getPropertySources().get(propertySources.length - 1)); + assertThat(b.getPropertySources().get(propertySources.length - 1)).isEqualTo(propertySources[5]); boolean caughtAlreadyBuilt = false; try { b.highestPriority(propertySources[5]); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); } @Test @@ -278,10 +278,10 @@ public class DefaultConfigurationBuilderTest { b.addPropertySources(propertySources); Comparator<PropertySource> psComp = (o1, o2) -> o1.toString().compareTo(o2.toString()); // test - assertEquals(DefaultConfigurationBuilder.class, b.sortPropertySources(psComp).getClass()); + assertThat(b.sortPropertySources(psComp).getClass()).isEqualTo(DefaultConfigurationBuilder.class); Arrays.sort(propertySources, psComp); for (int i = 0; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } } @@ -297,10 +297,10 @@ public class DefaultConfigurationBuilderTest { b.addPropertyFilters(propertyFilters); Comparator<PropertyFilter> pfComp = (o1, o2) -> o1.toString().compareTo(o2.toString()); //test - assertEquals(DefaultConfigurationBuilder.class, b.sortPropertyFilter(pfComp).getClass()); + assertThat(b.sortPropertyFilter(pfComp).getClass()).isEqualTo(DefaultConfigurationBuilder.class); Arrays.sort(propertyFilters, pfComp); for (int i = 0; i < propertyFilters.length; i++) { - assertEquals(propertyFilters[i], b.getPropertyFilters().get(i)); + assertThat(b.getPropertyFilters().get(i)).isEqualTo(propertyFilters[i]); } } @@ -313,29 +313,29 @@ public class DefaultConfigurationBuilderTest { Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> buildConverters = b.getPropertyConverter(); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter1)); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter2)); - assertEquals(1, ctx.getPropertyConverters().size()); - assertEquals(2, ctx.getPropertyConverters(TypeLiteral.of(String.class)).size()); - assertTrue(buildConverters.get(TypeLiteral.of(String.class)).containsAll( - ctx.getPropertyConverters().get(TypeLiteral.of(String.class)))); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter1)).isTrue(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter2)).isTrue(); + assertThat(ctx.getPropertyConverters()).hasSize(1); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class))).hasSize(2); + assertThat(buildConverters.get(TypeLiteral.of(String.class)).containsAll( + ctx.getPropertyConverters().get(TypeLiteral.of(String.class)))).isTrue(); b = new DefaultConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), converter1); cfg = b.addPropertyConverters(TypeLiteral.of(String.class), converter1).build(); ctx = cfg.getContext(); - assertEquals(1, ctx.getPropertyConverters(TypeLiteral.of(String.class)).size()); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class))).hasSize(1); b = new DefaultConfigurationBuilder().addPropertyConverters(TypeLiteral.of(String.class), converter1, converter2); cfg = b.removePropertyConverters(TypeLiteral.of(String.class), converter1).build(); ctx = cfg.getContext(); - assertFalse(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter1)); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter2)); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter1)).isFalse(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter2)).isTrue(); b = new DefaultConfigurationBuilder().addPropertyConverters(TypeLiteral.of(String.class), converter1, converter2); cfg = b.removePropertyConverters(TypeLiteral.of(String.class)).build(); ctx = cfg.getContext(); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).isEmpty()); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).isEmpty()).isTrue(); } @Test @@ -347,29 +347,29 @@ public class DefaultConfigurationBuilderTest { Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> buildConverters = b.getPropertyConverter(); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter1)); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter2)); - assertEquals(1, ctx.getPropertyConverters().size()); - assertEquals(2, ctx.getPropertyConverters(TypeLiteral.of(String.class)).size()); - assertTrue(buildConverters.get(TypeLiteral.of(String.class)).containsAll( - ctx.getPropertyConverters().get(TypeLiteral.of(String.class)))); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter1)).isTrue(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter2)).isTrue(); + assertThat(ctx.getPropertyConverters()).hasSize(1); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class))).hasSize(2); + assertThat(buildConverters.get(TypeLiteral.of(String.class)).containsAll( + ctx.getPropertyConverters().get(TypeLiteral.of(String.class)))).isTrue(); b = new DefaultConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), Arrays.asList(converter1)); cfg = b.addPropertyConverters(TypeLiteral.of(String.class), Arrays.asList(converter1)).build(); ctx = cfg.getContext(); - assertEquals(1, ctx.getPropertyConverters(TypeLiteral.of(String.class)).size()); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class))).hasSize(1); b = new DefaultConfigurationBuilder().addPropertyConverters(TypeLiteral.of(String.class), Arrays.asList(converter1, converter2)); cfg = b.removePropertyConverters(TypeLiteral.of(String.class), Arrays.asList(converter1)).build(); ctx = cfg.getContext(); - assertFalse(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter1)); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter2)); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter1)).isFalse(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter2)).isTrue(); b = new DefaultConfigurationBuilder().addPropertyConverters(TypeLiteral.of(String.class), Arrays.asList(converter1, converter2)); cfg = b.removePropertyConverters(TypeLiteral.of(String.class)).build(); ctx = cfg.getContext(); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).isEmpty()); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).isEmpty()).isTrue(); } @Test @@ -379,12 +379,12 @@ public class DefaultConfigurationBuilderTest { .setPropertyValueCombinationPolicy(combPol); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); - assertEquals(ctx.getPropertyValueCombinationPolicy(), combPol); + assertThat(combPol).isEqualTo(ctx.getPropertyValueCombinationPolicy()); } @Test public void build() throws Exception { - assertNotNull(new DefaultConfigurationBuilder().build()); + assertThat(new DefaultConfigurationBuilder().build()).isNotNull(); } @Test http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilderTest.java ---------------------------------------------------------------------- diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilderTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilderTest.java index b783877..326484f 100644 --- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilderTest.java +++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilderTest.java @@ -24,7 +24,7 @@ import org.apache.tamaya.spi.PropertyConverter; import org.apache.tamaya.spi.PropertyFilter; import org.apache.tamaya.spi.PropertySource; import org.apache.tamaya.spi.PropertyValueCombinationPolicy; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.TypeLiteral; @@ -54,16 +54,16 @@ public class DefaultConfigurationContextBuilderTest { ConfigurationContext context = ConfigurationProvider.getConfiguration().getContext(); ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder() .setContext(context); - assertEquals(context, b.build()); + assertThat(b.build()).isEqualTo(context); boolean caughtAlreadyBuilt = false; try { b.setContext(context); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); b = new DefaultConfigurationContextBuilder(context); - assertEquals(context, b.build()); + assertThat(b.build()).isEqualTo(context); } @Test @@ -72,22 +72,22 @@ public class DefaultConfigurationContextBuilderTest { ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder() .addPropertySources(testPropertySource, testPS2); ConfigurationContext ctx = b.build(); - assertEquals(2, ctx.getPropertySources().size()); - assertTrue(ctx.getPropertySources().contains(testPropertySource)); - assertNotNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())); - assertTrue(ctx.getPropertySources().contains(testPS2)); - assertNotNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPS2.getName())); + assertThat(ctx.getPropertySources()).hasSize(2); + assertThat(ctx.getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())).isNotNull(); + assertThat(ctx.getPropertySources().contains(testPS2)).isTrue(); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPS2.getName())).isNotNull(); // Ensure no sorting happens during add, so switch ordinals! testPS2 = new MockedPropertySource("addPropertySources_Array", 1); b = new DefaultConfigurationContextBuilder(); ctx = b.addPropertySources(testPS2, testPropertySource).build(); - assertEquals(2, ctx.getPropertySources().size()); - assertTrue(ctx.getPropertySources().contains(testPropertySource)); - assertNotNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())); - assertTrue(ctx.getPropertySources().contains(testPS2)); - assertNotNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPS2.getName())); - assertEquals(ctx.getPropertySources().get(1).getName(), "MockedPropertySource"); - assertEquals(ctx.getPropertySources().get(0).getName(), "addPropertySources_Array"); + assertThat(ctx.getPropertySources()).hasSize(2); + assertThat(ctx.getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())).isNotNull(); + assertThat(ctx.getPropertySources().contains(testPS2)).isTrue(); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPS2.getName())).isNotNull(); + assertThat("MockedPropertySource").isEqualTo(ctx.getPropertySources().get(1).getName()); + assertThat("addPropertySources_Array").isEqualTo(ctx.getPropertySources().get(0).getName()); } @Test @@ -96,24 +96,24 @@ public class DefaultConfigurationContextBuilderTest { ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder() .addPropertySources(Arrays.asList(new PropertySource[]{testPropertySource, testPS2})); ConfigurationContext ctx = b.build(); - assertEquals(2, ctx.getPropertySources().size()); - assertTrue(ctx.getPropertySources().contains(testPropertySource)); - assertNotNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())); - assertTrue(ctx.getPropertySources().contains(testPS2)); - assertNotNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPS2.getName())); - assertEquals(ctx.getPropertySources().get(0).getName(), "MockedPropertySource"); - assertEquals(ctx.getPropertySources().get(1).getName(), "addPropertySources_Collection"); + assertThat(ctx.getPropertySources()).hasSize(2); + assertThat(ctx.getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())).isNotNull(); + assertThat(ctx.getPropertySources().contains(testPS2)).isTrue(); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPS2.getName())).isNotNull(); + assertThat("MockedPropertySource").isEqualTo(ctx.getPropertySources().get(0).getName()); + assertThat("addPropertySources_Collection").isEqualTo(ctx.getPropertySources().get(1).getName()); // Ensure no sorting happens during add, so switch ordinals! testPS2 = new MockedPropertySource("addPropertySources_Collection", 1); ctx = new DefaultConfigurationContextBuilder() .addPropertySources(Arrays.asList(new PropertySource[]{testPS2, testPropertySource})).build(); - assertEquals(2, ctx.getPropertySources().size()); - assertTrue(ctx.getPropertySources().contains(testPropertySource)); - assertNotNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())); - assertTrue(ctx.getPropertySources().contains(testPS2)); - assertNotNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPS2.getName())); - assertEquals(ctx.getPropertySources().get(1).getName(), "MockedPropertySource"); - assertEquals(ctx.getPropertySources().get(0).getName(), "addPropertySources_Collection"); + assertThat(ctx.getPropertySources()).hasSize(2); + assertThat(ctx.getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())).isNotNull(); + assertThat(ctx.getPropertySources().contains(testPS2)).isTrue(); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPS2.getName())).isNotNull(); + assertThat("MockedPropertySource").isEqualTo(ctx.getPropertySources().get(1).getName()); + assertThat("addPropertySources_Collection").isEqualTo(ctx.getPropertySources().get(0).getName()); } @Test @@ -122,20 +122,20 @@ public class DefaultConfigurationContextBuilderTest { ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder() .addPropertySources(testPropertySource, testPS2); ConfigurationContext ctx = b.build(); - assertEquals(2, ctx.getPropertySources().size()); - assertTrue(ctx.getPropertySources().contains(testPropertySource)); - assertNotNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())); - assertTrue(ctx.getPropertySources().contains(testPS2)); - assertNotNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPS2.getName())); + assertThat(ctx.getPropertySources()).hasSize(2); + assertThat(ctx.getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())).isNotNull(); + assertThat(ctx.getPropertySources().contains(testPS2)).isTrue(); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPS2.getName())).isNotNull(); b = new DefaultConfigurationContextBuilder() .addPropertySources(testPropertySource, testPS2); ctx = b.removePropertySources(testPropertySource).build(); - assertFalse(ctx.getPropertySources().contains(testPropertySource)); + assertThat(ctx.getPropertySources().contains(testPropertySource)).isFalse(); //Throws an exception - //assertNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())); - assertTrue(ctx.getPropertySources().contains(testPS2)); - assertNotNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPS2.getName())); - assertEquals(1, ctx.getPropertySources().size()); + //assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())).isNull(); + assertThat(ctx.getPropertySources().contains(testPS2)).isTrue(); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPS2.getName())).isNotNull(); + assertThat(ctx.getPropertySources()).hasSize(1); } @Test @@ -144,18 +144,18 @@ public class DefaultConfigurationContextBuilderTest { ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder() .addPropertySources(testPropertySource, testPS2); ConfigurationContext ctx = b.build(); - assertEquals(2, ctx.getPropertySources().size()); - assertTrue(ctx.getPropertySources().contains(testPropertySource)); - assertNotNull(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())); - assertTrue(ctx.getPropertySources().contains(testPS2)); - assertNotNull(ctx.getPropertySource(testPS2.getName())); + assertThat(ctx.getPropertySources()).hasSize(2); + assertThat(ctx.getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource(testPropertySource.getName())).isNotNull(); + assertThat(ctx.getPropertySources().contains(testPS2)).isTrue(); + assertThat(ctx.getPropertySource(testPS2.getName())).isNotNull(); b = new DefaultConfigurationContextBuilder() .addPropertySources(testPropertySource, testPS2); ctx = b.removePropertySources(testPropertySource).build(); - assertEquals(1, ctx.getPropertySources().size()); - assertFalse(ctx.getPropertySources().contains(testPropertySource)); - assertTrue(ctx.getPropertySources().contains(testPS2)); - assertNotNull(ctx.getPropertySource(testPS2.getName())); + assertThat(ctx.getPropertySources()).hasSize(1); + assertThat(ctx.getPropertySources().contains(testPropertySource)).isFalse(); + assertThat(ctx.getPropertySources().contains(testPS2)).isTrue(); + assertThat(ctx.getPropertySource(testPS2.getName())).isNotNull(); } @Test(expected = IllegalArgumentException.class) @@ -163,7 +163,7 @@ public class DefaultConfigurationContextBuilderTest { PropertySource testPS2 = new MockedPropertySource("removePropertySources_Array", 1); ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder() .addPropertySources(testPropertySource, testPS2); - assertNull(((DefaultConfigurationContextBuilder)b).getPropertySource("missing")); + assertThat(((DefaultConfigurationContextBuilder)b).getPropertySource("missing")).isNull(); } @Test @@ -179,14 +179,14 @@ public class DefaultConfigurationContextBuilderTest { } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); - assertTrue(ctx.getPropertyFilters().contains(filter1)); - assertTrue(ctx.getPropertyFilters().contains(filter2)); - assertEquals(2, ctx.getPropertyFilters().size()); + assertThat(caughtAlreadyBuilt).isTrue(); + assertThat(ctx.getPropertyFilters().contains(filter1)).isTrue(); + assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); + assertThat(ctx.getPropertyFilters()).hasSize(2); b = new DefaultConfigurationContextBuilder(); b.addPropertyFilters(filter1, filter2); b.addPropertyFilters(filter1, filter2); - assertEquals(2, ctx.getPropertyFilters().size()); + assertThat(ctx.getPropertyFilters()).hasSize(2); } @Test @@ -202,14 +202,14 @@ public class DefaultConfigurationContextBuilderTest { } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); - assertTrue(ctx.getPropertyFilters().contains(filter1)); - assertTrue(ctx.getPropertyFilters().contains(filter2)); - assertEquals(2, ctx.getPropertyFilters().size()); + assertThat(caughtAlreadyBuilt).isTrue(); + assertThat(ctx.getPropertyFilters().contains(filter1)).isTrue(); + assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); + assertThat(ctx.getPropertyFilters()).hasSize(2); b = new DefaultConfigurationContextBuilder(); b.addPropertyFilters(filter1, filter2); b.addPropertyFilters(filter1, filter2); - assertEquals(2, ctx.getPropertyFilters().size()); + assertThat(ctx.getPropertyFilters()).hasSize(2); } @Test @@ -219,22 +219,22 @@ public class DefaultConfigurationContextBuilderTest { ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder() .addPropertyFilters(filter1, filter2); ConfigurationContext ctx = b.build(); - assertTrue(ctx.getPropertyFilters().contains(filter1)); - assertTrue(ctx.getPropertyFilters().contains(filter2)); - assertEquals(2, ctx.getPropertyFilters().size()); + assertThat(ctx.getPropertyFilters().contains(filter1)).isTrue(); + assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); + assertThat(ctx.getPropertyFilters()).hasSize(2); b = new DefaultConfigurationContextBuilder() .addPropertyFilters(filter1, filter2); ctx = b.removePropertyFilters(filter1).build(); - assertEquals(1, ctx.getPropertyFilters().size()); - assertFalse(ctx.getPropertyFilters().contains(filter1)); - assertTrue(ctx.getPropertyFilters().contains(filter2)); + assertThat(ctx.getPropertyFilters()).hasSize(1); + assertThat(ctx.getPropertyFilters().contains(filter1)).isFalse(); + assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); boolean caughtAlreadyBuilt = false; try { b.removePropertyFilters(filter1); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); } @Test @@ -244,22 +244,22 @@ public class DefaultConfigurationContextBuilderTest { ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder() .addPropertyFilters(Arrays.asList(new PropertyFilter[]{filter1, filter2})); ConfigurationContext ctx = b.build(); - assertTrue(ctx.getPropertyFilters().contains(filter1)); - assertTrue(ctx.getPropertyFilters().contains(filter2)); - assertEquals(2, ctx.getPropertyFilters().size()); + assertThat(ctx.getPropertyFilters().contains(filter1)).isTrue(); + assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); + assertThat(ctx.getPropertyFilters()).hasSize(2); b = new DefaultConfigurationContextBuilder() .addPropertyFilters(Arrays.asList(new PropertyFilter[]{filter1, filter2})); ctx = b.removePropertyFilters(Arrays.asList(filter1)).build(); - assertEquals(1, ctx.getPropertyFilters().size()); - assertFalse(ctx.getPropertyFilters().contains(filter1)); - assertTrue(ctx.getPropertyFilters().contains(filter2)); + assertThat(ctx.getPropertyFilters()).hasSize(1); + assertThat(ctx.getPropertyFilters().contains(filter1)).isFalse(); + assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); boolean caughtAlreadyBuilt = false; try { b.removePropertyFilters(filter1); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); } @Test @@ -275,13 +275,13 @@ public class DefaultConfigurationContextBuilderTest { } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)); - assertEquals(1, ctx.getPropertyConverters().size()); + assertThat(caughtAlreadyBuilt).isTrue(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isTrue(); + assertThat(ctx.getPropertyConverters()).hasSize(1); b = new DefaultConfigurationContextBuilder() .addPropertyConverters(TypeLiteral.of(String.class), converter); b.addPropertyConverters(TypeLiteral.of(String.class), converter); - assertEquals(1, ctx.getPropertyConverters().size()); + assertThat(ctx.getPropertyConverters()).hasSize(1); } @Test @@ -299,14 +299,14 @@ public class DefaultConfigurationContextBuilderTest { } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)); - assertEquals(ctx.getPropertyConverters().size(), 1); + assertThat(caughtAlreadyBuilt).isTrue(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isTrue(); + assertThat(1).isEqualTo(ctx.getPropertyConverters().size()); b = new DefaultConfigurationContextBuilder() .addPropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})); b.addPropertyConverters(TypeLiteral.of(String.class), converter); - assertEquals(ctx.getPropertyConverters().size(), 1); + assertThat(1).isEqualTo(ctx.getPropertyConverters().size()); } @Test @@ -316,13 +316,13 @@ public class DefaultConfigurationContextBuilderTest { ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder() .addPropertyConverters(TypeLiteral.of(String.class), converter); ConfigurationContext ctx = b.build(); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)); - assertEquals(1, ctx.getPropertyConverters(TypeLiteral.of(String.class)).size()); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isTrue(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class))).hasSize(1); b = new DefaultConfigurationContextBuilder() .addPropertyConverters(TypeLiteral.of(String.class), converter); ctx = b.removePropertyConverters(TypeLiteral.of(String.class)).build(); - assertFalse(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).isEmpty()); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isFalse(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).isEmpty()).isTrue(); } @Test @@ -332,13 +332,13 @@ public class DefaultConfigurationContextBuilderTest { ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder() .addPropertyConverters(TypeLiteral.of(String.class), converter); ConfigurationContext ctx = b.build(); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)); - assertEquals(1, ctx.getPropertyConverters(TypeLiteral.of(String.class)).size()); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isTrue(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class))).hasSize(1); b = new DefaultConfigurationContextBuilder() .addPropertyConverters(TypeLiteral.of(String.class), converter); ctx = b.removePropertyConverters(TypeLiteral.of(String.class), converter).build(); - assertFalse(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).isEmpty()); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isFalse(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).isEmpty()).isTrue(); } @SuppressWarnings({"rawtypes", "unchecked"}) @@ -348,13 +348,13 @@ public class DefaultConfigurationContextBuilderTest { ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder() .addPropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})); ConfigurationContext ctx = b.build(); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)); - assertEquals(1, ctx.getPropertyConverters(TypeLiteral.of(String.class)).size()); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isTrue(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class))).hasSize(1); b = new DefaultConfigurationContextBuilder() .addPropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})); ctx = b.removePropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})).build(); - assertFalse(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).isEmpty()); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isFalse(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).isEmpty()).isTrue(); } @Test @@ -369,8 +369,8 @@ public class DefaultConfigurationContextBuilderTest { } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); - assertEquals(ctx.getPropertyValueCombinationPolicy(), combPol); + assertThat(caughtAlreadyBuilt).isTrue(); + assertThat(combPol).isEqualTo(ctx.getPropertyValueCombinationPolicy()); } @Test @@ -383,21 +383,21 @@ public class DefaultConfigurationContextBuilderTest { b.addPropertySources(propertySources); b.increasePriority(propertySources[propertySources.length - 1]); for (int i = 0; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } b.increasePriority(propertySources[propertySources.length - 2]).build(); for (int i = 0; i < propertySources.length - 2; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } - assertEquals(propertySources[propertySources.length - 1], b.getPropertySources().get(propertySources.length - 2)); - assertEquals(propertySources[propertySources.length - 2], b.getPropertySources().get(propertySources.length - 1)); + assertThat(b.getPropertySources().get(propertySources.length - 2)).isEqualTo(propertySources[propertySources.length - 1]); + assertThat(b.getPropertySources().get(propertySources.length - 1)).isEqualTo(propertySources[propertySources.length - 2]); boolean caughtAlreadyBuilt = false; try { b.increasePriority(propertySources[propertySources.length - 2]); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); } @Test @@ -410,21 +410,21 @@ public class DefaultConfigurationContextBuilderTest { b.addPropertySources(propertySources); b.decreasePriority(propertySources[0]); for (int i = 0; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } b.decreasePriority(propertySources[1]).build(); for (int i = 2; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } - assertEquals(propertySources[0], b.getPropertySources().get(1)); - assertEquals(propertySources[1], b.getPropertySources().get(0)); + assertThat(b.getPropertySources().get(1)).isEqualTo(propertySources[0]); + assertThat(b.getPropertySources().get(0)).isEqualTo(propertySources[1]); boolean caughtAlreadyBuilt = false; try { b.decreasePriority(propertySources[1]); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); } @Test @@ -439,23 +439,23 @@ public class DefaultConfigurationContextBuilderTest { // test b.lowestPriority(propertySources[0]); for (int i = 0; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } b.lowestPriority(propertySources[1]); for (int i = 2; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } - assertEquals(propertySources[0], b.getPropertySources().get(1)); - assertEquals(propertySources[1], b.getPropertySources().get(0)); + assertThat(b.getPropertySources().get(1)).isEqualTo(propertySources[0]); + assertThat(b.getPropertySources().get(0)).isEqualTo(propertySources[1]); b.lowestPriority(propertySources[5]).build(); - assertEquals(propertySources[5], b.getPropertySources().get(0)); + assertThat(b.getPropertySources().get(0)).isEqualTo(propertySources[5]); boolean caughtAlreadyBuilt = false; try { b.lowestPriority(propertySources[5]); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); } @Test @@ -470,23 +470,23 @@ public class DefaultConfigurationContextBuilderTest { // test b.highestPriority(propertySources[propertySources.length - 1]); for (int i = 0; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } b.highestPriority(propertySources[propertySources.length - 2]); for (int i = 0; i < propertySources.length - 2; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } - assertEquals(propertySources[propertySources.length - 2], b.getPropertySources().get(propertySources.length - 1)); - assertEquals(propertySources[propertySources.length - 1], b.getPropertySources().get(propertySources.length - 2)); + assertThat(b.getPropertySources().get(propertySources.length - 1)).isEqualTo(propertySources[propertySources.length - 2]); + assertThat(b.getPropertySources().get(propertySources.length - 2)).isEqualTo(propertySources[propertySources.length - 1]); b.highestPriority(propertySources[5]).build(); - assertEquals(propertySources[5], b.getPropertySources().get(propertySources.length - 1)); + assertThat(b.getPropertySources().get(propertySources.length - 1)).isEqualTo(propertySources[5]); boolean caughtAlreadyBuilt = false; try { b.highestPriority(propertySources[5]); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); } @Test @@ -500,10 +500,10 @@ public class DefaultConfigurationContextBuilderTest { b.addPropertySources(propertySources); Comparator<PropertySource> psComp = (o1, o2) -> o1.toString().compareTo(o2.toString()); // test - assertEquals(DefaultConfigurationContextBuilder.class, b.sortPropertySources(psComp).getClass()); + assertThat(b.sortPropertySources(psComp).getClass()).isEqualTo(DefaultConfigurationContextBuilder.class); Arrays.sort(propertySources, psComp); for (int i = 0; i < propertySources.length; i++) { - assertEquals(propertySources[i], b.getPropertySources().get(i)); + assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } } @@ -519,10 +519,10 @@ public class DefaultConfigurationContextBuilderTest { b.addPropertyFilters(propertyFilters); Comparator<PropertyFilter> pfComp = (o1, o2) -> o1.toString().compareTo(o2.toString()); //test - assertEquals(DefaultConfigurationContextBuilder.class, b.sortPropertyFilter(pfComp).getClass()); + assertThat(b.sortPropertyFilter(pfComp).getClass()).isEqualTo(DefaultConfigurationContextBuilder.class); Arrays.sort(propertyFilters, pfComp); for (int i = 0; i < propertyFilters.length; i++) { - assertEquals(propertyFilters[i], b.getPropertyFilters().get(i)); + assertThat(b.getPropertyFilters().get(i)).isEqualTo(propertyFilters[i]); } } @@ -530,34 +530,34 @@ public class DefaultConfigurationContextBuilderTest { public void build() throws Exception { ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder(); ConfigurationContext ctx = b.build(); - assertNotNull(ctx); - assertTrue(ctx.getPropertySources().isEmpty()); - assertTrue(ctx.getPropertyFilters().isEmpty()); + assertThat(ctx).isNotNull(); + assertThat(ctx.getPropertySources().isEmpty()).isTrue(); + assertThat(ctx.getPropertyFilters().isEmpty()).isTrue(); boolean caughtAlreadyBuilt = false; try { b.build(); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); } @Test public void testRemoveAllFilters() throws Exception { ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder(); b.addPropertyFilters((value, context) -> value.toBuilder().setValue(toString() + " - ").build()); - assertFalse(b.getPropertyFilters().isEmpty()); + assertThat(b.getPropertyFilters().isEmpty()).isFalse(); b.removePropertyFilters(b.getPropertyFilters()); - assertTrue(b.getPropertyFilters().isEmpty()); + assertThat(b.getPropertyFilters().isEmpty()).isTrue(); } @Test public void testRemoveAllSources() throws Exception { ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder(); b.addPropertySources(new MockedPropertySource()); - assertFalse(b.getPropertySources().isEmpty()); + assertThat(b.getPropertySources().isEmpty()).isFalse(); b.removePropertySources(b.getPropertySources()); - assertTrue(b.getPropertyFilters().isEmpty()); + assertThat(b.getPropertyFilters().isEmpty()).isTrue(); } @Test @@ -578,20 +578,20 @@ public class DefaultConfigurationContextBuilderTest { } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); b = new DefaultConfigurationContextBuilder(); b.addPropertyFilters((value, context) -> value.toBuilder().setValue(toString() + " - ").build()); b.addPropertySources(new MockedPropertySource()); b.addPropertyConverters(TypeLiteral.of(String.class), converter); b.resetWithConfigurationContext(empty); - assertTrue(b.getPropertyConverter().isEmpty()); - assertTrue(b.getPropertySources().isEmpty()); - assertTrue(b.getPropertyFilters().isEmpty()); + assertThat(b.getPropertyConverter().isEmpty()).isTrue(); + assertThat(b.getPropertySources().isEmpty()).isTrue(); + assertThat(b.getPropertyFilters().isEmpty()).isTrue(); b.resetWithConfigurationContext(full).build(); - assertFalse(b.getPropertyConverter().isEmpty()); - assertFalse(b.getPropertySources().isEmpty()); - assertFalse(b.getPropertyFilters().isEmpty()); + assertThat(b.getPropertyConverter().isEmpty()).isFalse(); + assertThat(b.getPropertySources().isEmpty()).isFalse(); + assertThat(b.getPropertyFilters().isEmpty()).isFalse(); } @@ -605,12 +605,12 @@ public class DefaultConfigurationContextBuilderTest { } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); ConfigurationContext ctx = new DefaultConfigurationContextBuilder().loadDefaults().build(); - assertFalse(ctx.getPropertyConverters().isEmpty()); - assertFalse(ctx.getPropertyFilters().isEmpty()); - assertFalse(ctx.getPropertySources().isEmpty()); + assertThat(ctx.getPropertyConverters().isEmpty()).isFalse(); + assertThat(ctx.getPropertyFilters().isEmpty()).isFalse(); + assertThat(ctx.getPropertySources().isEmpty()).isFalse(); } @@ -624,11 +624,11 @@ public class DefaultConfigurationContextBuilderTest { } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); ConfigurationContext ctx = new DefaultConfigurationContextBuilder().addDefaultPropertyConverters().build(); - assertFalse(ctx.getPropertyConverters().isEmpty()); - assertNotNull(ctx.getPropertyConverters(TypeLiteral.of(Integer.class))); + assertThat(ctx.getPropertyConverters().isEmpty()).isFalse(); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(Integer.class))).isNotNull(); } @Test @@ -641,10 +641,10 @@ public class DefaultConfigurationContextBuilderTest { } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); ConfigurationContext ctx = new DefaultConfigurationContextBuilder().addDefaultPropertyFilters().build(); - assertFalse(ctx.getPropertyFilters().isEmpty()); + assertThat(ctx.getPropertyFilters().isEmpty()).isFalse(); } @Test @@ -657,11 +657,11 @@ public class DefaultConfigurationContextBuilderTest { } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } - assertTrue(caughtAlreadyBuilt); + assertThat(caughtAlreadyBuilt).isTrue(); ConfigurationContext ctx = new DefaultConfigurationContextBuilder().addDefaultPropertySources().build(); - assertFalse(ctx.getPropertySources().isEmpty()); - assertNotNull(ctx.getPropertySource("environment-properties")); + assertThat(ctx.getPropertySources().isEmpty()).isFalse(); + assertThat(ctx.getPropertySource("environment-properties")).isNotNull(); } @Test @@ -669,7 +669,7 @@ public class DefaultConfigurationContextBuilderTest { DefaultConfigurationContextBuilder b = new DefaultConfigurationContextBuilder(); List<PropertySource> ps = new ArrayList<>(); b.addCorePropertyResources(ps); - assertFalse(ps.isEmpty()); + assertThat(ps.isEmpty()).isFalse(); } }
