Search in sources :

Example 46 with ArtifactVersion

use of co.cask.cdap.api.artifact.ArtifactVersion in project cdap by caskdata.

the class ArtifactRangeTest method testIsInRange.

@Test
public void testIsInRange() {
    ArtifactRange range = new ArtifactRange(NamespaceId.DEFAULT.getNamespace(), "test", new ArtifactVersion("1.0.0"), new ArtifactVersion("2.0.0"));
    Assert.assertFalse(range.versionIsInRange(new ArtifactVersion("0.0.9")));
    Assert.assertFalse(range.versionIsInRange(new ArtifactVersion("0.9.0")));
    Assert.assertFalse(range.versionIsInRange(new ArtifactVersion("0.9")));
    // 1 < 1.0 < 1.0.0-SNAPSHOT < 1.0.0
    Assert.assertFalse(range.versionIsInRange(new ArtifactVersion("1")));
    Assert.assertFalse(range.versionIsInRange(new ArtifactVersion("1.0")));
    Assert.assertFalse(range.versionIsInRange(new ArtifactVersion("1.0.0-SNAPSHOT")));
    Assert.assertTrue(range.versionIsInRange(new ArtifactVersion("1.0.0")));
    Assert.assertTrue(range.versionIsInRange(new ArtifactVersion("1.0.1-SNAPSHOT")));
    Assert.assertTrue(range.versionIsInRange(new ArtifactVersion("1.0.1")));
    Assert.assertTrue(range.versionIsInRange(new ArtifactVersion("1.1.0")));
    // 2 < 2.0 < 2.0.0-SNAPSHOT < 2.0.0
    Assert.assertTrue(range.versionIsInRange(new ArtifactVersion("2")));
    Assert.assertTrue(range.versionIsInRange(new ArtifactVersion("2.0")));
    Assert.assertTrue(range.versionIsInRange(new ArtifactVersion("2.0.0-SNAPSHOT")));
    Assert.assertFalse(range.versionIsInRange(new ArtifactVersion("2.0.0")));
    Assert.assertFalse(range.versionIsInRange(new ArtifactVersion("2.0.1")));
}
Also used : ArtifactVersion(co.cask.cdap.api.artifact.ArtifactVersion) ArtifactRange(co.cask.cdap.api.artifact.ArtifactRange) Test(org.junit.Test)

Example 47 with ArtifactVersion

use of co.cask.cdap.api.artifact.ArtifactVersion in project cdap by caskdata.

the class AppFabricTestHelper method deployApplicationWithManager.

public static ApplicationWithPrograms deployApplicationWithManager(Id.Namespace namespace, Class<?> appClass, Supplier<File> folderSupplier, Config config) throws Exception {
    ensureNamespaceExists(namespace.toEntityId());
    Location deployedJar = createAppJar(appClass, folderSupplier);
    ArtifactVersion artifactVersion = new ArtifactVersion(String.format("1.0.%d", System.currentTimeMillis()));
    ArtifactId artifactId = new ArtifactId(appClass.getSimpleName(), artifactVersion, ArtifactScope.USER);
    ArtifactDescriptor artifactDescriptor = new ArtifactDescriptor(artifactId, deployedJar);
    ArtifactRepository artifactRepository = getInjector().getInstance(ArtifactRepository.class);
    artifactRepository.addArtifact(Artifacts.toArtifactId(namespace.toEntityId(), artifactId).toId(), new File(deployedJar.toURI()));
    AppDeploymentInfo info = new AppDeploymentInfo(artifactDescriptor, namespace.toEntityId(), appClass.getName(), null, null, config == null ? null : new Gson().toJson(config));
    return getLocalManager().deploy(info).get();
}
Also used : ArtifactVersion(co.cask.cdap.api.artifact.ArtifactVersion) ArtifactId(co.cask.cdap.api.artifact.ArtifactId) AppDeploymentInfo(co.cask.cdap.internal.app.deploy.pipeline.AppDeploymentInfo) ArtifactDescriptor(co.cask.cdap.internal.app.runtime.artifact.ArtifactDescriptor) Gson(com.google.gson.Gson) ArtifactRepository(co.cask.cdap.internal.app.runtime.artifact.ArtifactRepository) File(java.io.File) Location(org.apache.twill.filesystem.Location)

