### Question:
LegacyCliAdapter implements CliAdapter, Callable<CliResult> { static CliResult writeToOutputFile(Config config, Path outputPath) throws IOException { SystemAdapter systemAdapter = SystemAdapter.INSTANCE; systemAdapter.out().printf("Saving config to %s", outputPath); systemAdapter.out().println(); JaxbUtil.marshalWithNoValidation(config, systemAdapter.out()); systemAdapter.out().println(); try (OutputStream outputStream = Files.newOutputStream(outputPath)) { JaxbUtil.marshal(config, outputStream); systemAdapter.out().printf("Saved config to %s", outputPath); systemAdapter.out().println(); return new CliResult(0, false, config); } catch (ConstraintViolationException validationException) { validationException.getConstraintViolations().stream() .map(cv -> "Warning: " + cv.getMessage() + " on property " + cv.getPropertyPath()) .forEach(systemAdapter.err()::println); Files.write(outputPath, JaxbUtil.marshalToStringNoValidation(config).getBytes()); systemAdapter.out().printf("Saved config to %s", outputPath); systemAdapter.out().println(); return new CliResult(2, false, config); } } LegacyCliAdapter(); @Override CliType getType(); @Override CliResult call(); @Override CliResult execute(String... args); void setOverrides(final LegacyOverridesMixin overrides);  }### Answer:
@Test public void writeToOutputFileValidationError() throws Exception { Config config = mock(Config.class); Path outputPath = Files.createTempFile("writeToOutputFileValidationError", ".txt"); CliResult result = LegacyCliAdapter.writeToOutputFile(config, outputPath); assertThat(result.getStatus()).isEqualTo(2); }