Search in sources :

Example 1 with Request

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

the class ServicesIT method checkPutResponseContainsMultipleDataTest.

@Test(groups = { "integration", "services", "httpput" }, description = "An integration test to verify the data from a put call")
public void checkPutResponseContainsMultipleDataTest() {
    JsonObject request = new JsonObject();
    request.addProperty("id", 3);
    request.addProperty("title", "foo1");
    request.addProperty("body", "bar");
    request.addProperty("userId", 3);
    Map<String, String> responsePairs = new HashMap<>();
    responsePairs.put("id", "3");
    responsePairs.put("body", "bar");
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.put("posts/3", 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)

Example 2 with Request

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

the class ServicesIT method comparePutResponseBadDataTest.

@Test(groups = { "integration", "services", "httpput" }, description = "A negative integration test to verify the data from a put call")
public void comparePutResponseBadDataTest() {
    JsonObject request = new JsonObject();
    request.addProperty("id", 1);
    request.addProperty("title", "foo1");
    request.addProperty("body", "bar");
    request.addProperty("userId", 3);
    JsonObject response = new JsonObject();
    response.addProperty("userId", 1);
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.put("posts/3", new Request(request)).assertEquals(response);
    // verify one issue
    finish(1);
}
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 3 with Request

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

the class ServicesIT method checkGetParamsResponseContainsBadArrayDataTest.

@Test(groups = { "integration", "services", "httpget" }, description = "An integration test to verify the data from a get call")
public void checkGetParamsResponseContainsBadArrayDataTest() {
    Map<String, String> params = new HashMap<>();
    params.put("userId", "6");
    JsonObject json = new JsonObject();
    json.addProperty("userId", 1);
    json.addProperty("id", 3);
    json.addProperty("title", "sunt aut facere repellat provident occaecati excepturi optio reprehenderit");
    json.addProperty("body", "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto");
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.get("posts", new Request(params)).assertContains(json);
    // verify 1 issue
    finish(1);
}
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)

Example 4 with Request

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

the class ServicesIT method compareGetParamsResponseNullObjectDataTest.

@Test(groups = { "integration", "services", "httpget" }, description = "A negative integration test to verify the data from a get call")
public void compareGetParamsResponseNullObjectDataTest() {
    Map<String, String> params = new HashMap<>();
    params.put("userId", "6");
    JsonArray response = new JsonArray();
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.get("posts/6", new Request(params)).assertEquals(response);
    // verify one issue
    finish(1);
}
Also used : JsonArray(com.google.gson.JsonArray) Call(com.coveros.selenified.services.Call) HashMap(java.util.HashMap) Request(com.coveros.selenified.services.Request) Test(org.testng.annotations.Test)

Example 5 with Request

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

the class ServicesIT method checkGetParamsResponseContainsArrayDataTest.

@Test(groups = { "integration", "services", "httpget" }, description = "An integration test to verify the data from a get call")
public void checkGetParamsResponseContainsArrayDataTest() {
    Map<String, String> params = new HashMap<>();
    params.put("userId", "6");
    JsonObject json = new JsonObject();
    json.addProperty("userId", 6);
    json.addProperty("id", 51);
    json.addProperty("title", "soluta aliquam aperiam consequatur illo quis voluptas");
    json.addProperty("body", "sunt dolores aut doloribus\ndolore doloribus voluptates tempora et\ndoloremque et quo\ncum asperiores sit consectetur dolorem");
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.get("posts", new Request(params)).assertContains(json);
    // 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

Request (com.coveros.selenified.services.Request)198 Test (org.testng.annotations.Test)197 Call (com.coveros.selenified.services.Call)142 JsonObject (com.google.gson.JsonObject)115 HashMap (java.util.HashMap)102 File (java.io.File)32 JsonArray (com.google.gson.JsonArray)30 HTTP (com.coveros.selenified.services.HTTP)5 JsonParser (com.google.gson.JsonParser)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1