@Test public void testTargetWDBinding_2() throws Exception { final String result = "{\"id\":\"1\",\"name\":\"target 1\",\"handler\":\"aws\",\"desc\":\"my target\",\"default\":\"true\"}"; ObjectMapper mapper = JSonBindingUtils.createObjectMapper(); TargetWrapperDescriptor twd = new TargetWrapperDescriptor(); twd.setId( "1" ); twd.setName( "target 1" ); twd.setDescription( "my target" ); twd.setHandler( "aws" ); twd.setDefault( true ); StringWriter writer = new StringWriter(); mapper.writeValue( writer, twd ); String s = writer.toString(); Assert.assertEquals( result, s ); TargetWrapperDescriptor readTwd = mapper.readValue( result, TargetWrapperDescriptor.class ); Assert.assertEquals( twd.getId(), readTwd.getId()); Assert.assertEquals( twd.getName(), readTwd.getName()); Assert.assertEquals( twd.getDescription(), readTwd.getDescription()); Assert.assertEquals( twd.getHandler(), readTwd.getHandler()); }
@SuppressWarnings( { "unchecked", "rawtypes" } ) public static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false ); SimpleModule module = new SimpleModule( "RoboconfModule", new Version( 1, 0, 0, null, null, null )); for( Map.Entry<Class<?>,? super JsonSerializer<?>> entry : SERIALIZERS.entrySet()) module.addSerializer((Class) entry.getKey(), (JsonSerializer) entry.getValue()); for( Map.Entry<Class<?>,? super JsonDeserializer<?>> entry : DESERIALIZERS.entrySet()) module.addDeserializer((Class) entry.getKey(), (JsonDeserializer) entry.getValue()); mapper.registerModule( module ); return mapper; }
JSonBindingUtils { @SuppressWarnings( { "unchecked", "rawtypes" } ) public static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false ); SimpleModule module = new SimpleModule( "RoboconfModule", new Version( 1, 0, 0, null, null, null )); for( Map.Entry<Class<?>,? super JsonSerializer<?>> entry : SERIALIZERS.entrySet()) module.addSerializer((Class) entry.getKey(), (JsonSerializer) entry.getValue()); for( Map.Entry<Class<?>,? super JsonDeserializer<?>> entry : DESERIALIZERS.entrySet()) module.addDeserializer((Class) entry.getKey(), (JsonDeserializer) entry.getValue()); mapper.registerModule( module ); return mapper; } }
JSonBindingUtils { @SuppressWarnings( { "unchecked", "rawtypes" } ) public static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false ); SimpleModule module = new SimpleModule( "RoboconfModule", new Version( 1, 0, 0, null, null, null )); for( Map.Entry<Class<?>,? super JsonSerializer<?>> entry : SERIALIZERS.entrySet()) module.addSerializer((Class) entry.getKey(), (JsonSerializer) entry.getValue()); for( Map.Entry<Class<?>,? super JsonDeserializer<?>> entry : DESERIALIZERS.entrySet()) module.addDeserializer((Class) entry.getKey(), (JsonDeserializer) entry.getValue()); mapper.registerModule( module ); return mapper; } private  JSonBindingUtils(); }
JSonBindingUtils { @SuppressWarnings( { "unchecked", "rawtypes" } ) public static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false ); SimpleModule module = new SimpleModule( "RoboconfModule", new Version( 1, 0, 0, null, null, null )); for( Map.Entry<Class<?>,? super JsonSerializer<?>> entry : SERIALIZERS.entrySet()) module.addSerializer((Class) entry.getKey(), (JsonSerializer) entry.getValue()); for( Map.Entry<Class<?>,? super JsonDeserializer<?>> entry : DESERIALIZERS.entrySet()) module.addDeserializer((Class) entry.getKey(), (JsonDeserializer) entry.getValue()); mapper.registerModule( module ); return mapper; } private  JSonBindingUtils(); static Map<Class<?>,? super JsonSerializer<?>> getSerializers(); @SuppressWarnings( { "unchecked", "rawtypes" } ) static ObjectMapper createObjectMapper(); }
JSonBindingUtils { @SuppressWarnings( { "unchecked", "rawtypes" } ) public static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false ); SimpleModule module = new SimpleModule( "RoboconfModule", new Version( 1, 0, 0, null, null, null )); for( Map.Entry<Class<?>,? super JsonSerializer<?>> entry : SERIALIZERS.entrySet()) module.addSerializer((Class) entry.getKey(), (JsonSerializer) entry.getValue()); for( Map.Entry<Class<?>,? super JsonDeserializer<?>> entry : DESERIALIZERS.entrySet()) module.addDeserializer((Class) entry.getKey(), (JsonDeserializer) entry.getValue()); mapper.registerModule( module ); return mapper; } private  JSonBindingUtils(); static Map<Class<?>,? super JsonSerializer<?>> getSerializers(); @SuppressWarnings( { "unchecked", "rawtypes" } ) static ObjectMapper createObjectMapper(); static final String AT_INSTANCE_PATH; }