Search in sources :

Example 21 with Device

use of org.wso2.carbon.device.mgt.common.Device in project product-iots by wso2.

the class MobileDeviceManagement method testViewDevices.

@Test(description = "Test getting devices")
public void testViewDevices() throws Exception {
    int expectedCount = this.userMode == TestUserMode.TENANT_ADMIN ? 3 : 23;
    HttpResponse response = client.get(Constants.MobileDeviceManagement.GET_ALL_DEVICES_ENDPOINT);
    Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    JsonObject devices = new JsonParser().parse(response.getData()).getAsJsonObject();
    Assert.assertEquals("Expected device count is not received", expectedCount, devices.get("count").getAsInt());
}
Also used : HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser) Test(org.testng.annotations.Test)

Example 22 with Device

use of org.wso2.carbon.device.mgt.common.Device in project product-iots by wso2.

the class MobileDeviceManagement method testAdvancedSearch.

@Test(description = "Test Advance search")
public void testAdvancedSearch() throws Exception {
    JsonArray pendingOperationsData = PayloadGenerator.getJsonArray(Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, Constants.AndroidEnrollment.GET_PENDING_OPERATIONS_METHOD);
    JsonArray newPayload = new JsonArray();
    HttpResponse response = client.put(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + Constants.DEVICE_ID + "/pending-operations", pendingOperationsData.toString());
    JsonArray pendingOperations = new JsonParser().parse(response.getData()).getAsJsonArray();
    for (JsonElement pendingOperation : pendingOperations) {
        JsonObject jsonObject = pendingOperation.getAsJsonObject();
        if (jsonObject.get("code").getAsString().equals("DEVICE_INFO")) {
            jsonObject.addProperty("operationResponse", PayloadGenerator.getJsonPayload(Constants.MobileDeviceManagement.REQUEST_PAYLOAD_FILE_NAME, Constants.MobileDeviceManagement.UPDATE_PAYLOAD_OPERATION).toString());
            jsonObject.addProperty("status", "COMPLETED");
            newPayload.add(jsonObject);
            break;
        }
    }
    client.put(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + Constants.DEVICE_ID + "/pending-operations", newPayload.toString());
    response = client.post(Constants.MobileDeviceManagement.GET_ALL_DEVICES_ENDPOINT + Constants.MobileDeviceManagement.ADVANCE_SEARCH_ENDPOINT, PayloadGenerator.getJsonPayload(Constants.MobileDeviceManagement.REQUEST_PAYLOAD_FILE_NAME, Constants.MobileDeviceManagement.ADVANCE_SEARCH_OPERATION).toString());
    JsonObject devices = new JsonParser().parse(response.getData()).getAsJsonObject();
    Assert.assertEquals("Expected device count is not received", 1, devices.get("devices").getAsJsonArray().size());
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser) Test(org.testng.annotations.Test)

Example 23 with Device

use of org.wso2.carbon.device.mgt.common.Device in project product-iots by wso2.

the class AndroidOperation method testLocation.

@Test(groups = { Constants.AndroidOperations.OPERATIONS_GROUP }, description = "Test Android device location " + "operation.")
public void testLocation() throws Exception {
    HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.LOCATION_ENDPOINT, Constants.AndroidOperations.LOCATION_PAYLOAD);
    Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
Also used : HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) Test(org.testng.annotations.Test)

Example 24 with Device

use of org.wso2.carbon.device.mgt.common.Device in project product-iots by wso2.

the class AndroidOperation method testUnLock.

@Test(groups = { Constants.AndroidOperations.OPERATIONS_GROUP }, description = "Test Android device un-lock " + "operation.")
public void testUnLock() throws MalformedURLException, AutomationFrameworkException {
    HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.UNLOCK_ENDPOINT, Constants.AndroidOperations.UNLOCK_OPERATION_PAYLOAD);
    Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
Also used : HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) Test(org.testng.annotations.Test)

Example 25 with Device

use of org.wso2.carbon.device.mgt.common.Device in project product-iots by wso2.

the class AndroidOperation method testCamera.

@Test(groups = { Constants.AndroidOperations.OPERATIONS_GROUP }, description = "Test Android device camera " + "operation.")
public void testCamera() throws Exception {
    HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.CAMERA_OPERATION, Constants.AndroidOperations.CAMERA_OPERATION_PAYLOAD);
    Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
Also used : HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)20 HttpResponse (org.wso2.carbon.automation.test.utils.http.client.HttpResponse)17 DeviceManagementException (org.wso2.carbon.device.mgt.common.DeviceManagementException)13 DeviceMgtPluginException (org.wso2.iot.sampledevice.plugin.exception.DeviceMgtPluginException)11 JsonParser (com.google.gson.JsonParser)10 SQLException (java.sql.SQLException)8 JsonObject (com.google.gson.JsonObject)7 Connection (java.sql.Connection)7 PreparedStatement (java.sql.PreparedStatement)7 HashMap (java.util.HashMap)6 ConnectedCupDeviceMgtPluginException (org.coffeeking.connectedcup.plugin.exception.ConnectedCupDeviceMgtPluginException)6 Device (org.wso2.carbon.device.mgt.common.Device)6 JsonArray (com.google.gson.JsonArray)5 JsonElement (com.google.gson.JsonElement)4 ResultSet (java.sql.ResultSet)4 ArrayList (java.util.ArrayList)4 Path (javax.ws.rs.Path)4 JSONObject (org.json.simple.JSONObject)4 PrivilegedCarbonContext (org.wso2.carbon.context.PrivilegedCarbonContext)4 DeviceIdentifier (org.wso2.carbon.device.mgt.common.DeviceIdentifier)4