Maven { public String findMavenIdFrom(String pomUrl) throws MavenIdNotFoundException { try { Document document = documentLoader.loadFromUrl(pomUrl); return findMavenId(document); } catch (DocumentNotLoadedException e) { throw new MavenIdNotFoundException("Can't find pom at " + pomUrl, e); } }  String findMavenIdFrom(String pomUrl); String findMavenIdFromContent(String pomContent);  }
@Test public void should_find_artifact_id() throws Exception { String pomUrl = fr.norad.visuwall.providers.common.ClasspathFiles.getAbsolutePathFile("pom-sample.xml"); Document document = new fr.norad.visuwall.providers.common.DocumentLoader().loadFromUrl(pomUrl); when(documentLoader.loadFromUrl(anyString())).thenReturn(document); String artifactId = maven.findMavenIdFrom("test-project"); assertEquals("fr.norad.visuwall:visuwall-hudsonclient", artifactId); }
@Test(expected = fr.norad.visuwall.providers.common.MavenIdNotFoundException.class) public void should_not_find_artifact_id() throws Exception { when(documentLoader.loadFromUrl(anyString())).thenThrow(new fr.norad.visuwall.providers.common.DocumentNotLoadedException("file not found", null)); maven.findMavenIdFrom("test-project"); }