Search in sources :

Example 16 with When

use of cucumber.api.java.en.When in project spring-rest-security-boilerplate by springboilerplate.

the class Tests method userLogin.

@When("^Successful login username and password are \"([^\"]*)\" AND \"(.*?)\"$")
public void userLogin(String username, String password) throws Throwable {
    MvcResult mvcResult;
    loginUser.setUsername(username);
    loginUser.setPassword(password);
    final String personDTOJson = jsonTester.write(loginUser).getJson();
    mvcResult = mockMvc.perform(post("/login").content(personDTOJson).contentType(APPLICATION_JSON_UTF8)).andExpect(status().isOk()).andDo(MockMvcResultHandlers.print()).andReturn();
    bearerToken = mvcResult.getResponse().getHeader("Authorization");
    System.out.println("Value is =" + bearerToken);
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) When(cucumber.api.java.en.When)

Example 17 with When

use of cucumber.api.java.en.When in project tutorials by eugenp.

the class StepDefinition method usersUploadDataOnAProject.

@When("^users upload data on a project$")
public void usersUploadDataOnAProject() throws IOException {
    wireMockServer.start();
    configureFor("localhost", 8080);
    stubFor(post(urlEqualTo(CREATE_PATH)).withHeader("content-type", equalTo(APPLICATION_JSON)).withRequestBody(containing("testing-framework")).willReturn(aResponse().withStatus(200)));
    HttpPost request = new HttpPost("http://localhost:8080/create");
    StringEntity entity = new StringEntity(jsonString);
    request.addHeader("content-type", APPLICATION_JSON);
    request.setEntity(entity);
    HttpResponse response = httpClient.execute(request);
    assertEquals(200, response.getStatusLine().getStatusCode());
    verify(postRequestedFor(urlEqualTo(CREATE_PATH)).withHeader("content-type", equalTo(APPLICATION_JSON)));
    wireMockServer.stop();
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) HttpResponse(org.apache.http.HttpResponse) When(cucumber.api.java.en.When)

Example 18 with When

use of cucumber.api.java.en.When in project tutorials by eugenp.

the class StepDefinition method usersGetInformationOnAProject.

@When("^users want to get information on the (.+) project$")
public void usersGetInformationOnAProject(String projectName) throws IOException {
    wireMockServer.start();
    configureFor("localhost", 8080);
    stubFor(get(urlEqualTo("/projects/cucumber")).withHeader("accept", equalTo(APPLICATION_JSON)).willReturn(aResponse().withBody(jsonString)));
    HttpGet request = new HttpGet("http://localhost:8080/projects/" + projectName.toLowerCase());
    request.addHeader("accept", APPLICATION_JSON);
    HttpResponse httpResponse = httpClient.execute(request);
    String responseString = convertResponseToString(httpResponse);
    assertThat(responseString, containsString("\"testing-framework\": \"cucumber\""));
    assertThat(responseString, containsString("\"website\": \"cucumber.io\""));
    verify(getRequestedFor(urlEqualTo("/projects/cucumber")).withHeader("accept", equalTo(APPLICATION_JSON)));
    wireMockServer.stop();
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) When(cucumber.api.java.en.When)

Example 19 with When

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

the class EditorStepDefs method i_Recover_The_Topology.

@When("^I recover the topology$")
public void i_Recover_The_Topology() throws Throwable {
    thrownException = null;
    try {
        TopologyDTO dto = editorService.recover(topologyIds.getLast(), topologyIdToLastOperationId.get(topologyIds.getLast()));
        topologyIdToLastOperationId.put(topologyIds.getLast(), null);
        dtoEvaluationContext = new StandardEvaluationContext(dto);
        topologyEvaluationContext = new StandardEvaluationContext(dto.getTopology());
    } catch (Exception e) {
        log.error("Error occurred when recovering the topology", e);
        thrownException = e;
        exceptionEvaluationContext = new StandardEvaluationContext(e);
    }
}
Also used : StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) TopologyDTO(alien4cloud.topology.TopologyDTO) NotFoundException(alien4cloud.exception.NotFoundException) IOException(java.io.IOException) When(cucumber.api.java.en.When)

Example 20 with When

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

the class EditorStepDefs method I_get_the_edited_topology.

@When("^I get the edited topology$")
public void I_get_the_edited_topology() {
    thrownException = null;
    try {
        editionContextManager.init(topologyIds.getLast());
        Topology topology = editionContextManager.getTopology();
        topologyEvaluationContext = new StandardEvaluationContext(topology);
    } catch (Exception e) {
        log.error("Exception ocrured while getting the topology", e);
        thrownException = e;
        exceptionEvaluationContext = new StandardEvaluationContext(e);
    } finally {
        editionContextManager.destroy();
    }
}
Also used : StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) Topology(org.alien4cloud.tosca.model.templates.Topology) NotFoundException(alien4cloud.exception.NotFoundException) IOException(java.io.IOException) When(cucumber.api.java.en.When)

Aggregations

When (cucumber.api.java.en.When)161 TestUtils.nullAsString (alien4cloud.it.utils.TestUtils.nullAsString)12 Application (alien4cloud.model.application.Application)10 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)9 Response (com.jayway.restassured.response.Response)7 IOException (java.io.IOException)6 List (java.util.List)6 StandardEvaluationContext (org.springframework.expression.spel.support.StandardEvaluationContext)6 FilteredSearchRequest (alien4cloud.rest.model.FilteredSearchRequest)5 Then (cucumber.api.java.en.Then)5 Collectors (java.util.stream.Collectors)5 Action (org.talend.dataprep.helper.api.Action)5 ComponentSearchRequest (alien4cloud.rest.component.ComponentSearchRequest)4 TopologyDTO (alien4cloud.topology.TopologyDTO)4 Path (java.nio.file.Path)4 HashMap (java.util.HashMap)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