Search in sources :

Example 16 with Response

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

the class ResponseTest method confirmEqualsArrayNullTest.

@Test
public void confirmEqualsArrayNullTest() throws IOException {
    JsonObject json = new JsonObject();
    json.addProperty("name", "john");
    Response response = new Response(5, json, "");
    response.setOutputFile(outputFile);
    response.assertEquals(new JsonArray());
    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 of:<div><i>\\[\\]</i></div></td>\n    <td>Found a response of:<div><i>\\{<br/>\\&nbsp;\\&nbsp;\"name\":\\&nbsp;\"john\"<br/>\\}</i></div></td>\n    <td>[0-9]+ms / [0-9]+ms</td>\n    <td class='fail'>Fail</td>\n   </tr>\n"));
}
Also used : Response(com.coveros.selenified.services.Response) JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 17 with Response

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

the class ResponseTest method confirmContainsObjectFailTest.

@Test
public void confirmContainsObjectFailTest() throws IOException {
    JsonObject child = new JsonObject();
    child.addProperty("first", "john");
    child.addProperty("last", "smith");
    JsonObject json = new JsonObject();
    json.add("name", child);
    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\":\\&nbsp;\\{<br/>\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;\"first\":\\&nbsp;\"john\",<br/>\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;\"last\":\\&nbsp;\"smith\"<br/>\\&nbsp;\\&nbsp;\\}<br/>}</i></div></td>\n    <td>[0-9]+ms / [0-9]+ms</td>\n    <td class='fail'>Fail</td>\n   </tr>\n"));
}
Also used : Response(com.coveros.selenified.services.Response) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 18 with Response

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

the class ResponseTest method checkNewResponseCodeObjectTest.

@Test
public void checkNewResponseCodeObjectTest() {
    Response response = new Response(5);
    Assert.assertNull(response.getObjectData());
}
Also used : Response(com.coveros.selenified.services.Response) Test(org.testng.annotations.Test)

Example 19 with Response

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

the class ResponseTest method confirmContainsArrayPassTest.

@Test
public void confirmContainsArrayPassTest() throws IOException {
    JsonObject child = new JsonObject();
    child.addProperty("first", "john");
    child.addProperty("last", "smith");
    JsonArray json = new JsonArray();
    json.add(child);
    Response response = new Response(5, json, "");
    response.setOutputFile(outputFile);
    response.assertContains(child);
    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 containing:<div><i>\\{<br/>\\&nbsp;\\&nbsp;\"first\":\\&nbsp;\"john\",<br/>\\&nbsp;\\&nbsp;\"last\":\\&nbsp;\"smith\"<br/>\\}</i></div></td>\n    <td>Found a response of:<div><i>\\[<br/>&nbsp;&nbsp;\\{<br/>\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;\"first\":\\&nbsp;\"john\",<br/>\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;\"last\":\\&nbsp;\"smith\"<br/>\\&nbsp;\\&nbsp;\\}<br/>\\]</i></div></td>\n    <td>[0-9]+ms / [0-9]+ms</td>\n    <td class='pass'>Pass</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)

Example 20 with Response

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

the class ResponseTest method confirmContainsArrayNullTest.

@Test
public void confirmContainsArrayNullTest() throws IOException {
    JsonObject json = new JsonObject();
    json.addProperty("first", "john");
    json.addProperty("last", "smith");
    Response response = new Response(5, json, "");
    response.setOutputFile(outputFile);
    response.assertContains(json);
    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 containing:<div><i>\\{<br/>\\&nbsp;\\&nbsp;\"first\":\\&nbsp;\"john\",<br/>\\&nbsp;\\&nbsp;\"last\":\\&nbsp;\"smith\"<br/>\\}</i></div></td>\n    <td>Found a response of:<div><i>\\{<br/>\\&nbsp;\\&nbsp;\"first\":\\&nbsp;\"john\",<br/>\\&nbsp;\\&nbsp;\"last\":\\&nbsp;\"smith\"<br/>\\}</i></div></td>\n    <td>[0-9]+ms / [0-9]+ms</td>\n    <td class='fail'>Fail</td>\n   </tr>\n"));
}
Also used : 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