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