Search in sources :

Example 46 with Request

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

the class HTTPTest method buildStringSingleParamTest.

@Test
public void buildStringSingleParamTest() {
    HTTP http = new HTTP(null, "Service");
    Map<String, Object> params = new HashMap<>();
    params.put("hello", "world");
    assertEquals(http.getRequestParams(new Request().setUrlParams(params)), "?hello=world");
}
Also used : HashMap(java.util.HashMap) Request(com.coveros.selenified.services.Request) HTTP(com.coveros.selenified.services.HTTP) Test(org.testng.annotations.Test)

Example 47 with Request

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

the class HTTPTest method buildStringEmptyParamTest.

@Test
public void buildStringEmptyParamTest() {
    HTTP http = new HTTP(null, "Service");
    assertEquals(http.getRequestParams(new Request()), "");
}
Also used : Request(com.coveros.selenified.services.Request) HTTP(com.coveros.selenified.services.HTTP) Test(org.testng.annotations.Test)

Example 48 with Request

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

the class HTTPTest method buildStringMultipleParamsTest.

@Test
public void buildStringMultipleParamsTest() {
    HTTP http = new HTTP(null, "Service");
    Map<String, Object> params = new HashMap<>();
    params.put("hello", "world");
    params.put("john", 5);
    assertEquals(http.getRequestParams(new Request().setUrlParams(params)), "?john=5&hello=world");
}
Also used : HashMap(java.util.HashMap) Request(com.coveros.selenified.services.Request) HTTP(com.coveros.selenified.services.HTTP) Test(org.testng.annotations.Test)

Example 49 with Request

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

the class ReporterTest method outputRequestPropertiesJsonObjectTest.

@Test
public void outputRequestPropertiesJsonObjectTest() {
    JsonObject json = new JsonObject();
    json.addProperty("hello", "world");
    Request request = new Request().setJsonPayload(json);
    String requestPayloadOutput = Reporter.getRequestPayloadOutput(request, null);
    assertTrue(requestPayloadOutput.matches("<a href='javascript:void\\(0\\)' onclick='toggle\\(\"[0-9]{13}_[a-zA-Z0-9]{10}\"\\)'>Toggle Payload</a> <span id='[0-9]{13}_[a-zA-Z0-9]{10}' style='display:none;'><div>\\{<br/>&nbsp;&nbsp;\"hello\":&nbsp;\"world\"<br/>\\}</div></span>"));
}
Also used : Request(com.coveros.selenified.services.Request) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Example 50 with Request

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

the class ReporterTest method outputRequestPropertiesEmptyMultipartAndFileTest.

@Test
public void outputRequestPropertiesEmptyMultipartAndFileTest() {
    Request request = new Request().setMultipartData(new HashMap<>());
    String requestPayloadOutput = Reporter.getRequestPayloadOutput(request, new File("Jenkinsfile"));
    assertTrue(requestPayloadOutput.matches("<a href='javascript:void\\(0\\)' onclick='toggle\\(\"[0-9]{13}_[a-zA-Z0-9]{10}\"\\)'>Toggle Payload</a> <span id='[0-9]{13}_[a-zA-Z0-9]{10}' style='display:none;'><div> with file: <a href='file:///" + System.getProperty("user.dir").replace("\\", "\\\\") + File.separator.replace("\\", "\\\\") + "Jenkinsfile'>Jenkinsfile</a></div></span>"));
}
Also used : Request(com.coveros.selenified.services.Request) File(java.io.File) 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