Search in sources :

Example 26 with Response

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

the class OutputFileTest method formatResponseBothTest.

@Test
public void formatResponseBothTest() {
    JsonArray array = new JsonArray();
    array.add("world");
    Response response = new Response(0, array, null);
    JsonObject object = new JsonObject();
    object.addProperty("hello", "world");
    response.setObjectData(object);
    Assert.assertEquals(outputFile.formatResponse(response), "<div><i>[<br/>&nbsp;&nbsp;\"world\"<br/>]{<br/>&nbsp;&nbsp;\"hello\":&nbsp;\"world\"<br/>}</i></div>");
}
Also used : JsonArray(com.google.gson.JsonArray) Response(com.coveros.selenified.services.Response) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 27 with Response

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

the class OutputFileTest method formatRequestObjectTest.

@Test
public void formatRequestObjectTest() {
    JsonObject json = new JsonObject();
    json.addProperty("hello", "world");
    Response response = new Response(0, json, null);
    Assert.assertEquals(outputFile.formatResponse(response), "<div><i>{<br/>&nbsp;&nbsp;\"hello\":&nbsp;\"world\"<br/>}</i></div>");
}
Also used : Response(com.coveros.selenified.services.Response) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 28 with Response

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

the class OutputFileTest method formatResponseArrayTest.

@Test
public void formatResponseArrayTest() {
    JsonArray json = new JsonArray();
    json.add("world");
    Response response = new Response(0, json, null);
    Assert.assertEquals(outputFile.formatResponse(response), "<div><i>[<br/>&nbsp;&nbsp;\"world\"<br/>]</i></div>");
}
Also used : JsonArray(com.google.gson.JsonArray) Response(com.coveros.selenified.services.Response) Test(org.testng.annotations.Test)

Example 29 with Response

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

the class ResponseTest method checkSetMessageTest.

@Test
public void checkSetMessageTest() {
    JsonArray json = new JsonArray();
    String message = "";
    Response response = new Response(5, json, message);
    Assert.assertEquals(response.getMessage(), message);
    String newMessage = "hello world";
    response.setMessage(newMessage);
    Assert.assertEquals(response.getMessage(), newMessage);
}
Also used : JsonArray(com.google.gson.JsonArray) Response(com.coveros.selenified.services.Response) Test(org.testng.annotations.Test)

Example 30 with Response

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

the class ResponseTest method confirmContainsObjectNullTest.

@Test
public void confirmContainsObjectNullTest() throws IOException {
    JsonArray json = new JsonArray();
    json.add("name");
    Response response = new Response(5, json, "");
    response.setOutputFile(outputFile);
    JsonObject badChild = new JsonObject();
    badChild.addProperty("first", "john");
    response.assertContains("name", badChild);
    String content = Files.toString(file, Charsets.UTF_8);
    Assert.assertTrue(content.matches("[.\\s\\S]+   <tr>\n    <td align='center'>1.</td>\n    <td> </td>\n    <td>Expected to find a response with key <i>name</i> equal to: <div><i>\\{<br/>\\&nbsp;\\&nbsp;\"first\":\\&nbsp;\"john\"<br/>\\}</i></div></td>\n    <td>Found a response of:<div><i>\\[<br/>\\&nbsp;\\&nbsp;\"name\"<br/>\\]</i></div></td>\n    <td>[0-9]+ms / [0-9]+ms</td>\n    <td class='fail'>Fail</td>\n   </tr>\n"));
}
Also used : JsonArray(com.google.gson.JsonArray) Response(com.coveros.selenified.services.Response) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Aggregations

Response (com.coveros.selenified.services.Response)44 Test (org.testng.annotations.Test)44 JsonObject (com.google.gson.JsonObject)24 JsonArray (com.google.gson.JsonArray)17 HashMap (java.util.HashMap)3 OutputFile (com.coveros.selenified.OutputFile)1