Search in sources :

Example 16 with ValueType

use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.

the class AbstractCollectionSerializationTest method givenCollectionTypeWithIntegerAndNullElementWhenSerializingAndDeserializingExpectEquals.

@Test
public void givenCollectionTypeWithIntegerAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception {
    String output = valueSerialization.serialize(integerCollection());
    CollectionType collectionType = new CollectionType(List.class, new ValueType(Integer.class));
    List<Integer> list = valueSerialization.deserialize(collectionType, output);
    assertEquals(integerCollection(), list);
}
Also used : BigInteger(java.math.BigInteger) ValueType(org.qi4j.api.type.ValueType) CollectionType(org.qi4j.api.type.CollectionType) AbstractQi4jTest(org.qi4j.test.AbstractQi4jTest) Test(org.junit.Test)

Example 17 with ValueType

use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.

the class AbstractCollectionSerializationTest method givenMapOfStringListStringAndNullElementWhenSerializingAndDeserializingExpectEquals.

@Test
public void givenMapOfStringListStringAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception {
    String output = valueSerialization.serialize(stringMultiMap());
    CollectionType collectionType = new CollectionType(List.class, new ValueType(String.class));
    MapType mapType = new MapType(Map.class, new ValueType(String.class), collectionType);
    Map<String, List<String>> value = valueSerialization.deserialize(mapType, output);
    assertEquals(stringMultiMap(), value);
}
Also used : ValueType(org.qi4j.api.type.ValueType) CollectionType(org.qi4j.api.type.CollectionType) ArrayList(java.util.ArrayList) List(java.util.List) MapType(org.qi4j.api.type.MapType) AbstractQi4jTest(org.qi4j.test.AbstractQi4jTest) Test(org.junit.Test)

Example 18 with ValueType

use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.

the class AbstractCollectionSerializationTest method givenCollectionTypeWithCharacterAndNullElementWhenSerializingAndDeserializingExpectEquals.

@Test
public void givenCollectionTypeWithCharacterAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception {
    String output = valueSerialization.serialize(characterCollection());
    CollectionType collectionType = new CollectionType(List.class, new ValueType(Character.class));
    List<Character> list = valueSerialization.deserialize(collectionType, output);
    assertEquals(characterCollection(), list);
}
Also used : ValueType(org.qi4j.api.type.ValueType) CollectionType(org.qi4j.api.type.CollectionType) AbstractQi4jTest(org.qi4j.test.AbstractQi4jTest) Test(org.junit.Test)

Example 19 with ValueType

use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.

the class AbstractCollectionSerializationTest method givenCollectionTypeWithByteAndNullElementWhenSerializingAndDeserializingExpectEquals.

@Test
public void givenCollectionTypeWithByteAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception {
    String output = valueSerialization.serialize(byteCollection());
    CollectionType collectionType = new CollectionType(Set.class, new ValueType(Byte.class));
    Set<Byte> list = valueSerialization.deserialize(collectionType, output);
    assertEquals(new LinkedHashSet<Byte>(byteCollection()), list);
}
Also used : ValueType(org.qi4j.api.type.ValueType) CollectionType(org.qi4j.api.type.CollectionType) AbstractQi4jTest(org.qi4j.test.AbstractQi4jTest) Test(org.junit.Test)

Example 20 with ValueType

use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.

the class AbstractCollectionSerializationTest method givenCollectionTypeWithDoubleAndNullElementWhenSerializingExpectCorrectJsonOutput.

@Test
public void givenCollectionTypeWithDoubleAndNullElementWhenSerializingExpectCorrectJsonOutput() throws Exception {
    String output = valueSerialization.serialize(doubleCollection());
    CollectionType collectionType = new CollectionType(List.class, new ValueType(Double.class));
    List<Double> list = valueSerialization.deserialize(collectionType, output);
    assertEquals(doubleCollection(), list);
}
Also used : ValueType(org.qi4j.api.type.ValueType) CollectionType(org.qi4j.api.type.CollectionType) AbstractQi4jTest(org.qi4j.test.AbstractQi4jTest) Test(org.junit.Test)

Aggregations

ValueType (org.qi4j.api.type.ValueType)23 CollectionType (org.qi4j.api.type.CollectionType)16 Test (org.junit.Test)13 AbstractQi4jTest (org.qi4j.test.AbstractQi4jTest)13 ValueCompositeType (org.qi4j.api.type.ValueCompositeType)8 MapType (org.qi4j.api.type.MapType)6 PropertyDescriptor (org.qi4j.api.property.PropertyDescriptor)5 ValueSerializationException (org.qi4j.api.value.ValueSerializationException)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)3 QualifiedName (org.qi4j.api.common.QualifiedName)3 EntityReference (org.qi4j.api.entity.EntityReference)3 EnumType (org.qi4j.api.type.EnumType)3 BigInteger (java.math.BigInteger)2 Preferences (java.util.prefs.Preferences)2 URI (org.openrdf.model.URI)2 ValueFactory (org.openrdf.model.ValueFactory)2 AssociationDescriptor (org.qi4j.api.association.AssociationDescriptor)2