Search in sources :

Example 26 with Request

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

the class ReadmeSampleIT method sampleServicesSearchTest.

@Test(groups = { "sample", "service", "coveros", "https" }, description = "A sample web services test to verify the response code")
public void sampleServicesSearchTest() {
    HashMap<String, Object> params = new HashMap<>();
    params.put("s", "Max+Saperstone");
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // retrieve the zip code and verify the return code
    call.get("", new Request().setUrlParams(params)).assertEquals().code(403);
    // verify no issues
    finish();
}
Also used : Call(com.coveros.selenified.services.Call) HashMap(java.util.HashMap) Request(com.coveros.selenified.services.Request) Test(org.testng.annotations.Test)

Example 27 with Request

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

the class LambdaTest method updateStatus.

/**
 * Connects with Lambda Test and updates the status in their system to the test result
 * status
 *
 * @param result - the testng itestresult object
 */
static void updateStatus(ITestResult result) {
    if (isLambdaTest() && result.getAttributeNames().contains(SESSION_ID)) {
        String sessionId = result.getAttribute(SESSION_ID).toString();
        JsonObject json = new JsonObject();
        String status = (result.getStatus() == 1) ? "passed" : "failed";
        json.addProperty("status_ind", status);
        try {
            LambdaTest lambdaTest = new LambdaTest();
            HTTP http = new HTTP(null, "https://api.lambdatest.com/automation/api/v1/", lambdaTest.getUsername(), lambdaTest.getPassword());
            http.patch("sessions/" + sessionId, new Request().setJsonPayload(json), null);
        } catch (MalformedURLException e) {
            log.error("Unable to connect to lambda test, due to credential problems");
        } catch (IOException e) {
            log.error(e);
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) Request(com.coveros.selenified.services.Request) JsonObject(com.google.gson.JsonObject) HTTP(com.coveros.selenified.services.HTTP) IOException(java.io.IOException)

Example 28 with Request

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

the class ServicesErrorIT method comparePutResponseCode200Test.

@Test(groups = { "integration", "service", "httpput", "https" }, description = "An integration test to verify the response code from a put call")
public void comparePutResponseCode200Test() {
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.put("posts/3", new Request()).verifyEquals().code(200);
    // verify 1 issue
    finish(1);
}
Also used : Call(com.coveros.selenified.services.Call) Request(com.coveros.selenified.services.Request) Test(org.testng.annotations.Test)

Example 29 with Request

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

the class ServicesErrorIT method compareDeleteResponseCode200Test.

@Test(groups = { "integration", "service", "httpdelete", "https" }, description = "An integration test to verify the response code from a delete call")
public void compareDeleteResponseCode200Test() {
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.delete("posts/5", new Request()).verifyEquals().code(200);
    // verify 1 issue
    finish(1);
}
Also used : Call(com.coveros.selenified.services.Call) Request(com.coveros.selenified.services.Request) Test(org.testng.annotations.Test)

Example 30 with Request

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

the class ServicesErrorIT method comparePostResponseCode201Test.

@Test(groups = { "integration", "service", "httppost", "https" }, description = "An integration test to verify the response code from a post call")
public void comparePostResponseCode201Test() {
    // use this object to verify the app looks as expected
    Call call = this.calls.get();
    // perform some actions
    call.post("posts/", new Request()).verifyEquals().code(201);
    // verify 1 issue
    finish(1);
}
Also used : Call(com.coveros.selenified.services.Call) Request(com.coveros.selenified.services.Request) 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