use of alien4cloud.rest.application.model.CreateApplicationRequest 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) {
}
}
Aggregations