Example 48 with ArtifactVersion

use of co.cask.cdap.api.artifact.ArtifactVersion in project cdap by caskdata.

the class IntegrationTestManager method addPluginArtifact.

@Override
public ArtifactManager addPluginArtifact(ArtifactId artifactId, ArtifactId parent, @Nullable Set<PluginClass> additionalPlugins, Class<?> pluginClass, Class<?>... pluginClasses) throws Exception {
    Set<ArtifactRange> parents = new HashSet<>();
    parents.add(new ArtifactRange(parent.getParent().getNamespace(), parent.getArtifact(), new ArtifactVersion(parent.getVersion()), true, new ArtifactVersion(parent.getVersion()), true));
    addPluginArtifact(artifactId, parents, additionalPlugins, pluginClass, pluginClasses);
    return new RemoteArtifactManager(clientConfig, restClient, artifactId);
}
Also used : ArtifactVersion(co.cask.cdap.api.artifact.ArtifactVersion) RemoteArtifactManager(co.cask.cdap.test.remote.RemoteArtifactManager) ArtifactRange(co.cask.cdap.api.artifact.ArtifactRange) HashSet(java.util.HashSet)

Example 49 with ArtifactVersion

use of co.cask.cdap.api.artifact.ArtifactVersion in project cdap by caskdata.

the class AbstractTestManager method toRange.

private Set<ArtifactRange> toRange(ArtifactId parent) {
    Set<ArtifactRange> parents = new HashSet<>();
    parents.add(new ArtifactRange(parent.getParent().getNamespace(), parent.getArtifact(), new ArtifactVersion(parent.getVersion()), true, new ArtifactVersion(parent.getVersion()), true));
    return parents;
}
Also used : ArtifactVersion(co.cask.cdap.api.artifact.ArtifactVersion) ArtifactRange(co.cask.cdap.api.artifact.ArtifactRange) HashSet(java.util.HashSet)

Example 50 with ArtifactVersion

use of co.cask.cdap.api.artifact.ArtifactVersion in project cdap by caskdata.

the class UnitTestManager method addPluginArtifact.

@Override
public ArtifactManager addPluginArtifact(ArtifactId artifactId, ArtifactId parent, Class<?> pluginClass, Class<?>... pluginClasses) throws Exception {
    Set<ArtifactRange> parents = new HashSet<>();
    parents.add(new ArtifactRange(parent.getParent().getNamespace(), parent.getArtifact(), new ArtifactVersion(parent.getVersion()), true, new ArtifactVersion(parent.getVersion()), true));
    addPluginArtifact(artifactId, parents, pluginClass, pluginClasses);
    return artifactManagerFactory.create(artifactId);
}
Also used : ArtifactVersion(co.cask.cdap.api.artifact.ArtifactVersion) ArtifactRange(co.cask.cdap.api.artifact.ArtifactRange) HashSet(java.util.HashSet)

Aggregations

ArtifactVersion (co.cask.cdap.api.artifact.ArtifactVersion)50 Test (org.junit.Test)36 ArtifactRange (co.cask.cdap.api.artifact.ArtifactRange)33 Id (co.cask.cdap.proto.Id)24 NamespaceId (co.cask.cdap.proto.id.NamespaceId)24 ArtifactId (co.cask.cdap.api.artifact.ArtifactId)18 PluginClass (co.cask.cdap.api.plugin.PluginClass)15 ArtifactId (co.cask.cdap.proto.id.ArtifactId)14 PluginPropertyField (co.cask.cdap.api.plugin.PluginPropertyField)12 File (java.io.File)11 Manifest (java.util.jar.Manifest)10 HashSet (java.util.HashSet)9 ArtifactDescriptor (co.cask.cdap.internal.app.runtime.artifact.ArtifactDescriptor)8 ArtifactNotFoundException (co.cask.cdap.common.ArtifactNotFoundException)7 ArtifactSummary (co.cask.cdap.api.artifact.ArtifactSummary)6 ImmutableSet (com.google.common.collect.ImmutableSet)6 Set (java.util.Set)6 Location (org.apache.twill.filesystem.Location)6 Map (java.util.Map)5 AppDeploymentInfo (co.cask.cdap.internal.app.deploy.pipeline.AppDeploymentInfo)4