Search in sources :

Example 1 with NodeInstanceDTO

use of alien4cloud.rest.service.model.NodeInstanceDTO in project alien4cloud by alien4cloud.

the class ServiceStepDefinitions method iSetThePropertyToForTheService.

@And("^I set the property \"([^\"]*)\" to \"([^\"]*)\" for the service \"([^\"]*)\"$")
public void iSetThePropertyToForTheService(String propertyName, String propertyValue, String serviceName) throws Throwable {
    String serviceId = Context.getInstance().getServiceId(serviceName);
    PatchServiceResourceRequest request = new PatchServiceResourceRequest();
    NodeInstanceDTO nodeInstance = new NodeInstanceDTO();
    nodeInstance.setProperties(Maps.newHashMap());
    nodeInstance.getProperties().put(propertyName, new ScalarPropertyValue(propertyValue));
    request.setNodeInstance(nodeInstance);
    Context.getInstance().registerRestResponse(Context.getRestClientInstance().patchJSon("/rest/v1/services/" + serviceId, JsonUtil.toString(request)));
}
Also used : NodeInstanceDTO(alien4cloud.rest.service.model.NodeInstanceDTO) PatchServiceResourceRequest(alien4cloud.rest.service.model.PatchServiceResourceRequest) TestUtils.nullAsString(alien4cloud.it.utils.TestUtils.nullAsString) ScalarPropertyValue(org.alien4cloud.tosca.model.definitions.ScalarPropertyValue) And(cucumber.api.java.en.And)

Example 2 with NodeInstanceDTO

use of alien4cloud.rest.service.model.NodeInstanceDTO in project alien4cloud by alien4cloud.

the class ServiceStepDefinitions method iStartTheService.

@And("^I (successfully\\s)?start the service \"([^\"]*)\"$")
public void iStartTheService(String successfully, String serviceName) throws Throwable {
    String serviceId = Context.getInstance().getServiceId(serviceName);
    PatchServiceResourceRequest request = new PatchServiceResourceRequest();
    NodeInstanceDTO nodeInstance = new NodeInstanceDTO();
    nodeInstance.setAttributeValues(Maps.newHashMap());
    nodeInstance.getAttributeValues().put("state", "started");
    request.setNodeInstance(nodeInstance);
    Context.getInstance().registerRestResponse(Context.getRestClientInstance().patchJSon("/rest/v1/services/" + serviceId, JsonUtil.toString(request)));
    CommonStepDefinitions.validateIfNeeded(StringUtils.isNotBlank(successfully));
}
Also used : NodeInstanceDTO(alien4cloud.rest.service.model.NodeInstanceDTO) PatchServiceResourceRequest(alien4cloud.rest.service.model.PatchServiceResourceRequest) TestUtils.nullAsString(alien4cloud.it.utils.TestUtils.nullAsString) And(cucumber.api.java.en.And)

Aggregations

TestUtils.nullAsString (alien4cloud.it.utils.TestUtils.nullAsString)2 NodeInstanceDTO (alien4cloud.rest.service.model.NodeInstanceDTO)2 PatchServiceResourceRequest (alien4cloud.rest.service.model.PatchServiceResourceRequest)2 And (cucumber.api.java.en.And)2 ScalarPropertyValue (org.alien4cloud.tosca.model.definitions.ScalarPropertyValue)1