public static ValueType of( Class<?> type ) { return new ValueType( type ); }
@Test public void givenMapOfStringByteAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception { String output = valueSerialization.serialize( stringByteMap() ); MapType mapType = new MapType( Map.class, new ValueType( String.class ), new ValueType( Byte.class ) ); Map<String, Byte> value = valueSerialization.deserialize( mapType, output ); assertEquals( stringByteMap(), value ); }
@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 ); }
@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 ); }
@Test public void givenIterableTypeWithByteAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception { String output = valueSerialization.serialize( Iterables.iterable( byteCollection().toArray() ) ); CollectionType collectionType = new CollectionType( List.class, new ValueType( Byte.class ) ); List<Byte> list = valueSerialization.deserialize( collectionType, output ); assertEquals( byteCollection(), list ); }
@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 ); }
@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 ); }
@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 ); }
@Test public void givenCollectionTypeWithFloatAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception { String output = valueSerialization.serialize( floatCollection() ); CollectionType collectionType = new CollectionType( List.class, new ValueType( Float.class ) ); List<Float> list = valueSerialization.deserialize( collectionType, output ); assertEquals( floatCollection(), list ); }
@Test public void givenCollectionTypeWithBigDecimalAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception { String output = valueSerialization.serialize( bigDecimalCollection() ); CollectionType collectionType = new CollectionType( Collection.class, new ValueType( BigDecimal.class ) ); Collection<BigDecimal> collection = valueSerialization.deserialize( collectionType, output ); assertEquals( bigDecimalCollection(), collection ); }
@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 ); }
@Test public void givenCollectionTypeWithLongAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception { String output = valueSerialization.serialize( longCollection() ); CollectionType collectionType = new CollectionType( List.class, new ValueType( Long.class ) ); List<Long> list = valueSerialization.deserialize( collectionType, output ); assertEquals( longCollection(), list ); }
@Test public void givenCollectionTypeWithBigIntegerAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception { String output = valueSerialization.serialize( bigIntegerCollection() ); CollectionType collectionType = new CollectionType( List.class, new ValueType( BigInteger.class ) ); List<BigInteger> list = valueSerialization.deserialize( collectionType, output ); assertEquals( bigIntegerCollection(), list ); }
@Test public void givenListOfMapStringStringAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception { String output = valueSerialization.serialize( stringListOfMaps() ); ValueType stringType = new ValueType( String.class ); CollectionType collectionType = new CollectionType( List.class, new MapType( Map.class, stringType, stringType ) ); List<Map<String, String>> value = valueSerialization.deserialize( collectionType, output ); assertEquals( stringListOfMaps(), value ); }