use of alien4cloud.model.application.ApplicationVersion in project alien4cloud by alien4cloud.
the class ApplicationVersionServiceTest method versionShouldNotBeDeployedWhenNoDeployment.
@Test
public void versionShouldNotBeDeployedWhenNoDeployment() {
dao.delete(Deployment.class, QueryBuilders.matchAllQuery());
// Check is now performed on application versions
ApplicationVersion applicationVersion = createApplicationVersion();
// this is supposed to find if a matching deployment object exists in ES.
Assert.assertFalse(appVersionSrv.isApplicationVersionDeployed(applicationVersion));
}
use of alien4cloud.model.application.ApplicationVersion in project alien4cloud by alien4cloud.
the class ApplicationVersionServiceTest method versionBeDeployed.
@Test
public void versionBeDeployed() {
dao.delete(Deployment.class, QueryBuilders.matchAllQuery());
ApplicationVersion applicationVersion = createApplicationVersion();
Deployment deployment = new Deployment();
deployment.setId(UUID.randomUUID().toString());
deployment.setVersionId("1.0.0-SNAPSHOT");
deployment.setEndDate(null);
dao.save(deployment);
// this is supposed to find if a matching deployment object exists in ES.
Assert.assertTrue(appVersionSrv.isApplicationVersionDeployed(applicationVersion));
}
use of alien4cloud.model.application.ApplicationVersion in project alien4cloud by alien4cloud.
the class ApplicationVersionServiceTest method versionShouldNotBeDeployedDeploymentComplete.
@Test
public void versionShouldNotBeDeployedDeploymentComplete() {
dao.delete(Deployment.class, QueryBuilders.matchAllQuery());
ApplicationVersion applicationVersion = createApplicationVersion();
Deployment deployment = new Deployment();
deployment.setId(UUID.randomUUID().toString());
deployment.setVersionId("1.0.0-SNAPSHOT");
deployment.setEndDate(new Date());
dao.save(deployment);
// this is supposed to find if a matching deployment object exists in ES.
Assert.assertFalse(appVersionSrv.isApplicationVersionDeployed(applicationVersion));
}
use of alien4cloud.model.application.ApplicationVersion in project alien4cloud by alien4cloud.
the class ApplicationVersionServiceTest method createApplicationVersion.
private ApplicationVersion createApplicationVersion() {
String version = "1.0.0-SNAPSHOT";
ApplicationVersion applicationVersion = new ApplicationVersion();
applicationVersion.setApplicationId("application");
applicationVersion.setVersion(version);
Map<String, ApplicationTopologyVersion> topologyVersionMap = Maps.newHashMap();
ApplicationTopologyVersion applicationTopologyVersion = new ApplicationTopologyVersion();
applicationTopologyVersion.setArchiveId(version);
topologyVersionMap.put(version, applicationTopologyVersion);
applicationTopologyVersion = new ApplicationTopologyVersion();
String devVersion = version + "-DEV";
applicationTopologyVersion.setArchiveId(devVersion);
topologyVersionMap.put(devVersion, applicationTopologyVersion);
applicationVersion.setTopologyVersions(topologyVersionMap);
dao.save(applicationVersion);
return applicationVersion;
}
use of alien4cloud.model.application.ApplicationVersion in project alien4cloud by alien4cloud.
the class ApplicationEnvironmentService method createApplicationEnvironment.
/**
* Create a new environment for a given application
*
* @param applicationId The id of the application.
* @param name The environment name.
* @param description The environment description.
* @param environmentType The type of environment.
* @return The newly created environment.
*/
public ApplicationEnvironment createApplicationEnvironment(String user, String applicationId, String name, String description, EnvironmentType environmentType, String topologyVersion) {
ApplicationVersion applicationVersion = applicationVersionService.getOrFailByArchiveId(Csar.createId(applicationId, topologyVersion));
if (!applicationVersion.getApplicationId().equals(applicationId)) {
throw new IllegalArgumentException("The topology version with id <" + topologyVersion + "> is not a topology of a version of the application with id <" + applicationId + ">");
}
// unique app env name for a given app
ensureNameUnicity(applicationId, name);
ApplicationEnvironment applicationEnvironment = new ApplicationEnvironment();
applicationEnvironment.setId(UUID.randomUUID().toString());
applicationEnvironment.setName(name);
applicationEnvironment.setDescription(description);
applicationEnvironment.setEnvironmentType(environmentType);
applicationEnvironment.setApplicationId(applicationId);
applicationEnvironment.setVersion(applicationVersion.getVersion());
applicationEnvironment.setTopologyVersion(topologyVersion);
Map<String, Set<String>> userRoles = Maps.newHashMap();
userRoles.put(user, Sets.newHashSet(ApplicationEnvironmentRole.DEPLOYMENT_MANAGER.toString()));
applicationEnvironment.setUserRoles(userRoles);
alienDAO.save(applicationEnvironment);
resourceUpdateInterceptor.runOnNewEnvironment(applicationEnvironment);
return applicationEnvironment;
}
Aggregations