ValidationWrapper { public void validate(ConfigValidator validator, Element element, Path path) { try { if (validator != null) { validator.validate(element); } } catch (ValidationException e) { ErrorCodeMapper.ErrorDetail errorDetail = ErrorCodeMapper.getErrorCode(e.getErrorId()); throw new InvalidInputConfigurationContentException(errorDetail.getErrorCode(), String.format(errorDetail.getErrorMessage(), path.toString())); } } ValidationWrapper(ConfigValidator configValidator); void check(Map<Path, Node> fileNodeMap); void validate(ConfigValidator validator, Element element, Path path);  }
@Test(expected = InvalidInputConfigurationContentException.class) public void testValidate() throws ValidationException { ConfigValidator validator = mock(ConfigValidator.class); ValidationWrapper validationWrapper = new ValidationWrapper(validator); Path path = mock(Path.class); Element element = mock(Element.class); ValidationException thrownException = mock(ValidationException.class); doThrow(thrownException).when(validator).validate(element); validationWrapper.validate(validator, element, path); }
@Test public void testValidateWithNoValidator() { ConfigValidator configValidator = null; ValidationWrapper validationWrapper = new ValidationWrapper(configValidator); Path path = mock(Path.class); Element element = mock(Element.class); validationWrapper.validate(configValidator, element, path); }