### Question:
MaxFieldValidator extends ValidatorProcess { public ValidateData process(ProcessValidation processValidation, JsonNode jsonValue) { int nbFields = Iterators.size(jsonValue.fieldNames()); eventSizeHistogram.observe(nbFields); if (nbFields > processValidation.getParameterValidation().getMaxFields()) { return UtilsValidateData.createValidateData(false, StatusCode.max_fields, TypeValidation.MAX_FIELD, jsonValue, String.valueOf(nbFields)); } return ValidateData.builder() .success(true) .typeValidation(TypeValidation.MAX_FIELD) .jsonValue(jsonValue) .build(); } MaxFieldValidator(); ValidateData process(ProcessValidation processValidation, JsonNode jsonValue);  }### Answer:
@Test public void should_Process_Ko() throws Exception { MaxFieldValidator maxFieldValidator = new MaxFieldValidator(); RawDataGen rd = RawDataGen.builder().messageSend("gni").project("project").type("type").build(); ObjectMapper obj = new ObjectMapper(); String value = obj.writeValueAsString(rd); JsonNode jsonValue = JSONUtils.getInstance().parse(value); ValidateData v = maxFieldValidator.process(ProcessValidation.builder() .parameterValidation(ParameterValidation.builder() .maxFields(2L).build() ).build(), jsonValue); assertThat(v.success).isFalse(); }
@Test public void should_Process_Ok() throws Exception { MaxFieldValidator maxFieldValidator = new MaxFieldValidator(); RawDataGen rd = RawDataGen.builder().messageSend("gni").project("project").type("type").build(); ObjectMapper obj = new ObjectMapper(); String value = obj.writeValueAsString(rd); JsonNode jsonValue = JSONUtils.getInstance().parse(value); ValidateData v = maxFieldValidator.process(ProcessValidation.builder() .parameterValidation(ParameterValidation.builder() .maxFields(7L).build() ).build(), jsonValue); assertThat(v.success).isTrue(); }