Search in sources :

Example 6 with HTTPResponse

use of io.syndesis.qe.utils.http.HTTPResponse in project syndesis-qe by syndesisio.

the class ODataSteps method checkEntityWithPropertyExists.

@Then("^.*validate that OData( V2)? service contains entity with \"([^\"]*)\":\"([^\"]*)\" property:value pair in \"([^\"]*)\" collection$")
public void checkEntityWithPropertyExists(String v2, String propertyName, String expectedValue, String entitySetName) {
    String route;
    if (v2 != null && !v2.isEmpty()) {
        route = ODataUtils.getCurrentV2Url();
    } else {
        route = ODataUtils.getV4OpenshiftRoute();
    }
    HTTPResponse response = HTTPUtils.doGetRequest(route + entitySetName);
    log.info("Checking if entity with " + propertyName + ":" + expectedValue + " property:value pair is present");
    if (v2 != null && !v2.isEmpty()) {
        // v2 service returns xml file
        assertThat(response.getBody()).contains(propertyName + ">" + expectedValue);
    } else {
        // v4 service returns json file
        assertThat(response.getBody()).contains("\"" + propertyName + "\":\"" + expectedValue + "\"");
    }
}
Also used : HTTPResponse(io.syndesis.qe.utils.http.HTTPResponse) Then(io.cucumber.java.en.Then)

Example 7 with HTTPResponse

use of io.syndesis.qe.utils.http.HTTPResponse in project syndesis-qe by syndesisio.

the class ODataSteps method insertEntityToODataService.

@When("^.*insert entity \"([^\"]*)\" into \"([^\"]*)\" collection on OData service$")
public void insertEntityToODataService(final String entity, final String collection) {
    String requestBody = ODataUtils.readResourceFile(this.getClass().getClassLoader().getResource(entity));
    Headers headers = Headers.of("Content-Type", "application/json");
    HTTPResponse response = HTTPUtils.doPostRequest(ODataUtils.getV4OpenshiftRoute() + collection, requestBody, headers);
    assertThat(response.getCode()).isEqualTo(201);
    log.info("Entity from resource file " + entity + " succesfully inserted to sample OData service");
}
Also used : Headers(okhttp3.Headers) HTTPResponse(io.syndesis.qe.utils.http.HTTPResponse) When(io.cucumber.java.en.When)

Example 8 with HTTPResponse

use of io.syndesis.qe.utils.http.HTTPResponse in project syndesis-qe by syndesisio.

the class PortForwardUtils method isWorking.

private static boolean isWorking() {
    HTTPResponse response = null;
    try {
        response = HTTPUtils.doGetRequest(CHECK_URL, null, false);
    } catch (Exception ex) {
        log.debug("Exception while waiting for port forward: " + ex);
    }
    log.debug("Wait for port-forward response code: " + (response == null ? -1 : response.getCode()));
    return response != null && response.getCode() == 200;
}
Also used : HTTPResponse(io.syndesis.qe.utils.http.HTTPResponse) IOException(java.io.IOException)

Example 9 with HTTPResponse

use of io.syndesis.qe.utils.http.HTTPResponse in project syndesis-qe by syndesisio.

the class InvokeHttpRequest method invokeWebhookRequest.

private HTTPResponse invokeWebhookRequest(String nameOfIntegration, String token, String body) {
    log.debug("Body to set: " + body);
    String url = getUrlForWebhook(nameOfIntegration, token);
    log.info("WebHook URL: " + url);
    int beforeNumberOfMessages = integrationUtils.numberOfMessages(nameOfIntegration);
    HTTPResponse httpResponse = HTTPUtils.doPostRequest(url, body);
    integrationUtils.waitForMessage(nameOfIntegration, beforeNumberOfMessages + 1);
    return httpResponse;
}
Also used : HTTPResponse(io.syndesis.qe.utils.http.HTTPResponse)

Example 10 with HTTPResponse

use of io.syndesis.qe.utils.http.HTTPResponse in project syndesis-qe by syndesisio.

the class ODataSteps method oDataServiceContains.

@Then("^.*check that OData( V2)? \"([^\"]*)\" entity in \"([^\"]*)\" collection contains$")
public void oDataServiceContains(String v2, String entityKey, final String collection, DataTable table) {
    if (entityKey.matches("[A-Za-z]*")) {
        entityKey = "'" + entityKey + "'";
    }
    String route;
    if (v2 != null && !v2.isEmpty()) {
        route = ODataUtils.getCurrentV2Url();
    } else {
        route = ODataUtils.getV4OpenshiftRoute();
    }
    HTTPResponse response = HTTPUtils.doGetRequest(route + collection + "(" + entityKey + ")");
    assertThat(response.getCode()).isEqualTo(200);
    for (List<String> row : table.cells()) {
        assertThat(response.getBody()).contains(row.stream().map(s -> s == null ? "" : s).collect(Collectors.toList()));
    }
}
Also used : HTTPResponse(io.syndesis.qe.utils.http.HTTPResponse) Then(io.cucumber.java.en.Then)

Aggregations

HTTPResponse (io.syndesis.qe.utils.http.HTTPResponse)14 Then (io.cucumber.java.en.Then)6 Gson (com.google.gson.Gson)2 When (io.cucumber.java.en.When)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Headers (okhttp3.Headers)1