### Question:
IngestSourceManagerImpl implements IngestSourceManager { @Override public List<IngestSourceCandidate> listCandidates(PID destination) { List<IngestSource> applicableSources = listSources(destination); final List<IngestSourceCandidate> candidates = new ArrayList<>(); for (final IngestSource source : applicableSources) { candidates.addAll(source.listCandidates()); } return candidates; }  void init(); @Override List<IngestSource> listSources(PID target); @Override List<IngestSourceCandidate> listCandidates(PID destination); @Override IngestSource getIngestSourceById(String id); @Override IngestSource getIngestSourceForUri(URI uri); void setConfigPath(String configPath); void setMappingPath(String mappingPath); void setContentPathFactory(ContentPathFactory contentPathFactory);  }### Answer:
@Test public void testListCandidatesBag() throws Exception { addBagToSource(sourceFolderPath); configPath = createConfigFile(createBasicConfig("testsource", destPid)); initializeManager(); List<IngestSourceCandidate> candidates = sourceMan.listCandidates(destPid); assertEquals(1, candidates.size()); IngestSourceCandidate candidate = candidates.get(0); assertBagDetails(candidate, "testsource", "bag_with_files"); }
@Test public void testListCandidatesNoCandidates() throws Exception { configPath = createConfigFile(createBasicConfig("testsource", destPid)); initializeManager(); List<IngestSourceCandidate> candidates = sourceMan.listCandidates(destPid); assertTrue(candidates.isEmpty()); }
@Test public void testListCandidatesFromMultipleSources() throws Exception { Path source2FolderPath = tmpFolder.newFolder().toPath(); addBagToSource(source2FolderPath, "bag_with_files", "second_bag"); addBagToSource(sourceFolderPath); Map<String, Object> source2 = createConfig( "testsource2", "Source 2", source2FolderPath, asList("*"), destPid); configPath = createConfigFile( source2, createBasicConfig("testsource", destPid)); initializeManager(); List<IngestSourceCandidate> candidates = sourceMan.listCandidates(destPid); assertEquals(2, candidates.size()); IngestSourceCandidate candidate1 = findCandidateByPath("bag_with_files", candidates); assertBagDetails(candidate1, "testsource", "bag_with_files"); IngestSourceCandidate candidate2 = findCandidateByPath("second_bag", candidates); assertBagDetails(candidate2, "testsource2", "second_bag"); }
@Test public void testListCandidatesNoMatchingSource() throws Exception { addBagToSource(sourceFolderPath); PID anotherUnit = makePid(); configPath = createConfigFile(createBasicConfig("testsource", anotherUnit)); initializeManager(); List<IngestSourceCandidate> candidates = sourceMan.listCandidates(destPid); assertTrue("No candidates expected", candidates.isEmpty()); }