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