UpdateMessagePatchValidator implements Validator<ObjectNode> { @Override public boolean isValid(ObjectNode patch) { return validate(patch).isEmpty(); } @Inject @VisibleForTesting  UpdateMessagePatchValidator(ObjectMapperFactory parserFactory); @Override boolean isValid(ObjectNode patch); @Override Set<ValidationResult> validate(ObjectNode json);  }
@Test public void isValidShouldReturnTrueWhenPatchWellFormatted() throws IOException { ObjectMapper mapper = new ObjectMapper(); when(objectMapperFactory.forParsing()) .thenReturn(mapper); String jsonContent = "{ \"isUnread\" : \"true\" }"; ObjectNode rootNode = mapper.readValue(jsonContent, ObjectNode.class); UpdateMessagePatchValidator sut = new UpdateMessagePatchValidator(objectMapperFactory); assertThat(sut.isValid(rootNode)).isTrue(); }