use of co.cask.cdap.api.artifact.ArtifactRange in project cdap by caskdata.
the class ArtifactStoreTest method testGetNonexistantArtifact.
@Test
public void testGetNonexistantArtifact() throws IOException {
NamespaceId namespace = Ids.namespace("ns1");
// no artifacts in a namespace should return an empty collection
Assert.assertTrue(artifactStore.getArtifacts(namespace).isEmpty());
// no artifacts in range should return an empty collection
ArtifactRange range = new ArtifactRange(namespace.getNamespace(), "something", new ArtifactVersion("1.0.0"), new ArtifactVersion("2.0.0"));
Assert.assertTrue(artifactStore.getArtifacts(range, Integer.MAX_VALUE, ArtifactSortOrder.UNORDERED).isEmpty());
// no artifact by namespace and artifact name should throw an exception
try {
artifactStore.getArtifacts(namespace, "something", Integer.MAX_VALUE, ArtifactSortOrder.UNORDERED);
Assert.fail();
} catch (ArtifactNotFoundException e) {
// expected
}
// no artifact by namespace, artifact name, and version should throw an exception
try {
artifactStore.getArtifact(Id.Artifact.from(Id.Namespace.fromEntityId(namespace), "something", "1.0.0"));
Assert.fail();
} catch (ArtifactNotFoundException e) {
// expected
}
}
Aggregations