Search in sources :

Example 51 with When

use of cucumber.api.java.en.When in project alien4cloud by alien4cloud.

the class RuntimeStepDefinitions method iTriggerOnTheNodeTemplateTheCustomCommandOfTheInterfaceForApplicationUsingTheSecretProviderAndTheSecretCredentialsWithParameters.

/**
 * Attention: Should use the json format if the property value is a function when filling the parameters.
 *
 * @param nodeTemplateName
 * @param commandName
 * @param interfaceName
 * @param appName
 * @param secretProviderPluginName
 * @param secretCredentials
 * @param operationParameters
 * @throws Throwable
 */
@When("^I trigger on the node template \"([^\"]*)\" the custom command \"([^\"]*)\" of the interface \"([^\"]*)\" for application \"([^\"]*)\" using the secret provider \"([^\"]*)\" and the secret credentials \"([^\"]*)\" with parameters:$")
public void iTriggerOnTheNodeTemplateTheCustomCommandOfTheInterfaceForApplicationUsingTheSecretProviderAndTheSecretCredentialsWithParameters(String nodeTemplateName, String commandName, String interfaceName, String appName, String secretProviderPluginName, String secretCredentials, DataTable operationParameters) throws Throwable {
    OperationExecRequest commandRequest = new OperationExecRequest();
    commandRequest.setNodeTemplateName(nodeTemplateName);
    commandRequest.setInterfaceName(interfaceName);
    commandRequest.setOperationName(commandName);
    commandRequest.setApplicationEnvironmentId(Context.getInstance().getDefaultApplicationEnvironmentId(appName));
    if (StringUtils.isNotBlank(secretProviderPluginName) && StringUtils.isNotBlank(secretCredentials)) {
        commandRequest.setSecretProviderPluginName(secretProviderPluginName);
        Map<String, String> credentials = Splitter.on(",").withKeyValueSeparator(":").split(secretCredentials.replaceAll("\\s+", ""));
        commandRequest.setSecretProviderCredentials(credentials);
    }
    if (operationParameters != null) {
        Map<String, Object> parameters = Maps.newHashMap();
        for (List<String> operationParameter : operationParameters.raw()) {
            // check if the property is a function
            if (PropertyUtils.isFunction(ToscaFunctionConstants.GET_SECRET, operationParameter.get(1))) {
                parameters.put(operationParameter.get(0), PropertyUtils.toFunctionValue(operationParameter.get(1)));
            } else {
                parameters.put(operationParameter.get(0), operationParameter.get(1));
            }
        }
        commandRequest.setParameters(parameters);
    }
    String jSon = JsonUtil.toString(commandRequest);
    String restResponse = Context.getRestClientInstance().postJSon("/rest/v1/runtime/" + Context.getInstance().getApplication().getId() + "/operations/", jSon);
    Context.getInstance().registerRestResponse(restResponse);
}
Also used : OperationExecRequest(alien4cloud.paas.model.OperationExecRequest) When(cucumber.api.java.en.When)

Example 52 with When

use of cucumber.api.java.en.When in project alien4cloud by alien4cloud.

the class AuthenticationStepDefinitions method I_update_user_s_fields.

@When("^I update \"([^\"]*)\" user's fields:$")
public void I_update_user_s_fields(String username, List<Entry> fields) throws Throwable {
    Map<String, String> fieldsMap = Maps.newHashMap();
    for (Entry field : fields) {
        fieldsMap.put(field.getName(), field.getValue());
    }
    String resp = Context.getRestClientInstance().putJSon("/rest/v1/users/" + username, JsonUtil.toString(fieldsMap));
    System.out.println(resp);
    Context.getInstance().registerRestResponse(resp);
}
Also used : Entry(alien4cloud.it.Entry) When(cucumber.api.java.en.When)

Example 53 with When

use of cucumber.api.java.en.When in project alien4cloud by alien4cloud.

the class AuthenticationStepDefinitions method I_create_a_new_user_with_name_and_password_in_the_system.

