### Question:
TransMetaJsonDeserializer extends StdDeserializer<TransMeta> { protected void writeJsonAttributes( JsonNode attributes, ObjectMapper mapper, ObjectId stepId ) throws IOException { Map<String, Object> attrs = new HashMap<String, Object>(); attrs = mapper.readValue( attributes.toString(), attrs.getClass() ); for ( String s : attrs.keySet() ) { Object val = attrs.get( s ); try { if ( val instanceof Integer ) { repository.saveStepAttribute( null, stepId, s, (Integer) val ); } else if ( val instanceof Long ) { repository.saveStepAttribute( null, stepId, s, (Long) val ); } else if ( val instanceof Double ) { repository.saveStepAttribute( null, stepId, s, (Double) val ); } else if ( val instanceof Boolean ) { repository.saveStepAttribute( null, stepId, s, (Boolean) val ); } else { repository.saveStepAttribute( null, stepId, s, val == null ? null : (String) val ); } } catch ( KettleException e ) { LOGGER.info( Messages.getString( "INFO.Deserialization.Trans.SavingAttributes", s ), e ); } } } TransMetaJsonDeserializer( Class<?> aClass );  TransMetaJsonDeserializer( Class<?> aClass, Repository repository ); Repository getRepository(); void setRepository( Repository repository ); @Override TransMeta deserialize( JsonParser parser, DeserializationContext context );  }### Answer:
@Test public void testWriteJsonAttributes() throws Exception { JsonNode attributes = mock( JsonNode.class ); ObjectId stepId = new StringObjectId( "id" ); Map<String, Object> attrMap = new HashMap<String, Object>(){{ put( "name", "Test" ); put( "int", 2 ); put( "long", 3L ); put( "double", 3.0D ); put( "bool", true ); put( "null", null ); }}; when( attributes.toString() ).thenReturn( "mockedAttributes" ); when( mapper.readValue( "mockedAttributes", attrs0.getClass() ) ).then( invocationOnMock -> attrMap ); deserializer.writeJsonAttributes( attributes, mapper, stepId ); verify( repo ).saveStepAttribute( null, stepId, "name", "Test" ); verify( repo ).saveStepAttribute( null, stepId, "int", 2 ); verify( repo ).saveStepAttribute( null, stepId, "long", 3L ); verify( repo ).saveStepAttribute( null, stepId, "double", 3.0D ); verify( repo ).saveStepAttribute( null, stepId, "bool", true ); verify( repo ).saveStepAttribute( null, stepId, "null", null ); }