### Question:
TransMetaJsonDeserializer extends StdDeserializer<TransMeta> { protected void writeJsonFields( JsonNode fields, ObjectMapper mapper, ObjectId stepId ) throws IOException { List<Map<String, Object>> fieldLists = new ArrayList<Map<String, Object>>(); fieldLists = mapper.readValue( fields.toString(), fieldLists.getClass() ); int idx = 0; for ( Map<String, Object> fieldAttrs : fieldLists ) { for ( String s : fieldAttrs.keySet() ) { Object val = fieldAttrs.get( s ); try { if ( val instanceof Integer ) { repository.saveStepAttribute( null, stepId, idx, s, (Integer) val ); } else if ( val instanceof Long ) { repository.saveStepAttribute( null, stepId, idx, s, (Long) val ); } else if ( val instanceof Double ) { repository.saveStepAttribute( null, stepId, idx, s, (Double) val ); } else if ( val instanceof Boolean ) { repository.saveStepAttribute( null, stepId, idx, s, (Boolean) val ); } else { repository.saveStepAttribute( null, stepId, idx, s, val == null ? null : (String) val ); } } catch ( KettleException e ) { LOGGER.info( Messages.getString( "INFO.Deserialization.Trans.SavingAttributes", s, String.valueOf( idx ) ), e ); } } idx++; } } 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 testWriteJsonFields() throws Exception { JsonNode fields = mock( JsonNode.class ); ObjectId stepId = new StringObjectId( "id" ); List<Map<String, Object>> fieldLists = new ArrayList<Map<String, Object>>(); Map<String, Object> fieldMap0 = new HashMap<String, Object>(){{ put( "name", "Test 1" ); put( "int", 2 ); put( "long", 3L ); put( "double", 3.0D ); put( "bool", true ); put( "null", null ); }}; Map<String, Object> fieldMap1 = new HashMap<String, Object>(){{ put( "name", "Test 2" ); put( "int", 2 ); put( "long", 3L ); put( "double", 3.0D ); put( "bool", true ); put( "null", null ); }}; fieldLists.add( fieldMap0 ); fieldLists.add( fieldMap1 ); when( fields.toString() ).thenReturn( "mockedFields" ); when( mapper.readValue( "mockedFields", fieldLists.getClass() ) ).then( invocationOnMock -> fieldLists ); deserializer.writeJsonFields( fields, mapper, stepId ); verify( repo ).saveStepAttribute( null, stepId, 0, "name", "Test 1" ); verify( repo ).saveStepAttribute( null, stepId, 1, "name", "Test 2" ); verify( repo, times( 2 ) ).saveStepAttribute( any( ObjectId.class ), eq( stepId ), anyInt(), eq( "int" ), anyInt() ); verify( repo, times( 2 ) ).saveStepAttribute( any( ObjectId.class ), eq( stepId ), anyInt(), eq( "long" ), eq( 3L ) ); verify( repo, times( 2 ) ).saveStepAttribute( any( ObjectId.class ), eq( stepId ), anyInt(), eq( "double" ), eq( 3.0D ) ); verify( repo, times( 2 ) ).saveStepAttribute( any( ObjectId.class ), eq( stepId ), anyInt(), eq( "bool" ), eq( true ) ); verify( repo, times( 2 ) ).saveStepAttribute( any( ObjectId.class ), eq( stepId ), anyInt(), eq( "null" ), anyString() ) ; }