Search in sources :

Example 86 with HttpResponse

use of org.wso2.carbon.automation.test.utils.http.client.HttpResponse in project product-iots by wso2.

the class AppOperations method uploadAsset.

private static String uploadAsset(String path) {
    String resUploadEndpoint = EMMQSGConfig.getInstance().getEmmHost() + appmPublisherResourcesUrl;
    HTTPResponse httpResponse = HTTPInvoker.uploadFile(resUploadEndpoint, path, "image/jpeg");
    if (Constants.HTTPStatus.OK == httpResponse.getResponseCode()) {
        JSONObject resp = null;
        try {
            resp = (JSONObject) new JSONParser().parse(httpResponse.getResponse());
            return (String) resp.get("id");
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    return null;
}
Also used : JSONObject(org.json.simple.JSONObject) HTTPResponse(org.wso2.mdm.qsg.dto.HTTPResponse) JSONParser(org.json.simple.parser.JSONParser) ParseException(org.json.simple.parser.ParseException)

Example 87 with HttpResponse

use of org.wso2.carbon.automation.test.utils.http.client.HttpResponse in project product-iots by wso2.

the class OperationManagement method testInstallApps.

@Test(dependsOnMethods = { "testEnrollment" }, description = "Test Android install apps operation.")
public void testInstallApps() throws Exception {
    JsonObject operationData = PayloadGenerator.getJsonPayload(Constants.AndroidOperations.OPERATION_PAYLOAD_FILE_NAME, Constants.AndroidOperations.INSTALL_APPS_OPERATION);
    JsonArray deviceIds = new JsonArray();
    JsonPrimitive deviceID = new JsonPrimitive(Constants.DEVICE_ID);
    deviceIds.add(deviceID);
    operationData.add(Constants.DEVICE_IDENTIFIERS_KEY, deviceIds);
    HttpResponse response = rclient.post(Constants.AndroidOperations.INSTALL_APPS_ENDPOINT, operationData.toString());
    Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) JsonObject(com.google.gson.JsonObject) HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) Test(org.testng.annotations.Test)

Example 88 with HttpResponse

use of org.wso2.carbon.automation.test.utils.http.client.HttpResponse in project product-iots by wso2.

the class NotificationManagement method testGetNotification.

@Test(description = "Test get notification.", dependsOnMethods = { "testUpdateNotification" })
public void testGetNotification() throws Exception {
    HttpResponse response = client.get(Constants.NotificationManagement.NOTIFICATION_ENDPOINT);
    Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
}
Also used : HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) BeforeTest(org.testng.annotations.BeforeTest) Test(org.testng.annotations.Test)

Example 89 with HttpResponse

use of org.wso2.carbon.automation.test.utils.http.client.HttpResponse in project product-iots by wso2.

the class NotificationManagement method testUpdateNotification.

@Test(description = "Test update notification.", dependsOnMethods = { "testAddNotification" })
public void testUpdateNotification() throws Exception {
    HttpResponse response = client.put(Constants.NotificationManagement.NOTIFICATION_UPDATE_ENDPOINT, PayloadGenerator.getJsonPayload(Constants.NotificationManagement.NOTIFICATION_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_PUT).toString());
    Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.NotificationManagement.NOTIFICATION_RESPONSE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_PUT).toString(), response.getData().toString(), true);
}
Also used : HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) BeforeTest(org.testng.annotations.BeforeTest) Test(org.testng.annotations.Test)

Example 90 with HttpResponse

use of org.wso2.carbon.automation.test.utils.http.client.HttpResponse in project product-iots by wso2.

the class MobileQSGTestCase method testMobileApp.

@Test(description = "This test case tests whether app-catalogue is created from qsg script", dependsOnMethods = { "executeQSGScript" })
public void testMobileApp() throws Exception {
    RestClient appManagerRestClient = new RestClient(automationContext.getContextUrls().getWebAppURLHttps(), Constants.APPLICATION_JSON, accessTokenString);
    HttpResponse response = appManagerRestClient.get(Constants.QSGManagement.GET_MOBILE_APPS_ENDPONT);
    Assert.assertEquals(response.getResponseCode(), HttpStatus.SC_OK);
    Assert.assertTrue(response.getData().contains("WSO2Con-Android"), "Con-App-Android addition through script is not successful");
}
Also used : RestClient(org.wso2.iot.integration.common.RestClient) HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) Test(org.testng.annotations.Test)

Aggregations

HttpResponse (org.wso2.carbon.automation.test.utils.http.client.HttpResponse)75 Test (org.testng.annotations.Test)72 JsonObject (com.google.gson.JsonObject)15 HTTPResponse (org.wso2.mdm.qsg.dto.HTTPResponse)15 JsonParser (com.google.gson.JsonParser)14 JSONObject (org.json.simple.JSONObject)11 HashMap (java.util.HashMap)9 JsonArray (com.google.gson.JsonArray)8 IOException (java.io.IOException)8 HttpURLConnection (java.net.HttpURLConnection)8 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)7 KeyManagementException (java.security.KeyManagementException)6 KeyStoreException (java.security.KeyStoreException)6 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 HttpResponse (org.apache.http.HttpResponse)6 ClientProtocolException (org.apache.http.client.ClientProtocolException)6 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)6 HttpPost (org.apache.http.client.methods.HttpPost)5 JSONArray (org.json.simple.JSONArray)5 JsonElement (com.google.gson.JsonElement)4