Search in sources :

Example 16 with CollectionType

use of org.qi4j.api.type.CollectionType 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 CollectionType

use of org.qi4j.api.type.CollectionType 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 CollectionType

use of org.qi4j.api.type.CollectionType 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 19 with CollectionType

use of org.qi4j.api.type.CollectionType 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 20 with CollectionType

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

the class AbstractCollectionSerializationTest method givenCollectionTypeWithShortAndNullElementWhenSerializingAndDeserializingExpectEquals.

@Test
public void givenCollectionTypeWithShortAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception {
    String output = valueSerialization.serialize(shortCollection());
    CollectionType collectionType = new CollectionType(List.class, new ValueType(Short.class));
    List<Short> list = valueSerialization.deserialize(collectionType, output);
    assertEquals(shortCollection(), 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

CollectionType (org.qi4j.api.type.CollectionType)22 Test (org.junit.Test)16 ValueType (org.qi4j.api.type.ValueType)16 AbstractQi4jTest (org.qi4j.test.AbstractQi4jTest)16 MapType (org.qi4j.api.type.MapType)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Map (java.util.Map)6 ValueCompositeType (org.qi4j.api.type.ValueCompositeType)6 LinkedHashMap (java.util.LinkedHashMap)5 Date (java.util.Date)3 HashMap (java.util.HashMap)3 LinkedHashSet (java.util.LinkedHashSet)3 Set (java.util.Set)3 EntityReference (org.qi4j.api.entity.EntityReference)3 PropertyDescriptor (org.qi4j.api.property.PropertyDescriptor)3 EnumType (org.qi4j.api.type.EnumType)3 ValueComposite (org.qi4j.api.value.ValueComposite)3 BigInteger (java.math.BigInteger)2 Collection (java.util.Collection)2