### Question:
PomManagementServiceImpl implements PomManagementService { public Collection<Pom> getPoms() { updatePomCache(); return new ArrayList<Pom>(pomMap.values()); }  Pom getFocusedModule(); String getFocusedModuleName(); Pom getModuleForFileIdentifier(final String fileIdentifier); Collection<String> getModuleNames(); Pom getPomFromModuleName(final String moduleName); Pom getPomFromPath(final String pomPath); Collection<Pom> getPoms(); Pom getRootPom(); void setFocusedModule(final Pom focusedModule); FileMonitorService getFileMonitorService(); PomFactory getPomFactory(); FileManager getFileManager(); MetadataService getMetadataService(); MetadataDependencyRegistry getMetadataDependencyRegistry(); Shell getShell();  }### Answer:
@Test public void testGetPomOfSingleModuleProjectWhenParentHasNoRelativePath() throws Exception { setUpWorkingDirectory("single"); final String canonicalPath = getCanonicalPath("single/pom.xml"); when(mockFileMonitorService.getDirtyFiles(PomManagementServiceImpl.class.getName())) .thenReturn(Arrays.asList(canonicalPath)); final Pom mockPom = getMockPom(ROOT_MODULE_NAME, canonicalPath); final Collection<Pom> poms = service.getPoms(); assertEquals(1, poms.size()); assertEquals(mockPom, poms.iterator().next()); verifyProjectMetadataNotification(ROOT_MODULE_NAME); }
@Test public void testGetPomsOfMultiModuleProjectWhenParentAndChildAreDirty() throws Exception { setUpWorkingDirectory("multi"); final String rootPom = "multi/pom.xml"; final String rootPomCanonicalPath = getCanonicalPath(rootPom); final String childPom = "multi/foo-child/pom.xml"; final String childPomCanonicalPath = getCanonicalPath(childPom); final Collection<String> dirtyFiles = Arrays.asList(rootPomCanonicalPath, childPomCanonicalPath); when(mockFileMonitorService.getDirtyFiles(PomManagementServiceImpl.class.getName())) .thenReturn(dirtyFiles); final Pom mockRootPom = getMockPom(ROOT_MODULE_NAME, rootPomCanonicalPath); final String childModuleName = "foo-child"; final Pom mockChildPom = getMockPom(childModuleName, childPomCanonicalPath); when(mockFileManager.getInputStream(rootPomCanonicalPath)).thenReturn( getClass().getResourceAsStream(rootPom)); when(mockFileManager.getInputStream(childPomCanonicalPath)).thenReturn( getClass().getResourceAsStream(childPom)); final Collection<Pom> poms = service.getPoms(); final Collection<Pom> expectedPoms = Arrays.asList(mockRootPom, mockChildPom); assertEquals(expectedPoms.size(), poms.size()); assertTrue(poms.containsAll(expectedPoms)); verifyProjectMetadataNotification(ROOT_MODULE_NAME, childModuleName); }
@Test public void testGetPomsWhenNoPomsAreDirty() { final Collection<String> dirtyFiles = Arrays.asList("not-a-pom.txt"); when(mockFileMonitorService.getDirtyFiles(PomManagementServiceImpl.class.getName())) .thenReturn(dirtyFiles); final Collection<Pom> poms = service.getPoms(); assertEquals(0, poms.size()); }
@Test public void testGetPomsWhenOneEmptyPomIsDirty() throws Exception { final Collection<String> dirtyFiles = Arrays.asList(getCanonicalPath("empty/pom.xml")); when(mockFileMonitorService.getDirtyFiles(PomManagementServiceImpl.class.getName())) .thenReturn(dirtyFiles); final Collection<Pom> poms = service.getPoms(); assertEquals(0, poms.size()); }
@Test public void testGetPomsWhenOneNonExistantPomIsDirty() { final Collection<String> dirtyFiles = Arrays.asList("/users/jbloggs/clinic/pom.xml"); when(mockFileMonitorService.getDirtyFiles(PomManagementServiceImpl.class.getName())) .thenReturn(dirtyFiles); final Collection<Pom> poms = service.getPoms(); assertEquals(0, poms.size()); }