public File findCachedArtifact(LocatableEntity locatableEntity) { for (ArtifactLocator locator : locators) { File cachedArtifact = locator.findCachedArtifact(locatableEntity); if (cachedArtifact != null && cachedArtifact.exists()) return cachedArtifact; } return null; }
public File chooseExistingRoot(LocatableEntity locatableEntity) { for (ArtifactLocator locator : locators) { if (locator.directoryExists(locatableEntity)) { return locator.directoryFor(locatableEntity); } } return null; }
public void shouldFindArtifact() { when(artifactFactory.createArtifact( coord.getGroupId(), coord.getArtifactId(), coord.getVersion(), "", coord.getFileType())) .thenReturn(goodArtifact); try { assertSame(locator.getAbsolutePathToArtifact(coord), A_PATH); } catch (Exception e) { fail("Should not have thrown an exception."); } }
public void shouldThrowExceptionForInvalidFileType() { String badFileType = "jstestdriver-invalid-artifact"; when(artifactFactory.createArtifact( coord.getGroupId(), coord.getArtifactId(), coord.getVersion(), "", badFileType)) .thenReturn(badArtifact); when(coord.getFileType()).thenReturn(badFileType); try { locator.getAbsolutePathToArtifact(coord); fail("Should have thrown an exception for invalid artifactId"); } catch (ArtifactNotFoundException ignored) { } }
public void shouldThrowExceptionForInvalidGroupId() { String badGroupId = "com.google.jstestdriver.some.invalid.group"; when(artifactFactory.createArtifact( badGroupId, coord.getArtifactId(), coord.getVersion(), "", coord.getFileType())) .thenReturn(badArtifact); when(coord.getGroupId()).thenReturn(badGroupId); try { locator.getAbsolutePathToArtifact(coord); fail("Should have thrown an exception for invalid groupId"); } catch (ArtifactNotFoundException ignored) { } }