Search in sources :

Example 1 with ApplicationVersion

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));
}
Also used : ApplicationVersion(alien4cloud.model.application.ApplicationVersion) Test(org.junit.Test)

Example 2 with 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));
}
Also used : ApplicationVersion(alien4cloud.model.application.ApplicationVersion) Deployment(alien4cloud.model.deployment.Deployment) Test(org.junit.Test)

Example 3 with 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));
}
Also used : ApplicationVersion(alien4cloud.model.application.ApplicationVersion) Deployment(alien4cloud.model.deployment.Deployment) Date(java.util.Date) Test(org.junit.Test)

Example 4 with 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;
}
Also used : ApplicationVersion(alien4cloud.model.application.ApplicationVersion) ApplicationTopologyVersion(alien4cloud.model.application.ApplicationTopologyVersion)

Example 5 with 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;
}
Also used : ApplicationVersion(alien4cloud.model.application.ApplicationVersion) Set(java.util.Set) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment)

Aggregations

ApplicationVersion (alien4cloud.model.application.ApplicationVersion)19 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)6 ApiOperation (io.swagger.annotations.ApiOperation)6 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)6 ApplicationTopologyVersion (alien4cloud.model.application.ApplicationTopologyVersion)5 Audit (alien4cloud.audit.annotation.Audit)4 Test (org.junit.Test)4 Application (alien4cloud.model.application.Application)3 Deployment (alien4cloud.model.deployment.Deployment)3 AuthorizationServiceException (org.springframework.security.access.AuthorizationServiceException)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 Topology (org.alien4cloud.tosca.model.templates.Topology)2 TopologyVersionUpdated (alien4cloud.common.ResourceUpdateInterceptor.TopologyVersionUpdated)1 GetMultipleDataResult (alien4cloud.dao.model.GetMultipleDataResult)1 AlreadyExistException (alien4cloud.exception.AlreadyExistException)1 TestUtils.nullAsString (alien4cloud.it.utils.TestUtils.nullAsString)1 UpdateApplicationVersionException (alien4cloud.utils.version.UpdateApplicationVersionException)1 Date (java.util.Date)1 Set (java.util.Set)1 AfterApplicationTopologyVersionDeleted (org.alien4cloud.alm.events.AfterApplicationTopologyVersionDeleted)1