Search in sources :

Example 31 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class ApplicationStepDefinitions method doCreateApplication.

private void doCreateApplication(String name, String archiveName, String description, String topologyTemplateId, boolean register) throws IOException {
    CreateApplicationRequest request = new CreateApplicationRequest(archiveName, name, description, topologyTemplateId);
    Context.getInstance().registerRestResponse(getRestClientInstance().postJSon("/rest/v1/applications/", JsonUtil.toString(request)));
    // and rely on complete features.
    if (!register) {
        return;
    }
    try {
        // check the created application (topologyId)
        RestResponse<String> response = JsonUtil.read(Context.getInstance().getRestResponse(), String.class);
        String applicationJson = getRestClientInstance().get("/rest/v1/applications/" + response.getData());
        Application application = JsonUtil.read(applicationJson, Application.class).getData();
        if (application != null) {
            CURRENT_APPLICATION = application;
            CURRENT_APPLICATIONS.put(name, application);
            Context.getInstance().registerApplication(application);
            Context.getInstance().registerApplicationId(name, application.getId());
            setAppEnvironmentIdToContext(application.getName());
            setAppVersionIdToContext(application.getId());
            String topologyId = Csar.createId(application.getId(), VersionUtil.DEFAULT_VERSION_NAME);
            assertNotNull(topologyId);
            Context.getInstance().registerTopologyId(topologyId);
        }
    } catch (Throwable t) {
    }
}
Also used : CreateApplicationRequest(alien4cloud.rest.application.model.CreateApplicationRequest) TestUtils.nullAsString(alien4cloud.it.utils.TestUtils.nullAsString) Application(alien4cloud.model.application.Application)

Example 32 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class ApplicationStepDefinitions method There_is_a_application.

@Given("^There is a \"([^\"]*)\" application$")
public void There_is_a_application(String applicationName) throws Throwable {
    FilteredSearchRequest searchRequest = new FilteredSearchRequest(applicationName, 0, 50, null);
    String searchResponse = getRestClientInstance().postJSon("/rest/v1/applications/search", JsonUtil.toString(searchRequest));
    RestResponse<FacetedSearchResult> response = JsonUtil.read(searchResponse, FacetedSearchResult.class);
    boolean hasApplication = false;
    for (Object appAsObj : response.getData().getData()) {
        Application app = JsonUtil.readObject(JsonUtil.toString(appAsObj), Application.class);
        if (applicationName.equals(app.getName())) {
            hasApplication = true;
            CURRENT_APPLICATION = app;
        }
    }
    if (!hasApplication) {
        doCreateApplication(applicationName, appToArchName(applicationName), null, null, true);
    }
}
Also used : FilteredSearchRequest(alien4cloud.rest.model.FilteredSearchRequest) TestUtils.nullAsString(alien4cloud.it.utils.TestUtils.nullAsString) Application(alien4cloud.model.application.Application) FacetedSearchResult(alien4cloud.dao.model.FacetedSearchResult) Given(cucumber.api.java.en.Given)

Example 33 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class ApplicationStepDefinitions method I_retrieve_the_newly_created_application.

@When("^I retrieve the newly created application$")
public void I_retrieve_the_newly_created_application() throws Throwable {
    // App from context
    Application contextApp = Context.getInstance().getApplication();
    Context.getInstance().registerRestResponse(getRestClientInstance().get("/rest/v1/applications/" + contextApp.getId()));
}
Also used : Application(alien4cloud.model.application.Application) When(cucumber.api.java.en.When)

Example 34 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class ApplicationVersionStepDefinitions method I_search_for_application_versions.

@When("^I search for application versions$")
public void I_search_for_application_versions() throws Throwable {
    Application app = Context.getInstance().getApplication();
    FilteredSearchRequest request = new FilteredSearchRequest();
    request.setFrom(0);
    request.setSize(10);
    Context.getInstance().registerRestResponse(Context.getRestClientInstance().postJSon("/rest/v1/applications/" + app.getId() + "/versions/search", JsonUtil.toString(request)));
}
Also used : FilteredSearchRequest(alien4cloud.rest.model.FilteredSearchRequest) Application(alien4cloud.model.application.Application) When(cucumber.api.java.en.When)

Example 35 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class DeploymentTopologyStepDefinitions method iSelectTheFileFromTheCurrentTopologyArchiveForTheInputArtifact.

@When("^I select the file \"([^\"]*)\" from the current topology archive for the input artifact \"([^\"]*)\"$")
public void iSelectTheFileFromTheCurrentTopologyArchiveForTheInputArtifact(String fileRef, String inputArtifactName) throws Throwable {
    Application application = Context.getInstance().getApplication();
    String envId = Context.getInstance().getDefaultApplicationEnvironmentId(application.getName());
    String url = String.format("/rest/applications/%s/environments/%s/deployment-topology/inputArtifacts/%s/update", application.getId(), envId, inputArtifactName);
    DeploymentArtifact inputArtifact = new DeploymentArtifact();
    inputArtifact.setArchiveName(application.getId());
    inputArtifact.setArchiveVersion(TestUtils.getVersionFromId(Context.getInstance().getTopologyId()));
    inputArtifact.setArtifactRef(fileRef);
    inputArtifact.setArtifactRepository(ArtifactRepositoryConstants.ALIEN_TOPOLOGY_REPOSITORY);
    Context.getInstance().registerRestResponse(Context.getRestClientInstance().postJSon(url, JsonUtil.toString(inputArtifact)));
}
Also used : Application(alien4cloud.model.application.Application) DeploymentArtifact(org.alien4cloud.tosca.model.definitions.DeploymentArtifact) When(cucumber.api.java.en.When)

Aggregations

Application (alien4cloud.model.application.Application)103 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)45 ApiOperation (io.swagger.annotations.ApiOperation)43 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)39 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)38 Audit (alien4cloud.audit.annotation.Audit)28 List (java.util.List)14 Topology (org.alien4cloud.tosca.model.templates.Topology)14 Set (java.util.Set)12 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)11 RestResponse (alien4cloud.rest.model.RestResponse)11 Collectors (java.util.stream.Collectors)11 Map (java.util.Map)10 ApplicationEnvironmentService (alien4cloud.application.ApplicationEnvironmentService)9 ApplicationTopologyVersion (alien4cloud.model.application.ApplicationTopologyVersion)9 Arrays (java.util.Arrays)9 When (cucumber.api.java.en.When)8 Deployment (alien4cloud.model.deployment.Deployment)7 RestResponseBuilder (alien4cloud.rest.model.RestResponseBuilder)7 ApplicationEnvironmentAuthorizationDTO (alien4cloud.rest.orchestrator.model.ApplicationEnvironmentAuthorizationDTO)7