### Question:
Validator { public String validateParameters(OcrParameters params) { fileAccess = beanProvider.getFileAccess(); String validationMessage = ""; if (!isReadable(params.inputFolder)) { validationMessage += inputFolderError(); } if (isEmpty(params.inputTextType)) { validationMessage += noInputTextType(); } if (isEmpty(params.inputLanguages)) { validationMessage += noInputLanguages(); } if (!isWritable(params.outputFolder)) { validationMessage += outputFolderError(); } if (isEmpty(params.outputFormats)) { validationMessage += noOutputFormats(); } if (isEmpty(params.inputFormats)) { validationMessage += noInputFormats(); } if (isEmpty(params.priority)) { validationMessage += noPriority(); } if (isEmpty(params.ocrEngine)) { validationMessage += noOcrEngine(); } if (params.props == null) { validationMessage += nullProperties(); } if (validationMessage.isEmpty()) { return "OK"; } else { return validationMessage; } }  String validateParameters(OcrParameters params);  }### Answer:
@Test public void happyPath() { whenAskedThenFindFolders(); OcrParameters params = validParams(); String validation = validatorSut.validateParameters(params); verify(fileAccessMock).isReadableFolder("/tmp/input"); assertEquals("OK", validation); }
@Test public void shouldNotFindInputFolder() { when(fileAccessMock.isReadableFolder("/tmp/input")).thenReturn(false); when(fileAccessMock.isWritableFolder("/tmp/output")).thenReturn(true); OcrParameters params = validParams(); String validation = validatorSut.validateParameters(params); assertThat(validation, containsString("Input folder not found")); }
@Test public void shouldNotFindOutputFolder() { when(fileAccessMock.isReadableFolder("/tmp/input")).thenReturn(true); when(fileAccessMock.isWritableFolder("/tmp/output")).thenReturn(false); OcrParameters params = validParams(); String validation = validatorSut.validateParameters(params); assertThat(validation, containsString("Output folder not found or it is not writable")); }
@Test public void shouldDetectMissingInputFormats() { whenAskedThenFindFolders(); OcrParameters params = validParams(); params.inputFormats = new String[]{}; String validation = validatorSut.validateParameters(params); assertEquals("No input formats. ", validation); }
@Test public void shouldDetectMissingInputTextType() { whenAskedThenFindFolders(); OcrParameters params = validParams(); params.inputTextType = " "; String validation = validatorSut.validateParameters(params); assertEquals("No input text type. ", validation); }
@Test public void shouldDetectMissingLanguages() { whenAskedThenFindFolders(); OcrParameters params = validParams(); params.inputLanguages = null; String validation = validatorSut.validateParameters(params); assertEquals("No input languages. ", validation); }
@Test public void shouldDetectMissingOutputFormats() { whenAskedThenFindFolders(); OcrParameters params = validParams(); params.outputFormats = null; String validation = validatorSut.validateParameters(params); assertEquals("No output formats. ", validation); }
@Test public void shouldDetectMissingPriority() { whenAskedThenFindFolders(); OcrParameters params = validParams(); params.priority = ""; String validation = validatorSut.validateParameters(params); assertEquals("No priority. ", validation); }
@Test public void shouldDetectMissingOcrEngine() { whenAskedThenFindFolders(); OcrParameters params = validParams(); params.ocrEngine = null; String validation = validatorSut.validateParameters(params); assertEquals("No OCR engine. ", validation); }
@Test public void shouldDetectNullOptions() { whenAskedThenFindFolders(); OcrParameters params = validParams(); params.props = null; String validation = validatorSut.validateParameters(params); assertEquals("Properties may not be null. ", validation); }