### Question:
HotfolderManager { public void waitForResults(long timeout, long waitInterval, List<OcrOutput> outputs, URI errorResultXmlUri) throws TimeoutException, IOException { long start = System.currentTimeMillis(); List<URI> mustBeThereUris = extractFromOutputs(outputs); outerLoop: while (true) { checkIfError(start, timeout, errorResultXmlUri); for (URI expectedUri : mustBeThereUris) { if (!hotfolder.exists(expectedUri)) { logger.debug(expectedUri.toString() + " is not yet available"); waitALittle(waitInterval); continue outerLoop; } } logger.debug("Got all files."); break; } } HotfolderManager(String serverUrl, String user, String password);   HotfolderManager(Hotfolder initHotfolder); void deleteOutputs(List<OcrOutput> outputs); void deleteImages(List<OcrImage> images); void copyImagesToHotfolder(List<OcrImage> ocrImages); void retrieveResults(List<OcrOutput> ocrOutputs); void createAndSendTicket(AbbyyTicket abbyyTicket, String name); void waitForResults(long timeout, long waitInterval,
			List<OcrOutput> outputs, URI errorResultXmlUri); boolean enoughSpaceAvailable(long maxSpace, URI inputFolder,
		URI outputFolder, URI errorFolder); void deleteTicket(AbbyyTicket abbyyTicket); String readFromErrorFile(URI errorResultUri, String processName);  }### Answer:
@Test public void shouldWaitForResultsVeryShort() throws URISyntaxException, TimeoutException, IOException { List<OcrOutput> outputsToWaitFor = validOutputs(); when(hotfolderMock.exists(any(URI.class))).thenReturn(true); when(hotfolderMock.exists(new URI("http: managerSut.waitForResults(10, 1, outputsToWaitFor, new URI("http: verify(pauseMock, never()).forMilliseconds(anyLong()); }
@Test public void shouldWaitOneIterationForEachFile() throws URISyntaxException, IOException, TimeoutException { List<OcrOutput> outputsToWaitFor = validOutputs(); when(hotfolderMock.exists(new URI("http: when(hotfolderMock.exists(new URI("http: when(hotfolderMock.exists(new URI("http: managerSut.waitForResults(10, 1, outputsToWaitFor, new URI("http: verify(pauseMock, times(2)).forMilliseconds(1); }
@Test(expected=TimeoutException.class) public void shouldProvokeTimeout() throws URISyntaxException, IOException, TimeoutException { List<OcrOutput> outputsToWaitFor = validOutputs(); when(hotfolderMock.exists(new URI("http: managerSut.waitForResults(1, 1, outputsToWaitFor, new URI("http: }
@Test(expected=IOException.class) public void shouldFindErrorFile() throws URISyntaxException, IOException, TimeoutException { List<OcrOutput> outputsToWaitFor = validOutputs(); when(hotfolderMock.exists(new URI("http: managerSut.waitForResults(1, 1, outputsToWaitFor, new URI("http: }