@When("^I create a new user with username \"([^\"]*)\" and password \"([^\"]*)\" in the system$")
public void I_create_a_new_user_with_name_and_password_in_the_system(String username, String password) throws Throwable {
    CreateUserRequest request = new CreateUserRequest();
    request.setUsername(username);
    request.setPassword(password);
    request.setEmail(username + "@alien4cloud.org");
    Context.getInstance().registerRestResponse(Context.getRestClientInstance().postJSon("/rest/v1/users/", JsonUtil.toString(request)));
}
Also used : CreateUserRequest(alien4cloud.security.users.rest.CreateUserRequest) When(cucumber.api.java.en.When)

Example 54 with When

use of cucumber.api.java.en.When in project alien4cloud by alien4cloud.

the class ManagedServiceStepDefinitions method iDeleteTheServiceRelatedToTheApplicationEnvironment.

@When("^I (successfully\\s)?delete the service related to the application \"([^\"]*)\", environment \"([^\"]*)\"$")
public void iDeleteTheServiceRelatedToTheApplicationEnvironment(String successfully, String applicationName, String environmentName) throws Throwable {
    String applicationId = Context.getInstance().getApplicationId(applicationName);
    String environmentId = Context.getInstance().getApplicationEnvironmentId(applicationName, environmentName);
    Context.getInstance().registerRestResponse(getRestClientInstance().delete(String.format("/rest/applications/%s/environments/%s/services", applicationId, nullAsString(environmentId))));
    CommonStepDefinitions.validateIfNeeded(StringUtils.isNotBlank(successfully));
}
Also used : TestUtils.nullAsString(alien4cloud.it.utils.TestUtils.nullAsString) When(cucumber.api.java.en.When)

Example 55 with When

use of cucumber.api.java.en.When in project alien4cloud by alien4cloud.

the class ServiceStepDefinitions method createService.

@When("^I (successfully\\s)?create a service with name \"(.*?)\", version \"(.*?)\", type \"(.*?)\", archive version \"(.*?)\"$")
public void createService(String successfully, String serviceName, String serviceVersion, String type, String archiveVersion) throws Throwable {
    CreateServiceResourceRequest request = new CreateServiceResourceRequest(nullable(serviceName), nullable(serviceVersion), nullable(type), nullable(archiveVersion));
    Context.getInstance().registerRestResponse(getRestClientInstance().postJSon("/rest/v1/services/", JsonUtil.toString(request)));
    CommonStepDefinitions.validateIfNeeded(StringUtils.isNotBlank(successfully));
    try {
        LAST_CREATED_ID = JsonUtil.read(Context.getInstance().getRestResponse(), String.class).getData();
        Context.getInstance().registerService(LAST_CREATED_ID, serviceName);
    } catch (Throwable t) {
    }
}
Also used : CreateServiceResourceRequest(alien4cloud.rest.service.model.CreateServiceResourceRequest) When(cucumber.api.java.en.When)

Aggregations

When (cucumber.api.java.en.When)148 TestUtils.nullAsString (alien4cloud.it.utils.TestUtils.nullAsString)12 Application (alien4cloud.model.application.Application)10 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)6 StandardEvaluationContext (org.springframework.expression.spel.support.StandardEvaluationContext)6 ComponentSearchRequest (alien4cloud.rest.component.ComponentSearchRequest)5 FilteredSearchRequest (alien4cloud.rest.model.FilteredSearchRequest)5 TopologyDTO (alien4cloud.topology.TopologyDTO)4 Path (java.nio.file.Path)4 List (java.util.List)4 UiApplicationDriver (org.activityinfo.test.driver.UiApplicationDriver)4 PivotTableEditor (org.activityinfo.test.pageobject.web.reports.PivotTableEditor)4 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)4 WebElement (org.openqa.selenium.WebElement)4 MvcResult (org.springframework.test.web.servlet.MvcResult)4 NotFoundException (alien4cloud.exception.NotFoundException)3 Context (alien4cloud.it.Context)3 MetaPropConfiguration (alien4cloud.model.common.MetaPropConfiguration)3 DeployApplicationRequest (alien4cloud.rest.application.model.DeployApplicationRequest)3 UpdateDeploymentTopologyRequest (alien4cloud.rest.application.model.UpdateDeploymentTopologyRequest)3