### Question:
AddCsvLookupTransformator extends TransformatorProcess { public void apply(String idProcess, ParameterTransformation parameterTransformation, ObjectNode jsonValue) { String field = parameterTransformation.getCsvLookupData().getField(); if (StringUtils.isNotBlank(field)) { if (has(field, jsonValue)) { JsonNode valueField = at(field, jsonValue); if (parameterTransformation.getCsvLookupData().getMap().get(valueField.asText()) != null && !parameterTransformation.getCsvLookupData().getMap().get(valueField.asText()).isEmpty()) { parameterTransformation.getCsvLookupData().getMap().get(valueField.asText()) .stream() .forEach(processKeyValue -> put(jsonValue, processKeyValue.getKey(), processKeyValue.getValue())); } } } } AddCsvLookupTransformator(); void apply(String idProcess, ParameterTransformation parameterTransformation, ObjectNode jsonValue);  }### Answer:
@Test public void should_Process_Ok() throws Exception { AddCsvLookupTransformator addCsvLookupTransformator = new AddCsvLookupTransformator(); RawDataGen rd = RawDataGen.builder().messageSend("gni").project("project value").type("typeToDefine").build(); ObjectMapper obj = new ObjectMapper(); String value = obj.writeValueAsString(rd); ObjectNode jsonValue = JSONUtils.getInstance().parseObj(value); HashMap<String, List<ProcessKeyValue>> mapTest = new HashMap<>(); mapTest.put("typeToDefine", Arrays.asList(ProcessKeyValue.builder().key("ren.mouarf").value("toto").build(), ProcessKeyValue.builder().key("multipla").value("fiat").build())); mapTest.put("fake", Arrays.asList(ProcessKeyValue.builder().key("fakeKey").value("fakeValue").build(), ProcessKeyValue.builder().build())); addCsvLookupTransformator.apply(null, ParameterTransformation.builder() .csvLookupData(CsvLookupData.builder() .field("type") .map(mapTest) .build()) .build(), jsonValue); assertThat(jsonValue.get("type").asText()).isEqualTo("typeToDefine"); assertThat(jsonValue.get("ren").get("mouarf").asText()).isEqualTo("toto"); assertThat(jsonValue.get("multipla").asText()).isEqualTo("fiat"); }
@Test public void should_Process_Ko() throws Exception { AddCsvLookupTransformator addCsvLookupTransformator = new AddCsvLookupTransformator(); RawDataGen rd = RawDataGen.builder().messageSend("gni").project("project value").type("typeToDefine").build(); ObjectMapper obj = new ObjectMapper(); String value = obj.writeValueAsString(rd); ObjectNode jsonValue = JSONUtils.getInstance().parseObj(value); HashMap<String, List<ProcessKeyValue>> mapTest = new HashMap<>(); mapTest.put("typeToDefine", Arrays.asList(ProcessKeyValue.builder().key("ren.mouarf").value("toto").build(), ProcessKeyValue.builder().key("multipla").value("fiat").build())); mapTest.put("fake", Arrays.asList(ProcessKeyValue.builder().key("fakeKey").value("fakeValue").build(), ProcessKeyValue.builder().build())); addCsvLookupTransformator.apply(null, ParameterTransformation.builder() .csvLookupData(CsvLookupData.builder() .field("project") .map(mapTest) .build()) .build(), jsonValue); assertThat(jsonValue.get("type").asText()).isEqualTo("typeToDefine"); assertThat(jsonValue.has("multipla")).isFalse(); }