### Question:
TextFieldTransformator extends TransformatorProcess { public void apply(String idProcess, ParameterTransformation parameterTransformation, ObjectNode jsonValue) { JsonNode at = at(parameterTransformation.getKeyField(), jsonValue); String valueToFormat = at.getNodeType() == JsonNodeType.OBJECT ? at.toString() : at.asText(); if (StringUtils.isNotBlank(valueToFormat)) { put(jsonValue, parameterTransformation.getKeyField() + "_text", valueToFormat); remove(jsonValue,parameterTransformation.getKeyField()); } } TextFieldTransformator(); void apply(String idProcess, ParameterTransformation parameterTransformation, ObjectNode jsonValue);  }### Answer:
@Test public void should_Process_Ok() throws Exception { TextFieldTransformator textFieldTransformator = new TextFieldTransformator(); RawDataGen rd = RawDataGen.builder().messageSend("1548").project("project").type("type").build(); ObjectMapper obj = new ObjectMapper(); String value = obj.writeValueAsString(rd); ObjectNode jsonValue = JSONUtils.getInstance().parseObj(value); textFieldTransformator.apply(null, ParameterTransformation.builder() .keyField("messageSend") .build(), jsonValue); assertThat(jsonValue.path("messageSend_text").asText()).isEqualTo("1548"); assertThat(jsonValue.path("messageSend").asText()).isEqualTo(""); }
@Test public void should_Process_nestedObject_Ok() throws Exception { TextFieldTransformator textFieldTransformator = new TextFieldTransformator(); String value = "{\"something\":\"test\",\"comment\": {\"value\":\"value1\"}}"; ObjectNode jsonValue = JSONUtils.getInstance().parseObj(value); textFieldTransformator.apply(null, ParameterTransformation.builder() .keyField("comment") .build(), jsonValue); assertThat(jsonValue.path("comment_text").asText()).isEqualTo("{\"value\":\"value1\"}"); assertThat(jsonValue.path("comment").asText()).isEqualTo(""); }
@Test public void should_Process_Ko() throws Exception { TextFieldTransformator textFieldTransformator = new TextFieldTransformator(); RawDataGen rd = RawDataGen.builder().messageSend("1548").project("project").type("type").build(); ObjectMapper obj = new ObjectMapper(); String value = obj.writeValueAsString(rd); ObjectNode jsonValue = JSONUtils.getInstance().parseObj(value); textFieldTransformator.apply(null, ParameterTransformation.builder() .keyField("messageSend2") .build(), jsonValue); assertThat(jsonValue.path("messageSend2_text").asText()).isEqualTo(""); }