use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.
the class AndroidEnrollment method testGetPendingOperations.
@Test(description = "Test get pending operations", dependsOnMethods = { "testModifyEnrollment" })
public void testGetPendingOperations() throws Exception {
JsonArray pendingOperationsData = PayloadGenerator.getJsonArray(Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, Constants.AndroidEnrollment.GET_PENDING_OPERATIONS_METHOD);
HttpResponse response = client.put(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId + "/pending-operations", pendingOperationsData.toString());
JsonArray pendingOperations = new JsonParser().parse(response.getData()).getAsJsonArray();
Assert.assertEquals("Error while getting pending operations for android device with the id " + deviceId, HttpStatus.SC_CREATED, response.getResponseCode());
Assert.assertTrue("Pending operation count is 0. Periodic monitoring tasks are not running.", 0 < pendingOperations.size());
}
use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.
the class AndroidEnrollment method testModifyEnrollment.
@Test(description = "Test modify enrollment.", dependsOnMethods = { "testIsEnrolled" })
public void testModifyEnrollment() throws Exception {
JsonObject enrollmentData = PayloadGenerator.getJsonPayload(Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_PUT);
HttpResponse response = client.put(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId, enrollmentData.toString());
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_PUT).toString(), response.getData(), true);
}
use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.
the class WindowsEnrollment method testServerAvailability.
/**
* Test the Windows Discovery Get endpoint to see if the server is available.
*
* @throws Exception
*/
@Test(groups = Constants.WindowsEnrollment.WINDOWS_ENROLLMENT_GROUP, description = "Test Windows Discovery get.")
public void testServerAvailability() throws Exception {
client.setHttpHeader(Constants.CONTENT_TYPE, Constants.APPLICATION_SOAP_XML);
HttpResponse response = client.get(Constants.WindowsEnrollment.DISCOVERY_GET_URL);
Assert.assertEquals(response.getResponseCode(), HttpStatus.SC_OK);
}
use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.
the class AndroidPolicy method testGetEffectivePolicy.
@Test(groups = Constants.AndroidPolicy.POLICY_GROUP, description = "Test Android getEffectivePolicy.")
public void testGetEffectivePolicy() throws Exception {
HttpResponse response = client.get(Constants.AndroidPolicy.POLICY_ENDPOINT + Constants.DEVICE_ID);
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.AndroidPolicy.POLICY_RESPONSE_PAYLOAD_FILE_NAME, Constants.AndroidPolicy.GET_EFFECTIVE_POLICY).toString(), response.getData().toString(), true);
}
use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.
the class AppOperations method uploadApplication.
public static MobileApplication uploadApplication(String platform, String appName, String appContentType) {
String appUploadEndpoint = EMMQSGConfig.getInstance().getEmmHost() + appmPublisherMobileBinariesUrl;
String filePath = "apps" + File.separator + platform + File.separator + appName;
HTTPResponse httpResponse = HTTPInvoker.uploadFile(appUploadEndpoint, filePath, appContentType);
if (Constants.HTTPStatus.OK == httpResponse.getResponseCode()) {
JSONObject appMeta = null;
MobileApplication application = new MobileApplication();
try {
appMeta = (JSONObject) new JSONParser().parse(httpResponse.getResponse());
application.setPackageId((String) appMeta.get("package"));
application.setAppId(QSGUtils.getResourceId((String) appMeta.get("path")));
application.setVersion((String) appMeta.get("version"));
application.setPlatform(platform);
} catch (ParseException e) {
e.printStackTrace();
}
return application;
}
return null;
}
Aggregations