### Question:
WsdlValidator { public List<String> executeValidator(String wsdlUrl) throws WsdlValidatorNotExecutableException, WsdlValidationFailedException, InterruptedException { List<String> warnings = new ArrayList<>(); if (StringUtils.isEmpty(getWsdlValidatorCommand())) { log.warn("Skipping WSDL validator, command not set"); return warnings; } if (StringUtils.isEmpty(wsdlUrl)) { throw new IllegalArgumentException("wsdl url cannot be null or empty"); } try { ExternalProcessRunner.ProcessResult processResult = externalProcessRunner .executeAndThrowOnFailure(getWsdlValidatorCommand(), wsdlUrl); logValidatorOutput(processResult.getProcessOutput()); return processResult.getProcessOutput(); } catch (ProcessNotExecutableException e) { throw new WsdlValidatorNotExecutableException(e); } catch (ProcessFailedException e) { if (e.getErrorDeviation() != null) { logValidatorOutput(e.getErrorDeviation().getMetadata()); } throw new WsdlValidationFailedException(e.getErrorDeviation().getMetadata()); } } @Autowired  WsdlValidator(ExternalProcessRunner externalProcessRunner); List<String> executeValidator(String wsdlUrl);  }### Answer:
@Test public void validatorNotExecutable() throws Exception { ReflectionTestUtils.setField(wsdlValidator, "wsdlValidatorCommand", FOOBAR_VALIDATOR); try { wsdlValidator.executeValidator("src/test/resources/wsdl/error.wsdl"); fail("should have thrown WsdlValidationException"); } catch (WsdlValidator.WsdlValidatorNotExecutableException expected) { } }
@Test public void shouldHandleWarnings() throws Exception { List<String> warnings = wsdlValidator.executeValidator("src/test/resources/wsdl/warning.wsdl"); assertNotNull(warnings); assertEquals(1, warnings.size()); assertEquals(Collections.singletonList(MOCK_VALIDATOR_WARNING), warnings); }
@Test public void shouldFailValidation() throws Exception { try { wsdlValidator.executeValidator("src/test/resources/wsdl/error.wsdl"); fail("should have thrown WsdlValidationException"); } catch (WsdlValidator.WsdlValidationFailedException expected) { assertEquals(ERROR_INVALID_WSDL, expected.getErrorDeviation().getCode()); } }
@Test public void shouldPassValidation() throws Exception { List<String> warnings = wsdlValidator.executeValidator("src/test/resources/wsdl/testservice.wsdl"); assertEquals(new ArrayList(), warnings); }