FileChecker { public List<List<String>> checkFilesExistsWithPairs(final List<String> searchResult) { List<List<String>> result = new ArrayList<>(); for (String actualFile : searchResult) { List<String> actualPair = new ArrayList<>(); markFileIfNotExists(actualFile, actualPair); String pairFile = getPair(actualFile); markFileIfNotExists(pairFile, actualPair); result.add(actualPair); } return result; }  List<List<String>> checkFilesExistsWithPairs(final List<String> searchResult);  }
@Test public void testCheckFilesExistsWithPairsWhenThereAreSomeSearchResultButOneRequestDoesntHavePair() { List<String> list = new ArrayList<>(); list.add("src/test/resources/first_testreq.txt"); list.add("src/test/resources/second_testreq.txt"); List<List<String>> expected = new ArrayList<>(); List<String> pair = new ArrayList<>(); pair.add("src/test/resources/first_testreq.txt"); pair.add("src/test/resources/first_testresp.txt"); expected.add(pair); pair = new ArrayList<>(); pair.add("src/test/resources/second_testreq.txt"); pair.add("src/test/resources/second_testresp.txt" + ERROR_POSTFIX); expected.add(pair); List<List<String>> result = underTest.checkFilesExistsWithPairs(list); Assert.assertEquals(result, expected); }
@Test public void testCheckFilesExistsWithPairsWhenThereAreSomeSearchResultButOneResponseDoesntHavePair() { List<String> list = new ArrayList<>(); list.add("src/test/resources/first_testreq.txt"); list.add("src/test/resources/third_testresp.txt"); List<List<String>> expected = new ArrayList<>(); List<String> pair = new ArrayList<>(); pair.add("src/test/resources/first_testreq.txt"); pair.add("src/test/resources/first_testresp.txt"); expected.add(pair); pair = new ArrayList<>(); pair.add("src/test/resources/third_testresp.txt"); pair.add("src/test/resources/third_testreq.txt" + ERROR_POSTFIX); expected.add(pair); List<List<String>> result = underTest.checkFilesExistsWithPairs(list); Assert.assertEquals(result, expected); }
@Test public void testCheckFilesExistsWithPairsWhenSearchResultIsEmptyList() { List<String> list = new ArrayList<>(); List<List<String>> expected = new ArrayList<>(); List<List<String>> result = underTest.checkFilesExistsWithPairs(list); Assert.assertEquals(result, expected); }
@Test(expectedExceptions = NullPointerException.class) public void testCheckFilesExistsWithPairsWhenSearchResultIsNull() { underTest.checkFilesExistsWithPairs(null); }