Search in sources :

Example 21 with Call

use of com.coveros.selenified.services.Call in project selenified by Coveros.

the class ServicesIT method comparePostResponseDataTest.

@Test(groups = { "integration", "services", "httppost" }, description = "An integration test to verify the data from a post call")
public void comparePostResponseDataTest() {
    JsonObject request = new JsonObject();
    request.addProperty("title", "foo");
    request.addProperty("body", "bar");
    request.addProperty("userId", 2);
    JsonObject response = new JsonObject();
    response.addProperty("id", 101);
    response.addProperty("title", "foo");
    response.addProperty("body", "bar");
    response.addProperty("userId", 2);
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.post("posts/", new Request(request)).assertEquals(response);
    // verify no issues
    finish();
}
Also used : Call(com.coveros.selenified.services.Call) Request(com.coveros.selenified.services.Request) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 22 with Call

use of com.coveros.selenified.services.Call in project selenified by Coveros.

the class ServicesIT method compareDeleteResponseCode404Test.

@Test(groups = { "integration", "services", "httpdelete" }, description = "An integration test to verify the response code from a delete call")
public void compareDeleteResponseCode404Test() {
    JsonObject request = new JsonObject();
    request.addProperty("id", 1);
    request.addProperty("title", "foo1");
    request.addProperty("body", "bar");
    request.addProperty("userId", 5);
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.delete("post/", new Request(request)).assertEquals(404);
    // verify no issues
    finish();
}
Also used : Call(com.coveros.selenified.services.Call) Request(com.coveros.selenified.services.Request) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 23 with Call

use of com.coveros.selenified.services.Call in project selenified by Coveros.

the class ServicesIT method checkGetResponseContainsSingleObjectDataTest.

@Test(groups = { "integration", "services", "httpget" }, description = "An integration test to verify the data from a get call")
public void checkGetResponseContainsSingleObjectDataTest() {
    Map<String, String> responsePairs = new HashMap<>();
    responsePairs.put("userId", "1");
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.get("posts/6").assertContains(responsePairs);
    // verify no issues
    finish();
}
Also used : Call(com.coveros.selenified.services.Call) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 24 with Call

use of com.coveros.selenified.services.Call in project selenified by Coveros.

the class ServicesIT method comparePatchResponseDataTest.

@Test(groups = { "integration", "services", "httppatch" }, description = "An integration test to verify the data from a patch call")
public void comparePatchResponseDataTest() {
    JsonObject request = new JsonObject();
    request.addProperty("id", 4);
    request.addProperty("title", "foo1");
    request.addProperty("body", "bar");
    request.addProperty("userId", 4);
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.patch("posts/4", new Request(request)).assertEquals(request);
    // verify no issues
    finish();
}
Also used : Call(com.coveros.selenified.services.Call) Request(com.coveros.selenified.services.Request) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 25 with Call

use of com.coveros.selenified.services.Call in project selenified by Coveros.

the class ServicesIT method checkPatchResponseContainsMultipleDataTest.

@Test(groups = { "integration", "services", "httppatch" }, description = "An integration test to verify the data from a patch call")
public void checkPatchResponseContainsMultipleDataTest() {
    JsonObject request = new JsonObject();
    request.addProperty("id", 4);
    request.addProperty("title", "foo1");
    request.addProperty("body", "bar");
    request.addProperty("userId", 4);
    Map<String, String> responsePairs = new HashMap<>();
    responsePairs.put("userId", "4");
    responsePairs.put("title", "foo1");
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.patch("posts/4", new Request(request)).assertContains(responsePairs);
    // verify no issues
    finish();
}
Also used : Call(com.coveros.selenified.services.Call) HashMap(java.util.HashMap) Request(com.coveros.selenified.services.Request) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Aggregations

Call (com.coveros.selenified.services.Call)76 Test (org.testng.annotations.Test)75 Request (com.coveros.selenified.services.Request)56 JsonObject (com.google.gson.JsonObject)49 HashMap (java.util.HashMap)36 JsonArray (com.google.gson.JsonArray)5 JsonParser (com.google.gson.JsonParser)2 App (com.coveros.selenified.application.App)1 InvalidBrowserException (com.coveros.selenified.exceptions.InvalidBrowserException)1 HTTP (com.coveros.selenified.services.HTTP)1 MalformedURLException (java.net.MalformedURLException)1 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)1