diff --git a/subsystems/TypeHandlerLibrary/src/test/java/org/terasology/persistence/typeHandling/InMemorySerializerTest.java b/subsystems/TypeHandlerLibrary/src/test/java/org/terasology/persistence/typeHandling/InMemorySerializerTest.java index 8d77751f98b..f407648ebc3 100644 --- a/subsystems/TypeHandlerLibrary/src/test/java/org/terasology/persistence/typeHandling/InMemorySerializerTest.java +++ b/subsystems/TypeHandlerLibrary/src/test/java/org/terasology/persistence/typeHandling/InMemorySerializerTest.java @@ -39,7 +39,7 @@ class InMemorySerializerTest { - private InMemoryPersistedDataSerializer serializer = new InMemoryPersistedDataSerializer(); + private final InMemoryPersistedDataSerializer serializer = new InMemoryPersistedDataSerializer(); public static Stream types() { return Stream.of( @@ -123,30 +123,6 @@ void serializeStrings() { Assertions.assertThrows(ClassCastException.class, data::getAsDouble); } - //TODO remove it - public void template(PersistedData data) { - Assertions.assertFalse(data.isString()); - Assertions.assertFalse(data.isArray()); - Assertions.assertFalse(data.isNull()); - Assertions.assertFalse(data.isNumber()); - Assertions.assertFalse(data.isBoolean()); - Assertions.assertFalse(data.isBytes()); - Assertions.assertFalse(data.isValueMap()); - - Assertions.assertThrows(IllegalStateException.class, data::getAsValueMap); - Assertions.assertThrows(IllegalStateException.class, data::getAsArray); - - Assertions.assertThrows(DeserializationException.class, data::getAsByteBuffer); - Assertions.assertThrows(DeserializationException.class, data::getAsBytes); - - Assertions.assertThrows(ClassCastException.class, data::getAsString); - Assertions.assertThrows(ClassCastException.class, data::getAsBoolean); - Assertions.assertThrows(ClassCastException.class, data::getAsInteger); - Assertions.assertThrows(ClassCastException.class, data::getAsLong); - Assertions.assertThrows(ClassCastException.class, data::getAsFloat); - Assertions.assertThrows(ClassCastException.class, data::getAsDouble); - } - @Test void serializeOneAsStrings() { PersistedData data = serializer.serialize(new String[]{"foo"}); @@ -306,7 +282,7 @@ void serializeBytes() { Assertions.assertEquals(PersistedBytes.class, data.getClass()); Assertions.assertTrue(data.isBytes()); - Assertions.assertEquals(value, data.getAsBytes()); + Assertions.assertArrayEquals(value, data.getAsBytes()); Assertions.assertEquals(ByteBuffer.wrap(value), data.getAsByteBuffer()); Assertions.assertFalse(data.isString()); @@ -335,7 +311,7 @@ void serializeByteBuffer() { Assertions.assertEquals(PersistedBytes.class, data.getClass()); Assertions.assertTrue(data.isBytes()); - Assertions.assertEquals(value, data.getAsBytes()); + Assertions.assertArrayEquals(value, data.getAsBytes()); Assertions.assertEquals(ByteBuffer.wrap(value), data.getAsByteBuffer()); Assertions.assertFalse(data.isString()); @@ -469,7 +445,7 @@ private void checkValueArray(PersistedData data, PersistedData entry, Set Assertions.assertEquals(typeGetter.getGetter().apply(entry), typeGetter.getGetter().apply(data)) diff --git a/subsystems/TypeHandlerLibrary/src/test/java/org/terasology/persistence/typeHandling/coreTypes/factories/BytesTypeHandlerTest.java b/subsystems/TypeHandlerLibrary/src/test/java/org/terasology/persistence/typeHandling/coreTypes/factories/BytesTypeHandlerTest.java index f0d9690bbb7..dff71f2ae62 100644 --- a/subsystems/TypeHandlerLibrary/src/test/java/org/terasology/persistence/typeHandling/coreTypes/factories/BytesTypeHandlerTest.java +++ b/subsystems/TypeHandlerLibrary/src/test/java/org/terasology/persistence/typeHandling/coreTypes/factories/BytesTypeHandlerTest.java @@ -39,10 +39,10 @@ void byteArraySerializeDeserialize() { byte[] expectedObj = new byte[]{(byte) 0xFF}; PersistedBytes data = serialize(expectedObj, new ByteArrayTypeHandler()); - Assertions.assertEquals(expectedObj, data.getAsBytes()); + Assertions.assertArrayEquals(expectedObj, data.getAsBytes()); byte[] obj = deserialize(data, new ByteArrayTypeHandler()); - Assertions.assertEquals(expectedObj, obj); + Assertions.assertArrayEquals(expectedObj, obj); } private R serialize(T obj, TypeHandler typeHandler) { diff --git a/subsystems/TypeHandlerLibrary/src/test/java/org/terasology/persistence/typeHandling/coreTypes/factories/ObjectFieldMapTypeHandlerFactoryTest.java b/subsystems/TypeHandlerLibrary/src/test/java/org/terasology/persistence/typeHandling/coreTypes/factories/ObjectFieldMapTypeHandlerFactoryTest.java index 3451b19d965..1d6eadbc3c9 100644 --- a/subsystems/TypeHandlerLibrary/src/test/java/org/terasology/persistence/typeHandling/coreTypes/factories/ObjectFieldMapTypeHandlerFactoryTest.java +++ b/subsystems/TypeHandlerLibrary/src/test/java/org/terasology/persistence/typeHandling/coreTypes/factories/ObjectFieldMapTypeHandlerFactoryTest.java @@ -33,6 +33,10 @@ public class ObjectFieldMapTypeHandlerFactoryTest { private static class SomeClass { private T t; private List list; + + private SomeClass(T t) { + this.t = t; + } } @Test