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