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")));
}
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();
}
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);
}
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;
}
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);
}
Aggregations