### Question:
LookupListTransformator extends TransformatorProcess { public void apply(String idProcess, ParameterTransformation parameterTransformation, ObjectNode jsonValue) { String key = parameterTransformation.getKeyField(); if (StringUtils.isNotBlank(key)) { if (has(key,jsonValue)) { String oldValue = jsonValue.path(key).asText(); parameterTransformation.getMapLookup().entrySet().stream() .filter(entry -> entry.getKey().equals(oldValue)) .forEach(entry -> put(jsonValue, key, entry.getValue())); } } } LookupListTransformator(); void apply(String idProcess, ParameterTransformation parameterTransformation, ObjectNode jsonValue);  }### Answer:
@Test public void should_Process_Ok() throws Exception { LookupListTransformator lookupListTransformator = new LookupListTransformator(); RawDataGen rd = RawDataGen.builder().messageSend("gni").project("project value").type("type").build(); ObjectMapper obj = new ObjectMapper(); String value = obj.writeValueAsString(rd); ObjectNode jsonValue = JSONUtils.getInstance().parseObj(value); HashMap<String, String> mapTest = new HashMap<>(); mapTest.put("gni", "new value of message"); mapTest.put("project value", "new value of project"); lookupListTransformator.apply(null, ParameterTransformation.builder() .keyField("project") .mapLookup(mapTest) .build(), jsonValue); assertThat(jsonValue.get("messageSend").asText()).isEqualTo("gni"); assertThat(jsonValue.get("project").asText()).isEqualTo("new value of project"); assertThat(jsonValue.get("type").asText()).isEqualTo("type"); }
@Test public void should_Process_Limit_Ok() throws Exception { LookupListTransformator lookupListTransformator = new LookupListTransformator(); RawDataGen rd = RawDataGen.builder().messageSend("gni").project("project value").type("type").build(); ObjectMapper obj = new ObjectMapper(); String value = obj.writeValueAsString(rd); ObjectNode jsonValue = JSONUtils.getInstance().parseObj(value); HashMap<String, String> mapTest = new HashMap<>(); mapTest.put("gni", "new value of message"); mapTest.put("project value", "new value of project"); lookupListTransformator.apply(null, ParameterTransformation.builder() .keyField("messageSend") .mapLookup(mapTest) .build(), jsonValue); assertThat(jsonValue.get("messageSend").asText()).isEqualTo("new value of message"); assertThat(jsonValue.get("project").asText()).isEqualTo("project value"); assertThat(jsonValue.get("type").asText()).isEqualTo("type"); }
@Test public void should_Process_Limit_Ko() throws Exception { LookupListTransformator lookupListTransformator = new LookupListTransformator(); RawDataGen rd = RawDataGen.builder().messageSend("gni").project("project value").type("type").build(); ObjectMapper obj = new ObjectMapper(); String value = obj.writeValueAsString(rd); ObjectNode jsonValue = JSONUtils.getInstance().parseObj(value); HashMap<String, String> mapTest = new HashMap<>(); mapTest.put("gni", "new value of message"); mapTest.put("project value", "new value of project"); lookupListTransformator.apply(null, ParameterTransformation.builder() .keyField("gni") .mapLookup(mapTest) .build(), jsonValue); assertThat(jsonValue.get("messageSend").asText()).isEqualTo("gni"); assertThat(jsonValue.get("project").asText()).isEqualTo("project value"); assertThat(jsonValue.get("type").asText()).isEqualTo("type"); }