Search in sources :

Example 1 with HTTPResponse

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

the class HTTPValidationSteps method verifyThatAfterSecondsWasCalls.

@Then("^verify that after (\\d+) seconds there (?:were|was) (\\d+) calls?$")
public void verifyThatAfterSecondsWasCalls(int seconds, int calls) {
    clear();
    TestUtils.sleepIgnoreInterrupt((long) seconds * 1000);
    HTTPResponse r = HTTPUtils.doGetRequest("http://localhost:28080/events");
    Map<Long, String> events = new Gson().fromJson(r.getBody(), Map.class);
    assertThat(events).size().isEqualTo(calls);
}
Also used : HTTPResponse(io.syndesis.qe.utils.http.HTTPResponse) Gson(com.google.gson.Gson) Then(io.cucumber.java.en.Then)

Example 2 with HTTPResponse

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

the class ServiceNow method deleteIncident.

public static void deleteIncident(String sysId) {
    HTTPResponse r = HTTPUtils.doDeleteRequest(String.format("%s/%s", url, sysId), Headers.of("Authorization", "Basic " + Base64.getEncoder().encodeToString((userName + ":" + password).getBytes())));
    assertThat(r.getCode()).isEqualTo(204);
}
Also used : HTTPResponse(io.syndesis.qe.utils.http.HTTPResponse)

Example 3 with HTTPResponse

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

the class ServiceNow method getFilteredIncidents.

public static List<Incident> getFilteredIncidents(String filter, int limit) {
    String getUrl = url + "?sysparm_limit=" + limit;
    if (filter != null) {
        try {
            getUrl += "&sysparm_query=" + URLEncoder.encode(filter, "UTF-8");
        } catch (UnsupportedEncodingException e) {
        // this won't happen
        }
    }
    HTTPResponse r = HTTPUtils.doGetRequest(getUrl, Headers.of("Authorization", "Basic " + Base64.getEncoder().encodeToString((userName + ":" + password).getBytes())));
    assertThat(r.getCode()).isEqualTo(200);
    String responseBody = r.getBody();
    return parseResponse(responseBody);
}
Also used : HTTPResponse(io.syndesis.qe.utils.http.HTTPResponse) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 4 with HTTPResponse

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

the class ServiceNow method createIncident.

public static Incident createIncident(Incident i) {
    String json = getIncidentJson(i);
    log.debug(String.format("Sending incident Json: %s", json));
    HTTPResponse r = HTTPUtils.doPostRequest(url, json, "application/json", Headers.of("Authorization", "Basic " + Base64.getEncoder().encodeToString((userName + ":" + password).getBytes())));
    assertThat(r.getCode()).isEqualTo(201);
    return getIncidentFromResponse(r);
}
Also used : HTTPResponse(io.syndesis.qe.utils.http.HTTPResponse)

Example 5 with HTTPResponse

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

the class ODataSteps method oDataServiceDoesntContain.

@Then("^.*check that entity \"([^\"]*)\" is not present in \"([^\"]*)\" collection on OData( V2)? service$")
public void oDataServiceDoesntContain(final String entityKey, final String collection, String v2) {
    HTTPResponse response = HTTPUtils.doGetRequest((v2 != null && !v2.isEmpty() ? ODataUtils.getCurrentV2Url() : ODataUtils.getV4OpenshiftRoute()) + collection + "(" + entityKey + ")");
    assertThat(response.getCode()).isEqualTo(404);
}
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