TAMAYA-217: Convert test assertions to AssertJ This seemingly-lengthy commit converts all of the assertions in tests from a combination of JUnit, Hamcrest, and AssertJ to only AssertJ. None of the logic has changed, only the syntax.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/119c4982 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/119c4982 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/119c4982 Branch: refs/heads/master Commit: 119c49821dea5d89b0a87578abd0e733605926c1 Parents: 125eed2 Author: William Lieurance <[email protected]> Authored: Mon Feb 26 03:15:05 2018 -0600 Committer: William Lieurance <[email protected]> Committed: Mon Feb 26 03:15:05 2018 -0600 ---------------------------------------------------------------------- code/api/pom.xml | 4 - .../org/apache/tamaya/ConfigExceptionTest.java | 10 +- .../tamaya/ConfigurationProviderTest.java | 22 +- .../org/apache/tamaya/ConfigurationTest.java | 48 +-- .../java/org/apache/tamaya/TypeLiteralTest.java | 37 ++- .../spi/ConfigurationProviderSpiTest.java | 10 +- .../tamaya/spi/ConversionContextTest.java | 34 +-- .../apache/tamaya/spi/FilterContextTest.java | 24 +- .../tamaya/spi/PropertySourceProviderTest.java | 6 +- .../apache/tamaya/spi/PropertySourceTest.java | 16 +- .../tamaya/spi/PropertyValueBuilderTest.java | 68 ++--- .../apache/tamaya/spi/PropertyValueTest.java | 88 +++--- .../tamaya/spi/ServiceContextManagerTest.java | 8 +- .../apache/tamaya/spi/ServiceContextTest.java | 30 +- code/core/pom.xml | 4 - .../tamaya/core/ConfigurationBuilderTest.java | 188 ++++++------ .../core/ConfigurationContextBuilderTest.java | 188 ++++++------ .../apache/tamaya/core/ConfigurationTest.java | 24 +- .../apache/tamaya/core/OSGIActivatorTest.java | 12 +- .../internal/CoreConfigurationBuilderTest.java | 96 +++--- .../internal/CoreConfigurationProviderTest.java | 22 +- .../core/internal/CoreConfigurationTest.java | 70 ++--- .../internal/DefaultJavaConfigurationTest.java | 17 +- .../internal/OSGIServiceComparatorTest.java | 29 +- .../core/internal/OSGIServiceContextTest.java | 24 +- .../core/internal/OSGIServiceLoaderTest.java | 18 +- .../converters/BigDecimalConverterTest.java | 23 +- .../converters/BigIntegerConverterTest.java | 27 +- .../converters/BooleanConverterTest.java | 98 +++--- .../internal/converters/ByteConverterTest.java | 34 +-- .../internal/converters/CharConverterTest.java | 34 +-- .../internal/converters/ClassConverterTest.java | 18 +- .../internal/converters/ConvertQueryTest.java | 12 +- .../converters/CurrencyConverterTest.java | 42 +-- .../converters/DoubleConverterTest.java | 53 ++-- .../converters/DurationConverterTest.java | 22 +- .../internal/converters/FileConverterTest.java | 10 +- .../internal/converters/FloatConverterTest.java | 57 ++-- .../converters/InstantConverterTest.java | 14 +- .../converters/IntegerConverterTest.java | 36 +-- .../converters/LocalDateConverterTest.java | 14 +- .../converters/LocalDateTimeConverterTest.java | 14 +- .../converters/LocalTimeConverterTest.java | 14 +- .../internal/converters/LongConverterTest.java | 36 +-- .../converters/NumberConverterTest.java | 51 ++-- .../converters/OffsetDateTimeConverterTest.java | 14 +- .../converters/OffsetTimeConverterTest.java | 14 +- .../converters/OptionalConverterTest.java | 20 +- .../internal/converters/PathConverterTest.java | 20 +- .../internal/converters/ShortConverterTest.java | 36 +-- .../converters/SupplierConverterTest.java | 10 +- .../internal/converters/URIConverterTest.java | 24 +- .../internal/converters/URLConverterTest.java | 24 +- code/spi-support/pom.xml | 4 - .../BuildablePropertySourceProviderTest.java | 26 +- .../spisupport/BuildablePropertySourceTest.java | 62 ++-- .../DefaultConfigValueEvaluatorTest.java | 10 +- .../DefaultConfigurationBuilderTest.java | 154 +++++----- .../DefaultConfigurationContextBuilderTest.java | 300 +++++++++---------- .../DefaultConfigurationContextTest.java | 25 +- .../spisupport/DefaultConfigurationTest.java | 62 ++-- .../spisupport/DefaultServiceContextTest.java | 38 +-- .../tamaya/spisupport/EnumConverterTest.java | 28 +- .../PriorityServiceComparatorTest.java | 10 +- .../PropertyConverterManagerTest.java | 119 ++++---- .../tamaya/spisupport/ReflectionUtilTest.java | 8 +- .../spisupport/RegexPropertyFilterTest.java | 37 ++- .../propertysource/BasePropertySourceTest.java | 28 +- .../propertysource/CLIPropertySourceTest.java | 48 +-- .../propertysource/EnumConverterTest.java | 12 +- .../EnvironmentPropertySourceTest.java | 42 +-- .../JavaConfigurationProviderTest.java | 25 +- .../PropertiesFilePropertySourceTest.java | 30 +- .../PropertiesResourcePropertySourceTest.java | 30 +- .../SimplePropertySourceTest.java | 74 ++--- .../SystemPropertySourceTest.java | 49 ++- .../WrappedPropertySourceTest.java | 44 +-- examples/01-minimal/pom.xml | 4 - examples/02-custom-property-source/pom.xml | 6 +- examples/11-distributed/pom.xml | 4 - .../distributed/DisplayContentTest.java | 6 +- .../distributed/DisplayRegistrationTest.java | 6 +- pom.xml | 19 -- 83 files changed, 1528 insertions(+), 1650 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/pom.xml ---------------------------------------------------------------------- diff --git a/code/api/pom.xml b/code/api/pom.xml index 581e18d..73cfc71 100644 --- a/code/api/pom.xml +++ b/code/api/pom.xml @@ -43,10 +43,6 @@ under the License. <scope>test</scope> </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/api/src/test/java/org/apache/tamaya/ConfigExceptionTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/ConfigExceptionTest.java b/code/api/src/test/java/org/apache/tamaya/ConfigExceptionTest.java index fa7da0a..56b06ee 100644 --- a/code/api/src/test/java/org/apache/tamaya/ConfigExceptionTest.java +++ b/code/api/src/test/java/org/apache/tamaya/ConfigExceptionTest.java @@ -20,7 +20,7 @@ package org.apache.tamaya; import org.junit.Test; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; /** * Tests instantiating {@link ConfigException}. @@ -30,16 +30,16 @@ public class ConfigExceptionTest { @Test public void testCreationMessage(){ ConfigException ex = new ConfigException("test"); - assertNull(ex.getCause()); - assertEquals(ex.getMessage(), "test"); + assertThat(ex.getCause()).isNull(); + assertThat("test").isEqualTo(ex.getMessage()); } @Test public void testCreationMessageThrowable(){ Exception e = new IllegalStateException("blabla"); ConfigException ex = new ConfigException("test", e); - assertTrue(ex.getCause() == e); - assertEquals("test", ex.getMessage()); + assertThat(ex.getCause() == e).isTrue(); + assertThat(ex.getMessage()).isEqualTo("test"); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java b/code/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java index e58806e..c65ae61 100644 --- a/code/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java +++ b/code/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java @@ -22,7 +22,7 @@ import org.apache.tamaya.spi.ConfigurationBuilder; import org.apache.tamaya.spi.ConfigurationContext; import org.apache.tamaya.spi.ConfigurationContextBuilder; import org.junit.Test; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; import org.mockito.Mockito; /** @@ -40,7 +40,7 @@ public class ConfigurationProviderTest { @Test public void testCreateConfiguration() { Configuration result = ConfigurationProvider.createConfiguration(ConfigurationProvider.getConfiguration().getContext()); - assertNotNull(result); + assertThat(result).isNotNull(); } /** @@ -50,15 +50,15 @@ public class ConfigurationProviderTest { @Test public void testGetSetConfigurationContext() { ConfigurationContext currentContext = ConfigurationProvider.getConfigurationContext(); - assertTrue(currentContext instanceof ConfigurationContext); + assertThat(currentContext instanceof ConfigurationContext).isTrue(); ConfigurationContext newContext = Mockito.mock(ConfigurationContext.class); try{ ConfigurationProvider.setConfigurationContext(newContext); - assertEquals(newContext, ConfigurationProvider.getConfigurationContext()); + assertThat(ConfigurationProvider.getConfigurationContext()).isEqualTo(newContext); }finally{ ConfigurationProvider.setConfigurationContext(currentContext); } - assertEquals(currentContext, ConfigurationProvider.getConfigurationContext()); + assertThat(ConfigurationProvider.getConfigurationContext()).isEqualTo(currentContext); } /** @@ -67,15 +67,15 @@ public class ConfigurationProviderTest { @Test public void testGetSetConfiguration() { Configuration currentConfig = ConfigurationProvider.getConfiguration(); - assertTrue(currentConfig instanceof Configuration); + assertThat(currentConfig instanceof Configuration).isTrue(); Configuration newConfig = Mockito.mock(Configuration.class); try{ ConfigurationProvider.setConfiguration(newConfig); - assertEquals(newConfig, ConfigurationProvider.getConfiguration()); + assertThat(ConfigurationProvider.getConfiguration()).isEqualTo(newConfig); }finally{ ConfigurationProvider.setConfiguration(currentConfig); } - assertEquals(currentConfig, ConfigurationProvider.getConfiguration()); + assertThat(ConfigurationProvider.getConfiguration()).isEqualTo(currentConfig); } /** @@ -84,7 +84,7 @@ public class ConfigurationProviderTest { @Test public void testGetConfigurationBuilder() { ConfigurationBuilder result = ConfigurationProvider.getConfigurationBuilder(); - assertTrue(result instanceof ConfigurationBuilder); + assertThat(result instanceof ConfigurationBuilder).isTrue(); } /** @@ -93,11 +93,11 @@ public class ConfigurationProviderTest { @Test public void testGetConfigurationContextBuilder() { ConfigurationContextBuilder result = ConfigurationProvider.getConfigurationContextBuilder(); - assertTrue(result instanceof ConfigurationContextBuilder); + assertThat(result instanceof ConfigurationContextBuilder).isTrue(); } @Test public void testConstructorFails(){ - assertTrue(ConfigurationProvider.class.getConstructors().length == 0); + assertThat(ConfigurationProvider.class.getConstructors().length == 0).isTrue(); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/src/test/java/org/apache/tamaya/ConfigurationTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/ConfigurationTest.java b/code/api/src/test/java/org/apache/tamaya/ConfigurationTest.java index 26e2058..ad13158 100644 --- a/code/api/src/test/java/org/apache/tamaya/ConfigurationTest.java +++ b/code/api/src/test/java/org/apache/tamaya/ConfigurationTest.java @@ -19,70 +19,70 @@ package org.apache.tamaya; import org.junit.Test; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; /** * Test class that tests the default methods implemented on * {@link org.apache.tamaya.Configuration}. The provided - * {@link org.apache.tamaya.TestConfiguration} is implemented with maximal use of - * the default methods. + * {@link org.apache.tamaya.TestConfiguration} is implemented with maximal use + * of the default methods. */ public class ConfigurationTest { @Test public void testget() throws Exception { - assertEquals(Boolean.TRUE, ConfigurationProvider.getConfiguration().get("booleanTrue", Boolean.class)); - assertEquals(Boolean.FALSE, ConfigurationProvider.getConfiguration().get("booleanFalse", Boolean.class)); - assertEquals((int) Byte.MAX_VALUE, (int) ConfigurationProvider.getConfiguration().get("byte", Byte.class)); - assertEquals(Integer.MAX_VALUE, (int) ConfigurationProvider.getConfiguration().get("int", Integer.class)); - assertEquals(Long.MAX_VALUE, (long) ConfigurationProvider.getConfiguration().get("long", Long.class)); - assertEquals(Float.MAX_VALUE, (double) ConfigurationProvider.getConfiguration().get("float", Float.class), 0.0d); - assertEquals(Double.MAX_VALUE, ConfigurationProvider.getConfiguration().get("double", Double.class), 0.0d); - assertEquals("aStringValue", ConfigurationProvider.getConfiguration().get("String")); + assertThat(Boolean.TRUE).isEqualTo(ConfigurationProvider.getConfiguration().get("booleanTrue", Boolean.class)); + assertThat(Boolean.FALSE).isEqualTo(ConfigurationProvider.getConfiguration().get("booleanFalse", Boolean.class)); + assertThat((int) Byte.MAX_VALUE).isEqualTo((int) ConfigurationProvider.getConfiguration().get("byte", Byte.class)); + assertThat(Integer.MAX_VALUE).isEqualTo((int) ConfigurationProvider.getConfiguration().get("int", Integer.class)); + assertThat(Long.MAX_VALUE).isEqualTo((long) ConfigurationProvider.getConfiguration().get("long", Long.class)); + assertThat(Float.MAX_VALUE).isCloseTo((float) ConfigurationProvider.getConfiguration().get("float", Float.class), within(0.001f)); + assertThat(Double.MAX_VALUE).isEqualTo(ConfigurationProvider.getConfiguration().get("double", Double.class)); + assertThat("aStringValue").isEqualTo(ConfigurationProvider.getConfiguration().get("String")); } @Test public void testGetBoolean() throws Exception { - assertTrue(ConfigurationProvider.getConfiguration().get("booleanTrue", Boolean.class)); - assertFalse(ConfigurationProvider.getConfiguration().get("booleanFalse", Boolean.class)); - assertFalse(ConfigurationProvider.getConfiguration().get("foorBar", Boolean.class)); + assertThat(ConfigurationProvider.getConfiguration().get("booleanTrue", Boolean.class)).isTrue(); + assertThat(ConfigurationProvider.getConfiguration().get("booleanFalse", Boolean.class)).isFalse(); + assertThat(ConfigurationProvider.getConfiguration().get("foorBar", Boolean.class)).isFalse(); } @Test public void testGetInteger() throws Exception { - assertEquals(Integer.MAX_VALUE, (int) ConfigurationProvider.getConfiguration().get("int", Integer.class)); + assertThat(Integer.MAX_VALUE).isEqualTo((int) ConfigurationProvider.getConfiguration().get("int", Integer.class)); } @Test public void testGetLong() throws Exception { - assertEquals(Long.MAX_VALUE, (long) ConfigurationProvider.getConfiguration().get("long", Long.class)); + assertThat(Long.MAX_VALUE).isEqualTo((long) ConfigurationProvider.getConfiguration().get("long", Long.class)); } @Test public void testGetDouble() throws Exception { - assertEquals(Double.MAX_VALUE, ConfigurationProvider.getConfiguration().get("double", Double.class), 0.0d); + assertThat(Double.MAX_VALUE).isEqualTo(ConfigurationProvider.getConfiguration().get("double", Double.class)); } @Test public void testGetOrDefault() throws Exception { - assertEquals("StringIfThereWasNotAValueThere", ConfigurationProvider.getConfiguration().getOrDefault("nonexistant", "StringIfThereWasNotAValueThere")); - assertEquals("StringIfThereWasNotAValueThere", ConfigurationProvider.getConfiguration().getOrDefault("nonexistant", String.class, "StringIfThereWasNotAValueThere")); + assertThat("StringIfThereWasNotAValueThere").isEqualTo(ConfigurationProvider.getConfiguration().getOrDefault("nonexistant", "StringIfThereWasNotAValueThere")); + assertThat("StringIfThereWasNotAValueThere").isEqualTo(ConfigurationProvider.getConfiguration().getOrDefault("nonexistant", String.class, "StringIfThereWasNotAValueThere")); } @Test public void testToBuilder() throws Exception { - assertNotNull(ConfigurationProvider.getConfiguration().toBuilder()); + assertThat(ConfigurationProvider.getConfiguration().toBuilder()).isNotNull(); } - + @Test public void testWith() throws Exception { ConfigOperator noop = (Configuration config) -> config; - assertNotNull(ConfigurationProvider.getConfiguration().with(noop)); + assertThat(ConfigurationProvider.getConfiguration().with(noop)).isNotNull(); } - + @Test public void testQuery() throws Exception { ConfigQuery<String> stringQuery = (ConfigQuery) (Configuration config) -> config.get("String"); - assertEquals("aStringValue", ConfigurationProvider.getConfiguration().query(stringQuery)); + assertThat(ConfigurationProvider.getConfiguration().query(stringQuery)).isEqualTo("aStringValue"); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java b/code/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java index 65fe706..7145ad6 100644 --- a/code/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java +++ b/code/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java @@ -21,7 +21,7 @@ package org.apache.tamaya; import java.lang.reflect.Type; import static org.apache.tamaya.TypeLiteral.getGenericInterfaceTypeParameters; import static org.apache.tamaya.TypeLiteral.getTypeParameters; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.Iterator; @@ -29,7 +29,6 @@ import java.util.List; import java.util.Map; import org.junit.Test; -import static org.junit.Assert.*; /** * Tests for the {@link TypeLiteral} class. @@ -45,16 +44,16 @@ public class TypeLiteralTest { @Test public void test_constructor() { TypeLiteral<List<String>> listTypeLiteral = new TypeLiteral<List<String>>() { }; - assertEquals(List.class, listTypeLiteral.getRawType()); - assertEquals(String.class, TypeLiteral.getTypeParameters(listTypeLiteral.getType())[0]); + assertThat(listTypeLiteral.getRawType()).isEqualTo(List.class); + assertThat(TypeLiteral.getTypeParameters(listTypeLiteral.getType())[0]).isEqualTo(String.class); } @Test public void test_of() { class MyListClass extends ArrayList<String> { } TypeLiteral<MyListClass> listTypeLiteral = TypeLiteral.of(MyListClass.class); - assertEquals(MyListClass.class, listTypeLiteral.getRawType()); - assertEquals(MyListClass.class, listTypeLiteral.getType()); + assertThat(listTypeLiteral.getRawType()).isEqualTo(MyListClass.class); + assertThat(listTypeLiteral.getType()).isEqualTo(MyListClass.class); } @Test(expected = NullPointerException.class) @@ -65,24 +64,24 @@ public class TypeLiteralTest { @Test public void test_getTypeParameters() { TypeLiteral<List<String>> listTypeLiteral = new TypeLiteral<List<String>>() { }; - assertEquals(List.class, listTypeLiteral.getRawType()); - assertEquals(String.class, TypeLiteral.getTypeParameters(listTypeLiteral.getType())[0]); + assertThat(listTypeLiteral.getRawType()).isEqualTo(List.class); + assertThat(TypeLiteral.getTypeParameters(listTypeLiteral.getType())[0]).isEqualTo(String.class); } @Test public void testGetTypeParametersNoGenerics() { - assertEquals(0, getTypeParameters(String.class).length); + assertThat(getTypeParameters(String.class).length).isEqualTo(0); } @Test public void test_getGenericInterfaceTypeParameter() { class MyListClass extends ArrayList<String> implements List<String> { } - assertEquals(String.class, getGenericInterfaceTypeParameters(MyListClass.class, List.class)[0]); + assertThat(getGenericInterfaceTypeParameters(MyListClass.class, List.class)[0]).isEqualTo(String.class); } @Test public void testGetGenericInterfaceTypeParameterNoGenerics() { - assertEquals(0, getGenericInterfaceTypeParameters(String.class, String.class).length); + assertThat(getGenericInterfaceTypeParameters(String.class, String.class).length).isEqualTo(0); } @Test(expected = NullPointerException.class) @@ -107,7 +106,7 @@ public class TypeLiteralTest { class B extends A { }; TypeLiteral<List<String>> checker = new TypeLiteral<List<String>>() { }; Type t = checker.getDefinedType(B.class); - assertEquals(t.getTypeName(), "java.lang.String"); + assertThat("java.lang.String").isEqualTo(t.getTypeName()); } @Test(expected = RuntimeException.class) @@ -125,13 +124,13 @@ public class TypeLiteralTest { TypeLiteral a = TypeLiteral.of(List.class); TypeLiteral b = TypeLiteral.of(List.class); TypeLiteral c = TypeLiteral.of(Map.class); - assertEquals(a.hashCode(), b.hashCode()); - assertNotEquals(a.hashCode(), c.hashCode()); - assertTrue(a.equals(a)); - assertTrue(a.equals(b)); - assertFalse(a.equals(null)); - assertFalse(a.equals("SomeString")); - assertFalse(a.equals(c)); + assertThat(b.hashCode()).isEqualTo(a.hashCode()); + assertThat(a.hashCode()).isNotEqualTo(c.hashCode()); + assertThat(a.equals(a)).isTrue(); + assertThat(a.equals(b)).isTrue(); + assertThat(a.equals(null)).isFalse(); + assertThat(a.equals("SomeString")).isFalse(); + assertThat(a.equals(c)).isFalse(); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/src/test/java/org/apache/tamaya/spi/ConfigurationProviderSpiTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/ConfigurationProviderSpiTest.java b/code/api/src/test/java/org/apache/tamaya/spi/ConfigurationProviderSpiTest.java index 2e1a836..4fe631f 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/ConfigurationProviderSpiTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/ConfigurationProviderSpiTest.java @@ -20,7 +20,7 @@ package org.apache.tamaya.spi; import org.apache.tamaya.TestConfigurationProvider; import org.junit.Test; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; import org.mockito.Mockito; public class ConfigurationProviderSpiTest { @@ -29,12 +29,12 @@ TestConfigurationProvider configProvider = new TestConfigurationProvider(); @Test public void testIsConfigurationSettableByDefault(){ - assertTrue(configProvider.isConfigurationSettable()); + assertThat(configProvider.isConfigurationSettable()).isTrue(); } @Test public void testIsConfigurationContextSettable(){ - assertTrue(configProvider.isConfigurationContextSettable()); + assertThat(configProvider.isConfigurationContextSettable()).isTrue(); } /** @@ -44,13 +44,13 @@ TestConfigurationProvider configProvider = new TestConfigurationProvider(); @Test public void testGetSetConfigurationContext() { ConfigurationContext currentContext = configProvider.getConfigurationContextFromInterface(); - assertTrue(currentContext instanceof ConfigurationContext); + assertThat(currentContext instanceof ConfigurationContext).isTrue(); ConfigurationContext newContext = Mockito.mock(ConfigurationContext.class); try{ configProvider.setConfigurationContext(newContext); //The mocked TestConfigurationProvider doesn't set the context on the // inner Configuration object, as that's deprecated. - assertEquals(newContext, configProvider.getConfigurationContext()); + assertThat(configProvider.getConfigurationContext()).isEqualTo(newContext); }finally{ configProvider.setConfigurationContext(currentContext); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/src/test/java/org/apache/tamaya/spi/ConversionContextTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/ConversionContextTest.java b/code/api/src/test/java/org/apache/tamaya/spi/ConversionContextTest.java index f3c8cec..f52d368 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/ConversionContextTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/ConversionContextTest.java @@ -31,7 +31,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; /** * Tests for {@link ConversionContext}, created by atsticks on 20.08.16. @@ -41,25 +41,25 @@ public class ConversionContextTest { @Test public void getSetKey() throws Exception { ConversionContext ctx = new ConversionContext.Builder("getKey", TypeLiteral.of(String.class)).build(); - assertEquals("getKey", ctx.getKey()); + assertThat(ctx.getKey()).isEqualTo("getKey"); ctx = new ConversionContext.Builder("getKey", TypeLiteral.of(String.class)).setKey("setKey").build(); - assertEquals("setKey", ctx.getKey()); + assertThat(ctx.getKey()).isEqualTo("setKey"); } @Test public void getSetTargetType() throws Exception { ConversionContext ctx = new ConversionContext.Builder("getTargetType", TypeLiteral.of(String.class)).build(); - assertEquals(TypeLiteral.of(String.class), ctx.getTargetType()); + assertThat(ctx.getTargetType()).isEqualTo(TypeLiteral.of(String.class)); ctx = new ConversionContext.Builder("setTargetType", TypeLiteral.of(String.class)).setTargetType(TypeLiteral.of(Integer.class)).build(); - assertEquals(TypeLiteral.of(Integer.class), ctx.getTargetType()); + assertThat(ctx.getTargetType()).isEqualTo(TypeLiteral.of(Integer.class)); } @Test public void getSetAnnotatedElement() throws Exception { ConversionContext ctx = new ConversionContext.Builder("getAnnotatedElement", TypeLiteral.of(List.class)).build(); - assertNull(ctx.getAnnotatedElement()); + assertThat(ctx.getAnnotatedElement()).isNull(); ctx = new ConversionContext.Builder(TypeLiteral.of(List.class)).setAnnotatedElement(MyAnnotatedElement).build(); - assertEquals(MyAnnotatedElement, ctx.getAnnotatedElement()); + assertThat(ctx.getAnnotatedElement()).isEqualTo(MyAnnotatedElement); } @Test @@ -67,7 +67,7 @@ public class ConversionContextTest { Configuration config = new MyConfiguration(); ConversionContext ctx = new ConversionContext.Builder("testConfiguration", TypeLiteral.of(List.class)) .setConfiguration(config).build(); - assertEquals(config, ctx.getConfiguration()); + assertThat(ctx.getConfiguration()).isEqualTo(config); } @Test @@ -81,23 +81,23 @@ public class ConversionContextTest { ConversionContext ctx = new ConversionContext.Builder("getSupportedFormats", TypeLiteral.of(List.class)) .addSupportedFormats(MyConverter.class, writeable.get(0), writeable.get(1)).build(); - assertTrue(ctx.getSupportedFormats().containsAll(readable)); - assertTrue(ctx.getSupportedFormats().indexOf(readable.get(0)) - < ctx.getSupportedFormats().indexOf(readable.get(1))); + assertThat(ctx.getSupportedFormats().containsAll(readable)).isTrue(); + assertThat(ctx.getSupportedFormats().indexOf(readable.get(0)) + < ctx.getSupportedFormats().indexOf(readable.get(1))).isTrue(); ctx = new ConversionContext.Builder(TypeLiteral.of(List.class)).build(); - assertTrue(ctx.getSupportedFormats().isEmpty()); + assertThat(ctx.getSupportedFormats().isEmpty()).isTrue(); ctx.addSupportedFormats(MyConverter.class, writeable.get(0), writeable.get(1)); - assertTrue(ctx.getSupportedFormats().containsAll(readable)); - assertTrue(ctx.getSupportedFormats().indexOf(readable.get(0)) - < ctx.getSupportedFormats().indexOf(readable.get(1))); + assertThat(ctx.getSupportedFormats().containsAll(readable)).isTrue(); + assertThat(ctx.getSupportedFormats().indexOf(readable.get(0)) + < ctx.getSupportedFormats().indexOf(readable.get(1))).isTrue(); } @Test public void testToString() throws Exception { ConversionContext ctx = new ConversionContext.Builder("toString", TypeLiteral.of(List.class)) .addSupportedFormats(MyConverter.class, "0.0.0.0/nnn", "x.x.x.x/yyy").build(); - assertEquals("ConversionContext{configuration=null, key='toString', targetType=TypeLiteral{type=interface java.util.List}, annotatedElement=null, supportedFormats=[0.0.0.0/nnn (MyConverter), x.x.x.x/yyy (MyConverter)]}", ctx.toString()); + assertThat(ctx.toString()).isEqualTo("ConversionContext{configuration=null, key='toString', targetType=TypeLiteral{type=interface java.util.List}, annotatedElement=null, supportedFormats=[0.0.0.0/nnn (MyConverter), x.x.x.x/yyy (MyConverter)]}"); } @Test @@ -105,7 +105,7 @@ public class ConversionContextTest { ConfigurationContext context = new MyConfigurationContext(); ConversionContext ctx = new ConversionContext.Builder("getConfigurationContext", TypeLiteral.of(List.class)) .setConfigurationContext(context).build(); - assertEquals(context, ctx.getConfigurationContext()); + assertThat(ctx.getConfigurationContext()).isEqualTo(context); } private static final AnnotatedElement MyAnnotatedElement = new AnnotatedElement() { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/src/test/java/org/apache/tamaya/spi/FilterContextTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/FilterContextTest.java b/code/api/src/test/java/org/apache/tamaya/spi/FilterContextTest.java index d8ff360..00567c1 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/FilterContextTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/FilterContextTest.java @@ -26,7 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; /** * Tests for {@link FilterContext}. @@ -65,16 +65,16 @@ public class FilterContextTest { PropertyValue val = PropertyValue.of("getKey", "v", ""); FilterContext ctx = new FilterContext(val, new HashMap<String,PropertyValue>(), new TestConfigContext()); - assertEquals(val, ctx.getProperty()); + assertThat(ctx.getProperty()).isEqualTo(val); } @Test public void isSinglePropertyScoped() throws Exception { PropertyValue val = PropertyValue.of("isSinglePropertyScoped", "v", ""); FilterContext ctx = new FilterContext(val, new HashMap<String,PropertyValue>(), new TestConfigContext()); - assertEquals(false, ctx.isSinglePropertyScoped()); + assertThat(ctx.isSinglePropertyScoped()).isEqualTo(false); ctx = new FilterContext(val, new TestConfigContext()); - assertEquals(true, ctx.isSinglePropertyScoped()); + assertThat(ctx.isSinglePropertyScoped()).isEqualTo(true); } @Test @@ -85,8 +85,8 @@ public class FilterContextTest { } PropertyValue val = PropertyValue.of("getConfigEntries", "v", ""); FilterContext ctx = new FilterContext(val, config, new TestConfigContext()); - assertEquals(config, ctx.getConfigEntries()); - assertTrue(config != ctx.getConfigEntries()); + assertThat(ctx.getConfigEntries()).isEqualTo(config); + assertThat(config != ctx.getConfigEntries()).isTrue(); } @Test @@ -99,12 +99,12 @@ public class FilterContextTest { FilterContext ctx = new FilterContext(val, config, new TestConfigContext()); String toString = ctx.toString(); - assertNotNull(toString); - assertTrue(toString.contains("FilterContext{value='PropertyValue{key='testToString', value='val', " + - "source='mySource'}', configEntries=[")); - assertTrue(toString.contains("key-0")); - assertTrue(toString.contains("key-1")); - assertTrue(toString.endsWith("}")); + assertThat(toString).isNotNull(); + assertThat(toString.contains("FilterContext{value='PropertyValue{key='testToString', value='val', " + + "source='mySource'}', configEntries=[")).isTrue(); + assertThat(toString.contains("key-0")).isTrue(); + assertThat(toString.contains("key-1")).isTrue(); + assertThat(toString.endsWith("}")).isTrue(); } private static class TestConfigContext implements ConfigurationContext{ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceProviderTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceProviderTest.java b/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceProviderTest.java index 0e8bcfb..15797a9 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceProviderTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceProviderTest.java @@ -19,7 +19,7 @@ package org.apache.tamaya.spi; import org.junit.Test; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; public class PropertySourceProviderTest { @@ -29,7 +29,7 @@ public class PropertySourceProviderTest { @Test public void testEmptySourceProvider() { PropertySourceProvider instance = PropertySourceProvider.EMPTY; - assertTrue(instance.getPropertySources().isEmpty()); - assertEquals("PropertySourceProvider(empty)", instance.toString()); + assertThat(instance.getPropertySources().isEmpty()).isTrue(); + assertThat(instance.toString()).isEqualTo("PropertySourceProvider(empty)"); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java b/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java index 3b7c0ff..3b8dbac 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java @@ -20,7 +20,7 @@ package org.apache.tamaya.spi; import java.util.Map; import org.junit.Test; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; public class PropertySourceTest { @@ -31,12 +31,12 @@ public class PropertySourceTest { @Test public void testEmptySource() { PropertySource instance = PropertySource.EMPTY; - assertEquals(Integer.MIN_VALUE, instance.getOrdinal()); - assertEquals("<empty>", instance.getName()); - assertNull(instance.get("key")); - assertTrue(instance.getProperties().isEmpty()); - assertFalse(instance.isScannable()); - assertEquals("PropertySource.EMPTY", instance.toString()); + assertThat(instance.getOrdinal()).isEqualTo(Integer.MIN_VALUE); + assertThat(instance.getName()).isEqualTo("<empty>"); + assertThat(instance.get("key")).isNull(); + assertThat(instance.getProperties().isEmpty()).isTrue(); + assertThat(instance.isScannable()).isFalse(); + assertThat(instance.toString()).isEqualTo("PropertySource.EMPTY"); } @@ -46,7 +46,7 @@ public class PropertySourceTest { @Test public void testIsScannableByDefault() { PropertySource instance = new PropertySourceImpl(); - assertEquals(true, instance.isScannable()); + assertThat(instance.isScannable()).isEqualTo(true); } public class PropertySourceImpl implements PropertySource { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueBuilderTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueBuilderTest.java b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueBuilderTest.java index 8f983bc..f927d94 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueBuilderTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueBuilderTest.java @@ -18,7 +18,7 @@ */ package org.apache.tamaya.spi; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; import java.util.HashMap; import java.util.Map; @@ -121,27 +121,27 @@ public class PropertyValueBuilderTest { public void testKey() throws Exception { PropertyValueBuilder b = new PropertyValueBuilder("k", "testKey").setValue("v"); PropertyValue val = b.build(); - assertEquals(val.getKey(),"k"); - assertEquals(val.getValue(),"v"); - assertNull(val.getMetaEntries().get("k")); + assertThat("k").isEqualTo(val.getKey()); + assertThat("v").isEqualTo(val.getValue()); + assertThat(val.getMetaEntries().get("k")).isNull(); } @Test public void testSetKey() { PropertyValueBuilder b = new PropertyValueBuilder("k", "testSetKey").setKey("key"); PropertyValue val = b.build(); - assertEquals(val.getKey(),"key"); + assertThat("key").isEqualTo(val.getKey()); } @Test public void testSource() throws Exception { PropertyValueBuilder b = new PropertyValueBuilder("k", "testSource").setValue("v"); PropertyValue val = b.build(); - assertEquals(val.getSource(),"testSource"); + assertThat("testSource").isEqualTo(val.getSource()); PropertyValueBuilder b2 = b.setSource("differentSource"); val = b2.build(); - assertEquals(val.getSource(),"differentSource"); + assertThat("differentSource").isEqualTo(val.getSource()); } @Test(expected=NullPointerException.class) @@ -158,31 +158,31 @@ public class PropertyValueBuilderTest { .setValue("v") .addMetaEntry("k", "v2") .setMetaEntries(meta).build(); - assertEquals("v", pv.getValue()); - assertEquals("k", pv.getKey()); - assertNull(pv.getMetaEntry("k")); - assertEquals("testGetKey", pv.getSource()); - assertEquals(2, pv.getMetaEntries().size()); - assertEquals("2", pv.getMetaEntry("1")); - assertEquals("b", pv.getMetaEntry("a")); + assertThat(pv.getValue()).isEqualTo("v"); + assertThat(pv.getKey()).isEqualTo("k"); + assertThat(pv.getMetaEntry("k")).isNull(); + assertThat(pv.getSource()).isEqualTo("testGetKey"); + assertThat(pv.getMetaEntries()).hasSize(2); + assertThat(pv.getMetaEntry("1")).isEqualTo("2"); + assertThat(pv.getMetaEntry("a")).isEqualTo("b"); } @Test public void testGetKey() throws Exception { PropertyValue pv = PropertyValue.builder("k", "testGetKey").setValue("v").build(); - assertEquals("k", pv.getKey()); + assertThat(pv.getKey()).isEqualTo("k"); } @Test public void testGetValue1() throws Exception { PropertyValue pv = PropertyValue.of("k", "v", "testGetValue"); - assertEquals("v", pv.getValue()); + assertThat(pv.getValue()).isEqualTo("v"); } @Test public void testGetValue2() throws Exception { PropertyValue pv = PropertyValue.builder("k", "testGetValue").setValue("v").build(); - assertEquals("v", pv.getValue()); + assertThat(pv.getValue()).isEqualTo("v"); } @Test(expected = NullPointerException.class) @@ -197,8 +197,8 @@ public class PropertyValueBuilderTest { .addMetaEntry("k", "v2") .addMetaEntry("k2", "v22") .removeMetaEntry("k").build(); - assertEquals("v22", pv.getMetaEntry("k2")); - assertNull(pv.getMetaEntry("k")); + assertThat(pv.getMetaEntry("k2")).isEqualTo("v22"); + assertThat(pv.getMetaEntry("k")).isNull(); } @Test(expected=NullPointerException.class) @@ -215,8 +215,8 @@ public class PropertyValueBuilderTest { .setValue("v") .setMetaEntries(meta); PropertyValue pv = b.build(); - assertEquals(meta, b.getMetaEntries()); - assertEquals(meta, pv.getMetaEntries()); + assertThat(b.getMetaEntries()).isEqualTo(meta); + assertThat(pv.getMetaEntries()).isEqualTo(meta); } @Test @@ -231,10 +231,10 @@ public class PropertyValueBuilderTest { context.remove("y"); b.setMetaEntries(context); PropertyValue contextData = b.build(); - assertEquals(contextData.getMetaEntries().size(), context.size()); - assertEquals(contextData.getMetaEntry("source"), "testSetContextData"); - assertNotNull(contextData.getMetaEntry("ts")); - assertNull(contextData.getMetaEntry("y")); + assertThat(context.size()).isEqualTo(contextData.getMetaEntries().size()); + assertThat("testSetContextData").isEqualTo(contextData.getMetaEntry("source")); + assertThat(contextData.getMetaEntry("ts")).isNotNull(); + assertThat(contextData.getMetaEntry("y")).isNull(); } @Test @@ -244,9 +244,9 @@ public class PropertyValueBuilderTest { b.addMetaEntry("y", "yValue"); b.addMetaEntry("y", "y2"); PropertyValue contextData = b.build(); - assertEquals(contextData.getMetaEntries().size(), 2); - assertNotNull(contextData.getMetaEntry("ts")); - assertEquals(contextData.getMetaEntry("y"), "y2"); + assertThat(2).isEqualTo(contextData.getMetaEntries().size()); + assertThat(contextData.getMetaEntry("ts")).isNotNull(); + assertThat("y2").isEqualTo(contextData.getMetaEntry("y")); } @Test @@ -257,11 +257,11 @@ public class PropertyValueBuilderTest { .addMetaEntry("somethingelse", "othervalue") .mapKey("mappedkey"); PropertyValue pv = b.build(); - assertEquals("mappedkey", pv.getKey()); - assertEquals("value", pv.getValue()); - assertEquals(2, pv.getMetaEntries().size()); - assertEquals("mappedvalue", pv.getMetaEntry("_mappedkey.AndThenSome")); - assertEquals("othervalue", pv.getMetaEntry("somethingelse")); + assertThat(pv.getKey()).isEqualTo("mappedkey"); + assertThat(pv.getValue()).isEqualTo("value"); + assertThat(pv.getMetaEntries()).hasSize(2); + assertThat(pv.getMetaEntry("_mappedkey.AndThenSome")).isEqualTo("mappedvalue"); + assertThat(pv.getMetaEntry("somethingelse")).isEqualTo("othervalue"); } @Test @@ -269,7 +269,7 @@ public class PropertyValueBuilderTest { PropertyValueBuilder b = new PropertyValueBuilder("k") .setValue("v") .addMetaEntry("metak", "metav"); - assertEquals("PropertyValueBuilder{key='k'value='v', metaEntries={metak=metav}}", b.toString()); + assertThat(b.toString()).isEqualTo("PropertyValueBuilder{key='k'value='v', metaEntries={metak=metav}}"); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java index f443f60..e23bd35 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java @@ -24,7 +24,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; @SuppressWarnings("unchecked") public class PropertyValueTest { @@ -56,7 +56,7 @@ public class PropertyValueTest { @Test public void testOf(){ - assertNotNull(PropertyValue.of("k", "v", "testGetKey")); + assertThat(PropertyValue.of("k", "v", "testGetKey")).isNotNull(); } @Test(expected = NullPointerException.class) @@ -71,79 +71,69 @@ public class PropertyValueTest { @Test public void testHashCode(){ - assertEquals(PropertyValue.of("k", "v", "testGetKey").hashCode(), - PropertyValue.of("k", "v", "testGetKey").hashCode()); - assertNotSame(PropertyValue.of("k", "v", "testGetKey").hashCode(), - PropertyValue.of("k1", "v", "testGetKey").hashCode()); - assertNotSame(PropertyValue.of("k", "v", "testGetKey").hashCode(), - PropertyValue.of("k", "v1", "testGetKey").hashCode()); - assertNotSame(PropertyValue.of("k", "v", "1").hashCode(), - PropertyValue.of("k", "v", "2").hashCode()); + assertThat(PropertyValue.of("k", "v", "testGetKey").hashCode()).isEqualTo(PropertyValue.of("k", "v", "testGetKey").hashCode()); + assertThat(PropertyValue.of("k", "v", "testGetKey").hashCode()).isNotSameAs(PropertyValue.of("k1", "v", "testGetKey").hashCode()); + assertThat(PropertyValue.of("k", "v", "testGetKey").hashCode()).isNotSameAs(PropertyValue.of("k", "v1", "testGetKey").hashCode()); + assertThat(PropertyValue.of("k", "v", "1").hashCode()).isNotSameAs(PropertyValue.of("k", "v", "2").hashCode()); } @Test public void testEquals(){ - assertEquals(PropertyValue.of("k", "v", "testEquals"), - PropertyValue.of("k", "v", "testEquals")); - assertNotSame(PropertyValue.of("k2", "v", "testEquals"), - PropertyValue.of("k", "v", "testEquals")); - assertNotSame(PropertyValue.of("k", "v", "testEquals"), - PropertyValue.of("k", "v2", "testEquals")); - assertNotSame(PropertyValue.of("k", "v", "testEquals"), - PropertyValue.of("k", "v", "testEquals2")); + assertThat(PropertyValue.of("k", "v", "testEquals")).isEqualTo(PropertyValue.of("k", "v", "testEquals")); + assertThat(PropertyValue.of("k2", "v", "testEquals")).isNotSameAs(PropertyValue.of("k", "v", "testEquals")); + assertThat(PropertyValue.of("k", "v", "testEquals")).isNotSameAs(PropertyValue.of("k", "v2", "testEquals")); + assertThat(PropertyValue.of("k", "v", "testEquals")).isNotSameAs(PropertyValue.of("k", "v", "testEquals2")); } - + @Test public void testBuilder(){ - assertNotNull(PropertyValue.builder("k", "testGetKey")); - assertEquals(PropertyValue.of("k", "v", "testEquals"), - PropertyValue.builder("k", "testEquals").setValue("v").build()); + assertThat(PropertyValue.builder("k", "testGetKey")).isNotNull(); + assertThat(PropertyValue.of("k", "v", "testEquals")).isEqualTo(PropertyValue.builder("k", "testEquals").setValue("v").build()); } @Test public void testToBuilder(){ - assertNotNull(PropertyValue.of("k", "v", "testGetKey").toBuilder()); + assertThat(PropertyValue.of("k", "v", "testGetKey").toBuilder()).isNotNull(); // round-trip PropertyValue val = PropertyValue.of("k", "v", "testGetKey"); - assertEquals(val, - val.toBuilder().build()); + assertThat(val).isEqualTo(val.toBuilder().build()); } @Test public void testGetKey() throws Exception { PropertyValue pv = PropertyValue.of("k", "v", "testGetKey"); - assertEquals("k", pv.getKey()); + assertThat(pv.getKey()).isEqualTo("k"); } @Test public void testGetValue() throws Exception { PropertyValue pv = PropertyValue.of("k", "v", "testGetValue"); - assertEquals("v", pv.getValue()); + assertThat(pv.getValue()).isEqualTo("v"); } @Test public void testGetSource() throws Exception { PropertyValue pv = PropertyValue.of("k", "v", "testGetSource"); - assertEquals("testGetSource", pv.getSource()); + assertThat(pv.getSource()).isEqualTo("testGetSource"); pv = PropertyValue.of("k", "v", "testGetSource"); - assertEquals("testGetSource", pv.getSource()); + assertThat(pv.getSource()).isEqualTo("testGetSource"); } @Test public void testGetMetaEntry() throws Exception { PropertyValue pv = PropertyValue.builder("k", "testGetMetaEntry").setValue("v") .addMetaEntry("k", "v2").build(); - assertEquals("v", pv.getValue()); - assertEquals("k", pv.getKey()); - assertEquals("v2", pv.getMetaEntry("k")); - assertEquals("testGetMetaEntry", pv.getSource()); + assertThat(pv.getValue()).isEqualTo("v"); + assertThat(pv.getKey()).isEqualTo("k"); + assertThat(pv.getMetaEntry("k")).isEqualTo("v2"); + assertThat(pv.getSource()).isEqualTo("testGetMetaEntry"); } @Test public void testGetMetaEntries() throws Exception { PropertyValue pv = PropertyValue.of("k", "v", "testGetMetaEntries"); - assertNotNull(pv.getMetaEntries()); - assertTrue(pv.getMetaEntries().isEmpty()); + assertThat(pv.getMetaEntries()).isNotNull(); + assertThat(pv.getMetaEntries().isEmpty()).isTrue(); } @Test @@ -152,16 +142,16 @@ public class PropertyValueTest { map.put("a", "1"); map.put("b", "2"); Map<String,PropertyValue> result = PropertyValue.map(map, "source1"); - assertNotNull(result); - assertEquals(map.size(), result.size()); + assertThat(result).isNotNull(); + assertThat(result.size()).isEqualTo(map.size()); for (Map.Entry<String,String>en:map.entrySet()) { PropertyValue val = result.get(en.getKey()); - assertNotNull(val); - assertEquals(val.getKey(), en.getKey()); - assertEquals(val.getValue(), en.getValue()); - assertEquals(val.getSource(), "source1"); - assertTrue(val.getMetaEntries().isEmpty()); + assertThat(val).isNotNull(); + assertThat(en.getKey()).isEqualTo(val.getKey()); + assertThat(en.getValue()).isEqualTo(val.getValue()); + assertThat("source1").isEqualTo(val.getSource()); + assertThat(val.getMetaEntries().isEmpty()).isTrue(); } } @@ -174,15 +164,15 @@ public class PropertyValueTest { map.put("m1", "n1"); map.put("m2", "n2"); Map<String,PropertyValue> result = PropertyValue.map(map, "source1", meta); - assertNotNull(result); - assertEquals(map.size(), result.size()); + assertThat(result).isNotNull(); + assertThat(result.size()).isEqualTo(map.size()); for(Map.Entry<String,String>en:map.entrySet()){ PropertyValue val = result.get(en.getKey()); - assertNotNull(val); - assertEquals(val.getKey(), en.getKey()); - assertEquals(val.getValue(), en.getValue()); - assertEquals(val.getSource(), "source1"); - assertEquals(val.getMetaEntries(), meta); + assertThat(val).isNotNull(); + assertThat(en.getKey()).isEqualTo(val.getKey()); + assertThat(en.getValue()).isEqualTo(val.getValue()); + assertThat("source1").isEqualTo(val.getSource()); + assertThat(meta).isEqualTo(val.getMetaEntries()); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java b/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java index 7379555..4fd16d8 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java @@ -26,7 +26,7 @@ import java.util.Collections; import java.util.Enumeration; import java.util.List; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; /** * Additional tests for {@link ServiceContextManager}, created by atsticks on 20.08.16. @@ -39,12 +39,12 @@ public class ServiceContextManagerTest { try { MyServiceContext mine = new MyServiceContext(); ServiceContextManager.set(mine); - assertTrue(ServiceContextManager.getServiceContext() == mine); + assertThat(ServiceContextManager.getServiceContext() == mine).isTrue(); ServiceContextManager.set(mine); - assertTrue(ServiceContextManager.getServiceContext() == mine); + assertThat(ServiceContextManager.getServiceContext() == mine).isTrue(); } finally { ServiceContextManager.set(prev); - assertTrue(ServiceContextManager.getServiceContext() == prev); + assertThat(ServiceContextManager.getServiceContext() == prev).isTrue(); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java b/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java index 301c6ab..60aaf51 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java @@ -18,11 +18,7 @@ */ package org.apache.tamaya.spi; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; import java.net.URL; @@ -76,38 +72,38 @@ public class ServiceContextTest { @Test public void testOrdinal() throws Exception { - assertEquals(1, serviceContext.ordinal()); + assertThat(serviceContext.ordinal()).isEqualTo(1); } @Test public void testgetService() throws Exception { - assertEquals("ServiceContextTest", serviceContext.getService(String.class)); - assertNull(serviceContext.getService(Integer.class)); + assertThat(serviceContext.getService(String.class)).isEqualTo("ServiceContextTest"); + assertThat(serviceContext.getService(Integer.class)).isNull(); } @Test public void testGetService() throws Exception { String service = serviceContext.getService(String.class); - assertNotNull(service); - assertEquals("ServiceContextTest", service); + assertThat(service).isNotNull(); + assertThat(service).isEqualTo("ServiceContextTest"); Integer intService = serviceContext.getService(Integer.class); - assertNull(intService); + assertThat(intService).isNull(); } @Test public void testGetServices() throws Exception { Collection<String> services = serviceContext.getServices(String.class); - assertNotNull(services); - assertFalse(services.isEmpty()); - assertEquals("ServiceContextTest", services.iterator().next()); + assertThat(services).isNotNull(); + assertThat(services.isEmpty()).isFalse(); + assertThat(services.iterator().next()).isEqualTo("ServiceContextTest"); List<Integer> intServices = serviceContext.getServices(Integer.class); - assertNotNull(intServices); - assertTrue(intServices.isEmpty()); + assertThat(intServices).isNotNull(); + assertThat(intServices.isEmpty()).isTrue(); } @Test public void testGetInstance() throws Exception { - assertNotNull(ServiceContextManager.getServiceContext()); + assertThat(ServiceContextManager.getServiceContext()).isNotNull(); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/core/pom.xml ---------------------------------------------------------------------- diff --git a/code/core/pom.xml b/code/core/pom.xml index 2d98631..e81015e 100644 --- a/code/core/pom.xml +++ b/code/core/pom.xml @@ -49,10 +49,6 @@ under the License. <artifactId>junit</artifactId> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>java-hamcrest</artifactId> - </dependency> - <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.compendium</artifactId> <scope>provided</scope> http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/119c4982/code/core/src/test/java/org/apache/tamaya/core/ConfigurationBuilderTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/ConfigurationBuilderTest.java b/code/core/src/test/java/org/apache/tamaya/core/ConfigurationBuilderTest.java index 1f702bb..e91394b 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/ConfigurationBuilderTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/ConfigurationBuilderTest.java @@ -30,7 +30,7 @@ import sun.security.krb5.Config; import java.util.Arrays; import java.util.Comparator; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; /** * Tests for {@link ConfigurationBuilder} by atsticks on 06.09.16. @@ -44,7 +44,7 @@ public class ConfigurationBuilderTest { Configuration cfg = ConfigurationProvider.getConfiguration(); ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder() .setConfiguration(cfg); - assertEquals(cfg, b.build()); + assertThat(b.build()).isEqualTo(cfg); } @Test @@ -53,19 +53,19 @@ public class ConfigurationBuilderTest { ConfigurationBuilder b = new CoreConfigurationBuilder() .addPropertySources(testPropertySource, testPS2); Configuration cfg = b.build(); - assertEquals(2, cfg.getContext().getPropertySources().size()); - assertTrue(cfg.getContext().getPropertySources().contains(testPropertySource)); - assertTrue(cfg.getContext().getPropertySources().contains(testPS2)); + assertThat(cfg.getContext().getPropertySources()).hasSize(2); + assertThat(cfg.getContext().getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(cfg.getContext().getPropertySources().contains(testPS2)).isTrue(); // Ensure no sorting happens during add, so switch ordinals! testPS2 = new TestPropertySource("addPropertySources_Array", 1); b = ConfigurationProvider.getConfigurationBuilder() .addPropertySources(testPS2, testPropertySource); cfg = b.build(); - assertEquals(2, cfg.getContext().getPropertySources().size()); - assertTrue(cfg.getContext().getPropertySources().contains(testPropertySource)); - assertTrue(cfg.getContext().getPropertySources().contains(testPS2)); - assertEquals(cfg.getContext().getPropertySources().get(1).getName(), "TestPropertySource"); - assertEquals(cfg.getContext().getPropertySources().get(0).getName(), "addPropertySources_Array"); + assertThat(cfg.getContext().getPropertySources()).hasSize(2); + assertThat(cfg.getContext().getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(cfg.getContext().getPropertySources().contains(testPS2)).isTrue(); + assertThat("TestPropertySource").isEqualTo(cfg.getContext().getPropertySources().get(1).getName()); + assertThat("addPropertySources_Array").isEqualTo(cfg.getContext().getPropertySources().get(0).getName()); } @Test @@ -74,21 +74,21 @@ public class ConfigurationBuilderTest { ConfigurationBuilder b = new CoreConfigurationBuilder() .addPropertySources(Arrays.asList(new PropertySource[]{testPropertySource, testPS2})); Configuration cfg = b.build(); - assertEquals(2, cfg.getContext().getPropertySources().size()); - assertTrue(cfg.getContext().getPropertySources().contains(testPropertySource)); - assertTrue(cfg.getContext().getPropertySources().contains(testPS2)); - assertEquals(cfg.getContext().getPropertySources().get(0).getName(), "TestPropertySource"); - assertEquals(cfg.getContext().getPropertySources().get(1).getName(), "addPropertySources_Collection"); + assertThat(cfg.getContext().getPropertySources()).hasSize(2); + assertThat(cfg.getContext().getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(cfg.getContext().getPropertySources().contains(testPS2)).isTrue(); + assertThat("TestPropertySource").isEqualTo(cfg.getContext().getPropertySources().get(0).getName()); + assertThat("addPropertySources_Collection").isEqualTo(cfg.getContext().getPropertySources().get(1).getName()); // Ensure no sorting happens during add, so switch ordinals! testPS2 = new TestPropertySource("addPropertySources_Collection", 1); b = ConfigurationProvider.getConfigurationBuilder() .addPropertySources(Arrays.asList(new PropertySource[]{testPS2, testPropertySource})); cfg = b.build(); - assertEquals(2, cfg.getContext().getPropertySources().size()); - assertTrue(cfg.getContext().getPropertySources().contains(testPropertySource)); - assertTrue(cfg.getContext().getPropertySources().contains(testPS2)); - assertEquals(cfg.getContext().getPropertySources().get(1).getName(), "TestPropertySource"); - assertEquals(cfg.getContext().getPropertySources().get(0).getName(), "addPropertySources_Collection"); + assertThat(cfg.getContext().getPropertySources()).hasSize(2); + assertThat(cfg.getContext().getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(cfg.getContext().getPropertySources().contains(testPS2)).isTrue(); + assertThat("TestPropertySource").isEqualTo(cfg.getContext().getPropertySources().get(1).getName()); + assertThat("addPropertySources_Collection").isEqualTo(cfg.getContext().getPropertySources().get(0).getName()); } @Test @@ -97,16 +97,16 @@ public class ConfigurationBuilderTest { ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder() .addPropertySources(testPropertySource, testPS2); Configuration cfg = b.build(); - assertEquals(2, cfg.getContext().getPropertySources().size()); - assertTrue(cfg.getContext().getPropertySources().contains(testPropertySource)); - assertTrue(cfg.getContext().getPropertySources().contains(testPS2)); + assertThat(cfg.getContext().getPropertySources()).hasSize(2); + assertThat(cfg.getContext().getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(cfg.getContext().getPropertySources().contains(testPS2)).isTrue(); b = ConfigurationProvider.getConfigurationBuilder() .addPropertySources(testPropertySource, testPS2); b.removePropertySources(testPropertySource); cfg = b.build(); - assertFalse(cfg.getContext().getPropertySources().contains(testPropertySource)); - assertTrue(cfg.getContext().getPropertySources().contains(testPS2)); - assertEquals(1, cfg.getContext().getPropertySources().size()); + assertThat(cfg.getContext().getPropertySources().contains(testPropertySource)).isFalse(); + assertThat(cfg.getContext().getPropertySources().contains(testPS2)).isTrue(); + assertThat(cfg.getContext().getPropertySources()).hasSize(1); } @Test @@ -115,16 +115,16 @@ public class ConfigurationBuilderTest { ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder() .addPropertySources(testPropertySource, testPS2); Configuration cfg = b.build(); - assertEquals(2, cfg.getContext().getPropertySources().size()); - assertTrue(cfg.getContext().getPropertySources().contains(testPropertySource)); - assertTrue(cfg.getContext().getPropertySources().contains(testPS2)); + assertThat(cfg.getContext().getPropertySources()).hasSize(2); + assertThat(cfg.getContext().getPropertySources().contains(testPropertySource)).isTrue(); + assertThat(cfg.getContext().getPropertySources().contains(testPS2)).isTrue(); b = ConfigurationProvider.getConfigurationBuilder() .addPropertySources(testPropertySource, testPS2); b.removePropertySources(testPropertySource); cfg = b.build(); - assertEquals(1, cfg.getContext().getPropertySources().size()); - assertFalse(cfg.getContext().getPropertySources().contains(testPropertySource)); - assertTrue(cfg.getContext().getPropertySources().contains(testPS2)); + assertThat(cfg.getContext().getPropertySources()).hasSize(1); + assertThat(cfg.getContext().getPropertySources().contains(testPropertySource)).isFalse(); + assertThat(cfg.getContext().getPropertySources().contains(testPS2)).isTrue(); } @Test @@ -135,13 +135,13 @@ public class ConfigurationBuilderTest { b.addPropertyFilters(filter1, filter2); Configuration cfg = b.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 = ConfigurationProvider.getConfigurationBuilder(); b.addPropertyFilters(filter1, filter2); b.addPropertyFilters(filter1, filter2); - assertEquals(2, ctx.getPropertyFilters().size()); + assertThat(ctx.getPropertyFilters()).hasSize(2); } @Test @@ -152,13 +152,13 @@ public class ConfigurationBuilderTest { b.addPropertyFilters(Arrays.asList(new PropertyFilter[]{filter1, filter2})); Configuration cfg = b.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 = ConfigurationProvider.getConfigurationBuilder(); b.addPropertyFilters(filter1, filter2); b.addPropertyFilters(filter1, filter2); - assertEquals(2, ctx.getPropertyFilters().size()); + assertThat(ctx.getPropertyFilters()).hasSize(2); } @Test @@ -169,17 +169,17 @@ public class ConfigurationBuilderTest { .addPropertyFilters(filter1, filter2); Configuration cfg = b.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 = ConfigurationProvider.getConfigurationBuilder() .addPropertyFilters(filter1, filter2); b.removePropertyFilters(filter1); cfg = b.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(); } @Test @@ -190,17 +190,17 @@ public class ConfigurationBuilderTest { .addPropertyFilters(Arrays.asList(new PropertyFilter[]{filter1, filter2})); Configuration cfg = b.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 = ConfigurationProvider.getConfigurationBuilder() .addPropertyFilters(Arrays.asList(new PropertyFilter[]{filter1, filter2})); b.removePropertyFilters(filter1); cfg = b.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(); } @Test @@ -211,12 +211,12 @@ public class ConfigurationBuilderTest { .addPropertyConverters(TypeLiteral.of(String.class), converter); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)); - assertEquals(1, ctx.getPropertyConverters().size()); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isTrue(); + assertThat(ctx.getPropertyConverters()).hasSize(1); b = ConfigurationProvider.getConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), converter); b.addPropertyConverters(TypeLiteral.of(String.class), converter); - assertEquals(1, ctx.getPropertyConverters().size()); + assertThat(ctx.getPropertyConverters()).hasSize(1); } @Test @@ -228,13 +228,13 @@ public class ConfigurationBuilderTest { Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); - assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)); - assertEquals(ctx.getPropertyConverters().size(), 1); + assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isTrue(); + assertThat(1).isEqualTo(ctx.getPropertyConverters().size()); b = ConfigurationProvider.getConfigurationBuilder() .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 @@ -245,15 +245,15 @@ public class ConfigurationBuilderTest { .addPropertyConverters(TypeLiteral.of(String.class), converter); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); - 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 = ConfigurationProvider.getConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), converter); b.removePropertyConverters(TypeLiteral.of(String.class), converter); cfg = b.build(); ctx = cfg.getContext(); - 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(); } @@ -265,15 +265,15 @@ public class ConfigurationBuilderTest { .addPropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); - 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 = ConfigurationProvider.getConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})); b.removePropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})); cfg = b.build(); ctx = cfg.getContext(); - 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 @@ -283,7 +283,7 @@ public class ConfigurationBuilderTest { .setPropertyValueCombinationPolicy(combPol); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); - assertEquals(ctx.getPropertyValueCombinationPolicy(), combPol); + assertThat(combPol).isEqualTo(ctx.getPropertyValueCombinationPolicy()); } @Test @@ -296,14 +296,14 @@ public class ConfigurationBuilderTest { 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]); 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]); } @Test @@ -316,14 +316,14 @@ public class ConfigurationBuilderTest { 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]); 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]); } @Test @@ -338,16 +338,16 @@ public class ConfigurationBuilderTest { // 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]); - assertEquals(propertySources[5], b.getPropertySources().get(0)); + assertThat(b.getPropertySources().get(0)).isEqualTo(propertySources[5]); } @Test @@ -362,16 +362,16 @@ public class ConfigurationBuilderTest { // 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]); - assertEquals(propertySources[5], b.getPropertySources().get(propertySources.length-1)); + assertThat(b.getPropertySources().get(propertySources.length-1)).isEqualTo(propertySources[5]); } @Test @@ -388,7 +388,7 @@ public class ConfigurationBuilderTest { b.sortPropertySources(psComp); 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]); } } @@ -406,7 +406,7 @@ public class ConfigurationBuilderTest { b.sortPropertyFilter(pfComp); 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]); } } @@ -415,26 +415,26 @@ public class ConfigurationBuilderTest { ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); - assertNotNull(ctx); - assertTrue(ctx.getPropertySources().isEmpty()); - assertTrue(ctx.getPropertyFilters().isEmpty()); + assertThat(ctx).isNotNull(); + assertThat(ctx.getPropertySources().isEmpty()).isTrue(); + assertThat(ctx.getPropertyFilters().isEmpty()).isTrue(); } @Test public void testRemoveAllFilters() throws Exception { ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); 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 { ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); b.addPropertySources(new TestPropertySource()); - assertFalse(b.getPropertySources().isEmpty()); + assertThat(b.getPropertySources().isEmpty()).isFalse(); b.removePropertySources(b.getPropertySources()); - assertTrue(b.getPropertyFilters().isEmpty()); + assertThat(b.getPropertyFilters().isEmpty()).isTrue(); } } \ No newline at end of file
