@Test public void testCommandHistoryItem() throws Exception { String expected = "{\"app\":\"test\",\"cmd\":\"scale\",\"details\":\"me\",\"start\":1542,\"duration\":21,\"result\":" + EXECUTION_OK + ",\"origin\":" + ORIGIN_REST_API + "}"; long duration = TimeUnit.NANOSECONDS.convert( 21, TimeUnit.MILLISECONDS ); Assert.assertEquals( 21000000, duration ); CommandHistoryItem item = new CommandHistoryItem( "test", "scale", ORIGIN_REST_API, "me", EXECUTION_OK, 1542, duration ); ObjectMapper mapper = JSonBindingUtils.createObjectMapper(); StringWriter writer = new StringWriter(); mapper.writeValue( writer, item ); Assert.assertEquals( expected, writer.toString()); duration = TimeUnit.NANOSECONDS.convert( 1, TimeUnit.MILLISECONDS ); item = new CommandHistoryItem( null, null, ORIGIN_SCHEDULER, null, EXECUTION_OK_WITH_SKIPPED, 21, duration ); writer = new StringWriter(); mapper.writeValue( writer, item ); Assert.assertEquals( "{\"start\":21,\"duration\":1,\"result\":" + EXECUTION_OK_WITH_SKIPPED + ",\"origin\":" + ORIGIN_SCHEDULER + "}", writer.toString()); }
@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; }