From de548efd18aff3b5f25c10c27ecafd6ce2322fc2 Mon Sep 17 00:00:00 2001 From: shamalka Date: Tue, 10 Dec 2019 15:17:00 +0530 Subject: [PATCH 1/2] Fix for enrollment app install without Google --- .../device/mgt/mobile/android/core/util/AndroidDeviceUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidDeviceUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidDeviceUtils.java index 2a1d4611f..eafcc6e37 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidDeviceUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidDeviceUtils.java @@ -705,7 +705,7 @@ public class AndroidDeviceUtils { JsonElement googlePolicyPayload = appElement.getAsJsonObject(). get(AndroidConstants.ApplicationInstall.GOOGLE_POLICY_PAYLOAD); - if (googlePolicyPayload == null) { + if (googlePolicyPayload == null || googlePolicyPayload.toString().equals("\"\"")) { uuid = appElement.getAsJsonObject(). get(AndroidConstants.ApplicationInstall.ENROLLMENT_APP_INSTALL_UUID).getAsString(); try (CloseableHttpClient httpClient = HttpClients.createDefault()) { From 127934e0b5fd7a60a8400f6eb34ec2c23f59bacc Mon Sep 17 00:00:00 2001 From: shamalka Date: Tue, 10 Dec 2019 16:15:31 +0530 Subject: [PATCH 2/2] Fix test cases --- .../core/DeviceManagementServiceTests.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/DeviceManagementServiceTests.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/DeviceManagementServiceTests.java index bea230479..2a5b818e4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/DeviceManagementServiceTests.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/DeviceManagementServiceTests.java @@ -196,9 +196,9 @@ public class DeviceManagementServiceTests { mockDeviceManagementService(); mockPolicyManagerService(); mockUser(); - Response response = androidService.enrollDevice(TestUtils.getBasicAndroidDevice()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); + Message message = androidService.enrollDevice(TestUtils.getBasicAndroidDevice()); + Assert.assertNotNull(message); + Assert.assertEquals(message.getResponseCode(), Response.Status.OK.getStatusCode()); } @Test @@ -237,9 +237,9 @@ public class DeviceManagementServiceTests { properties.add(property); androidDevice.setProperties(properties); - Response response = androidService.enrollDevice(androidDevice); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); + Message message = androidService.enrollDevice(androidDevice); + Assert.assertNotNull(message); + Assert.assertEquals(message.getResponseCode(), Response.Status.OK.getStatusCode()); } @Test @@ -249,9 +249,9 @@ public class DeviceManagementServiceTests { mockUser(); AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice(); androidDevice.setDeviceIdentifier("1234"); - Response response = androidService.enrollDevice(androidDevice); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + Message message = androidService.enrollDevice(androidDevice); + Assert.assertNotNull(message); + Assert.assertEquals(message.getResponseCode(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); } @Test