Search in sources :

Example 51 with ArtifactRange

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
    }
}
Also used : ArtifactVersion(co.cask.cdap.api.artifact.ArtifactVersion) ArtifactRange(co.cask.cdap.api.artifact.ArtifactRange) NamespaceId(co.cask.cdap.proto.id.NamespaceId) ArtifactNotFoundException(co.cask.cdap.common.ArtifactNotFoundException) Test(org.junit.Test)

Aggregations

ArtifactRange (co.cask.cdap.api.artifact.ArtifactRange)51 ArtifactVersion (co.cask.cdap.api.artifact.ArtifactVersion)37 Test (org.junit.Test)34 NamespaceId (co.cask.cdap.proto.id.NamespaceId)23 ArtifactId (co.cask.cdap.proto.id.ArtifactId)20 PluginClass (co.cask.cdap.api.plugin.PluginClass)19 Id (co.cask.cdap.common.id.Id)15 Manifest (java.util.jar.Manifest)13 PluginPropertyField (co.cask.cdap.api.plugin.PluginPropertyField)12 File (java.io.File)12 HashSet (java.util.HashSet)10 ArtifactNotFoundException (co.cask.cdap.common.ArtifactNotFoundException)9 ImmutableSet (com.google.common.collect.ImmutableSet)8 Set (java.util.Set)8 ArtifactId (co.cask.cdap.api.artifact.ArtifactId)7 PluginNotExistsException (co.cask.cdap.internal.app.runtime.plugin.PluginNotExistsException)7 ApplicationClass (co.cask.cdap.api.artifact.ApplicationClass)6 InvalidArtifactException (co.cask.cdap.common.InvalidArtifactException)6 IOException (java.io.IOException)6 ArtifactSummary (co.cask.cdap.api.artifact.ArtifactSummary)5