|
|
@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
|
|
|
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
|
|
|
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
|
|
|
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
|
|
|
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
|
|
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
|
|
@ -50,12 +51,15 @@ import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Properties;
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
|
|
|
|
public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTest {
|
|
|
|
public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTest {
|
|
|
|
|
|
|
|
|
|
|
|
private static final Log log = LogFactory.getLog(DeviceManagementProviderServiceTest.class);
|
|
|
|
private static final Log log = LogFactory.getLog(DeviceManagementProviderServiceTest.class);
|
|
|
|
|
|
|
|
public static final String DEVICE_ID = "9999";
|
|
|
|
|
|
|
|
public static final String ALTERNATE_DEVICE_ID = "1128";
|
|
|
|
private DeviceManagementProviderService providerService;
|
|
|
|
private DeviceManagementProviderService providerService;
|
|
|
|
private static final String DEVICE_TYPE = "RANDOM_DEVICE_TYPE";
|
|
|
|
private static final String DEVICE_TYPE = "RANDOM_DEVICE_TYPE";
|
|
|
|
private DeviceDetailsDAO deviceDetailsDAO = DeviceManagementDAOFactory.getDeviceDetailsDAO();
|
|
|
|
private DeviceDetailsDAO deviceDetailsDAO = DeviceManagementDAOFactory.getDeviceDetailsDAO();
|
|
|
@ -89,63 +93,39 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testGetAvailableDeviceTypes() {
|
|
|
|
public void testGetAvailableDeviceTypes() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<DeviceType> deviceTypes = deviceMgtService.getDeviceTypes();
|
|
|
|
List<DeviceType> deviceTypes = deviceMgtService.getDeviceTypes();
|
|
|
|
Assert.assertTrue(deviceTypes.size() > 0);
|
|
|
|
Assert.assertTrue(deviceTypes.size() > 0);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while getting the device types";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test(expectedExceptions = DeviceManagementException.class)
|
|
|
|
public void testNullDeviceEnrollment() {
|
|
|
|
public void testNullDeviceEnrollment() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
deviceMgtService.enrollDevice(null);
|
|
|
|
boolean enrollmentStatus = deviceMgtService.enrollDevice(null);
|
|
|
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
Assert.assertTrue(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testSuccessfulDeviceEnrollment() {
|
|
|
|
public void testSuccessfulDeviceEnrollment() throws DeviceManagementException {
|
|
|
|
Device device = TestDataHolder.generateDummyDeviceData(DEVICE_TYPE);
|
|
|
|
Device device = TestDataHolder.generateDummyDeviceData(new DeviceIdentifier(DEVICE_ID, DEVICE_TYPE));
|
|
|
|
try {
|
|
|
|
|
|
|
|
boolean enrollmentStatus = deviceMgtService.enrollDevice(device);
|
|
|
|
boolean enrollmentStatus = deviceMgtService.enrollDevice(device);
|
|
|
|
Assert.assertTrue(enrollmentStatus);
|
|
|
|
Assert.assertTrue(enrollmentStatus);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while enrolling device";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testSuccessfulDeviceEnrollment")
|
|
|
|
@Test(dependsOnMethods = "testSuccessfulDeviceEnrollment")
|
|
|
|
public void testIsEnrolled() {
|
|
|
|
public void testIsEnrolled() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
|
|
deviceIdentifier.setId(TestDataHolder.initialDeviceIdentifier);
|
|
|
|
deviceIdentifier.setId(DEVICE_ID);
|
|
|
|
deviceIdentifier.setType(DEVICE_TYPE);
|
|
|
|
deviceIdentifier.setType(DEVICE_TYPE);
|
|
|
|
boolean enrollmentStatus = deviceMgtService.isEnrolled(deviceIdentifier);
|
|
|
|
boolean enrollmentStatus = deviceMgtService.isEnrolled(deviceIdentifier);
|
|
|
|
Assert.assertTrue(enrollmentStatus);
|
|
|
|
Assert.assertTrue(enrollmentStatus);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while checking enrollment status.";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testIsEnrolledForNonExistingDevice() {
|
|
|
|
public void testIsEnrolledForNonExistingDevice() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
|
|
deviceIdentifier.setId("34535235235235235");
|
|
|
|
deviceIdentifier.setId("34535235235235235");
|
|
|
|
deviceIdentifier.setType(DEVICE_TYPE);
|
|
|
|
deviceIdentifier.setType(DEVICE_TYPE);
|
|
|
|
boolean enrollmentStatus = deviceMgtService.isEnrolled(deviceIdentifier);
|
|
|
|
boolean enrollmentStatus = deviceMgtService.isEnrolled(deviceIdentifier);
|
|
|
|
Assert.assertFalse(enrollmentStatus);
|
|
|
|
Assert.assertFalse(enrollmentStatus);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while checking enrollment status.";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(expectedExceptions = DeviceManagementException.class)
|
|
|
|
@Test(expectedExceptions = DeviceManagementException.class)
|
|
|
@ -154,34 +134,22 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testNonExistentDeviceType() {
|
|
|
|
public void testNonExistentDeviceType() throws DeviceManagementException {
|
|
|
|
Device device = TestDataHolder.generateDummyDeviceData("abc");
|
|
|
|
Device device = TestDataHolder.generateDummyDeviceData("abc");
|
|
|
|
try {
|
|
|
|
|
|
|
|
boolean enrollmentStatus = deviceMgtService.enrollDevice(device);
|
|
|
|
boolean enrollmentStatus = deviceMgtService.enrollDevice(device);
|
|
|
|
Assert.assertFalse(enrollmentStatus);
|
|
|
|
Assert.assertFalse(enrollmentStatus);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while enrolling device";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testReEnrollmentofSameDeviceUnderSameUser() {
|
|
|
|
public void testReEnrollmentofSameDeviceUnderSameUser() throws DeviceManagementException {
|
|
|
|
Device device = TestDataHolder.generateDummyDeviceData(DEVICE_TYPE);
|
|
|
|
Device device = TestDataHolder.generateDummyDeviceData(new DeviceIdentifier(DEVICE_ID, DEVICE_TYPE));
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
boolean enrollment = deviceMgtService.enrollDevice(device);
|
|
|
|
boolean enrollment = deviceMgtService.enrollDevice(device);
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertTrue(enrollment);
|
|
|
|
Assert.assertTrue(enrollment);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while enrolling device";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testReEnrollmentofSameDeviceUnderSameUser"})
|
|
|
|
@Test(dependsOnMethods = {"testReEnrollmentofSameDeviceUnderSameUser"})
|
|
|
|
public void testReEnrollmentofSameDeviceWithOtherUser() {
|
|
|
|
public void testReEnrollmentofSameDeviceWithOtherUser() throws DeviceManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
|
|
|
|
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
|
|
|
|
enrolmentInfo.setDateOfEnrolment(new Date().getTime());
|
|
|
|
enrolmentInfo.setDateOfEnrolment(new Date().getTime());
|
|
|
@ -190,32 +158,23 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
|
|
|
|
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
|
|
|
|
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
|
|
|
|
enrolmentInfo.setStatus(EnrolmentInfo.Status.CREATED);
|
|
|
|
enrolmentInfo.setStatus(EnrolmentInfo.Status.CREATED);
|
|
|
|
|
|
|
|
|
|
|
|
Device alternateDevice = TestDataHolder.generateDummyDeviceData("12345", DEVICE_TYPE,
|
|
|
|
Device alternateDevice = TestDataHolder.generateDummyDeviceData(DEVICE_ID, DEVICE_TYPE,
|
|
|
|
enrolmentInfo);
|
|
|
|
enrolmentInfo);
|
|
|
|
|
|
|
|
Device retrievedDevice1 = deviceMgtService.getDevice(new DeviceIdentifier(DEVICE_ID,
|
|
|
|
try {
|
|
|
|
DEVICE_TYPE));
|
|
|
|
Device retrievedDevice1 = deviceMgtService.getDevice(new DeviceIdentifier("12345", DEVICE_TYPE));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deviceMgtService.enrollDevice(alternateDevice);
|
|
|
|
deviceMgtService.enrollDevice(alternateDevice);
|
|
|
|
Device retrievedDevice2 = deviceMgtService.getDevice(new DeviceIdentifier(alternateDevice
|
|
|
|
Device retrievedDevice2 = deviceMgtService.getDevice(new DeviceIdentifier(alternateDevice
|
|
|
|
.getDeviceIdentifier(), alternateDevice.getType()));
|
|
|
|
.getDeviceIdentifier(), alternateDevice.getType()));
|
|
|
|
|
|
|
|
|
|
|
|
log.info(retrievedDevice1.getEnrolmentInfo().getOwner());
|
|
|
|
|
|
|
|
log.info(retrievedDevice2.getEnrolmentInfo().getOwner());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertFalse(retrievedDevice1.getEnrolmentInfo().getOwner().equalsIgnoreCase
|
|
|
|
Assert.assertFalse(retrievedDevice1.getEnrolmentInfo().getOwner().equalsIgnoreCase
|
|
|
|
(retrievedDevice2.getEnrolmentInfo().getOwner()));
|
|
|
|
(retrievedDevice2.getEnrolmentInfo().getOwner()));
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error Occured while enrolling device";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testReEnrollmentofSameDeviceWithOtherUser"})
|
|
|
|
@Test(dependsOnMethods = {"testReEnrollmentofSameDeviceWithOtherUser"})
|
|
|
|
public void testDisenrollment() {
|
|
|
|
public void testDisenrollment() throws DeviceManagementException {
|
|
|
|
Device device = TestDataHolder.generateDummyDeviceData(DEVICE_TYPE);
|
|
|
|
Device device = TestDataHolder.generateDummyDeviceData(new DeviceIdentifier(DEVICE_ID, DEVICE_TYPE));
|
|
|
|
try {
|
|
|
|
|
|
|
|
boolean disenrollmentStatus = deviceMgtService.disenrollDevice(new DeviceIdentifier
|
|
|
|
boolean disenrollmentStatus = deviceMgtService.disenrollDevice(new DeviceIdentifier
|
|
|
|
(device
|
|
|
|
(device
|
|
|
|
.getDeviceIdentifier(),
|
|
|
|
.getDeviceIdentifier(),
|
|
|
@ -223,43 +182,24 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
|
|
|
|
log.info(disenrollmentStatus);
|
|
|
|
log.info(disenrollmentStatus);
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertTrue(disenrollmentStatus);
|
|
|
|
Assert.assertTrue(disenrollmentStatus);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while enrolling device";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testGetDeviceCount() {
|
|
|
|
public void testGetDeviceCount() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
int count = deviceMgtService.getDeviceCount();
|
|
|
|
int count = deviceMgtService.getDeviceCount();
|
|
|
|
Assert.assertTrue(count > 0);
|
|
|
|
Assert.assertTrue(count > 0);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while getting the device count";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testGetDeviceCountForUser() {
|
|
|
|
public void testGetDeviceCountForUser() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
int count = deviceMgtService.getDeviceCount(TestDataHolder.OWNER);
|
|
|
|
int count = deviceMgtService.getDeviceCount(TestDataHolder.OWNER);
|
|
|
|
Assert.assertTrue(count > 0);
|
|
|
|
Assert.assertTrue(count > 0);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while getting the device count";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testGetDeviceCountForNonExistingUser() {
|
|
|
|
public void testGetDeviceCountForNonExistingUser() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
int count = deviceMgtService.getDeviceCount("ABCD");
|
|
|
|
int count = deviceMgtService.getDeviceCount("ABCD");
|
|
|
|
Assert.assertEquals(count, 0);
|
|
|
|
Assert.assertEquals(count, 0);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while getting the device count";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(expectedExceptions = DeviceManagementException.class)
|
|
|
|
@Test(expectedExceptions = DeviceManagementException.class)
|
|
|
@ -268,131 +208,80 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testIsActive() {
|
|
|
|
public void testIsActive() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
|
|
deviceIdentifier.setId(TestDataHolder.initialDeviceIdentifier);
|
|
|
|
deviceIdentifier.setId(TestDataHolder.initialDeviceIdentifier);
|
|
|
|
deviceIdentifier.setType(DEVICE_TYPE);
|
|
|
|
deviceIdentifier.setType(DEVICE_TYPE);
|
|
|
|
Assert.assertTrue(deviceMgtService.isActive(deviceIdentifier));
|
|
|
|
Assert.assertTrue(deviceMgtService.isActive(deviceIdentifier));
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while checking the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testIsActiveForNonExistingDevice() {
|
|
|
|
public void testIsActiveForNonExistingDevice() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
|
|
deviceIdentifier.setId("34535235235235235");
|
|
|
|
deviceIdentifier.setId("34535235235235235");
|
|
|
|
deviceIdentifier.setType("TEST_TYPE");
|
|
|
|
deviceIdentifier.setType("TEST_TYPE");
|
|
|
|
Assert.assertFalse(deviceMgtService.isActive(deviceIdentifier));
|
|
|
|
Assert.assertFalse(deviceMgtService.isActive(deviceIdentifier));
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while checking the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testSetActive() {
|
|
|
|
public void testSetActive() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
|
|
deviceIdentifier.setId(TestDataHolder.initialDeviceIdentifier);
|
|
|
|
deviceIdentifier.setId(TestDataHolder.initialDeviceIdentifier);
|
|
|
|
deviceIdentifier.setType(DEVICE_TYPE);
|
|
|
|
deviceIdentifier.setType(DEVICE_TYPE);
|
|
|
|
Assert.assertFalse(deviceMgtService.setActive(deviceIdentifier, true));
|
|
|
|
Assert.assertFalse(deviceMgtService.setActive(deviceIdentifier, true));
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testSetActiveForNonExistingDevice() {
|
|
|
|
public void testSetActiveForNonExistingDevice() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
|
|
deviceIdentifier.setId("34535235235235235");
|
|
|
|
deviceIdentifier.setId("34535235235235235");
|
|
|
|
deviceIdentifier.setType("TEST_TYPE");
|
|
|
|
deviceIdentifier.setType("TEST_TYPE");
|
|
|
|
Assert.assertFalse(deviceMgtService.setActive(deviceIdentifier, true));
|
|
|
|
Assert.assertFalse(deviceMgtService.setActive(deviceIdentifier, true));
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status for non-existing device";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testGetDeviceEnrolledTenants() {
|
|
|
|
public void testGetDeviceEnrolledTenants() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<Integer> tenants = deviceMgtService.getDeviceEnrolledTenants();
|
|
|
|
List<Integer> tenants = deviceMgtService.getDeviceEnrolledTenants();
|
|
|
|
Assert.assertEquals(tenants.size(), 1);
|
|
|
|
Assert.assertEquals(tenants.size(), 1);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testGetDevice() {
|
|
|
|
public void testGetDevice() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier(DEVICE_ID, DEVICE_TYPE));
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier("12345",DEVICE_TYPE));
|
|
|
|
Assert.assertTrue(device.getDeviceIdentifier().equalsIgnoreCase(DEVICE_ID));
|
|
|
|
Assert.assertTrue(device.getDeviceIdentifier().equalsIgnoreCase("12345"));
|
|
|
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testGetDeviceWithInfo() {
|
|
|
|
public void testGetDeviceWithInfo() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier(DEVICE_ID, DEVICE_TYPE)
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier("12345", DEVICE_TYPE)
|
|
|
|
|
|
|
|
, true);
|
|
|
|
, true);
|
|
|
|
Assert.assertTrue(device.getDeviceInfo() != null);
|
|
|
|
Assert.assertTrue(device.getDeviceInfo() != null);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testGetDeviceWithOutInfo() {
|
|
|
|
public void testGetDeviceWithOutInfo() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier(DEVICE_ID, DEVICE_TYPE)
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier("12345", DEVICE_TYPE)
|
|
|
|
|
|
|
|
, false);
|
|
|
|
, false);
|
|
|
|
Assert.assertTrue(device.getDeviceInfo() == null);
|
|
|
|
Assert.assertTrue(device.getDeviceInfo() == null);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testGetAllDevicesOfRole() {
|
|
|
|
public void testGetAllDevicesOfRole() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<Device> devices = deviceMgtService.getAllDevicesOfRole("admin");
|
|
|
|
List<Device> devices = deviceMgtService.getAllDevicesOfRole("admin");
|
|
|
|
Assert.assertTrue(devices.size() > 0);
|
|
|
|
Assert.assertTrue(devices.size() > 0);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testDeviceByOwner() {
|
|
|
|
public void testDeviceByOwner() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier(DEVICE_ID,
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier("12345",
|
|
|
|
|
|
|
|
DEVICE_TYPE), "admin", true);
|
|
|
|
DEVICE_TYPE), "admin", true);
|
|
|
|
Assert.assertTrue(device != null);
|
|
|
|
Assert.assertTrue(device != null);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testDeviceByDate() {
|
|
|
|
public void testDeviceByDate() throws DeviceManagementException, TransactionManagementException, DeviceDetailsMgtDAOException {
|
|
|
|
try {
|
|
|
|
Device initialDevice = deviceMgtService.getDevice(new DeviceIdentifier(DEVICE_ID,
|
|
|
|
Device initialDevice = deviceMgtService.getDevice(new DeviceIdentifier("12345",
|
|
|
|
|
|
|
|
DEVICE_TYPE));
|
|
|
|
DEVICE_TYPE));
|
|
|
|
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
@ -401,81 +290,100 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
|
|
|
|
//This dao entry is to mimic a device info operation
|
|
|
|
//This dao entry is to mimic a device info operation
|
|
|
|
deviceDetailsDAO.addDeviceInformation(initialDevice.getId(), TestDataHolder
|
|
|
|
deviceDetailsDAO.addDeviceInformation(initialDevice.getId(), TestDataHolder
|
|
|
|
.generateDummyDeviceInfo());
|
|
|
|
.generateDummyDeviceInfo());
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
} catch (DeviceDetailsMgtDAOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier(DEVICE_ID,
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier("12345",
|
|
|
|
|
|
|
|
DEVICE_TYPE), yesterday());
|
|
|
|
DEVICE_TYPE), yesterday());
|
|
|
|
Assert.assertTrue(device != null);
|
|
|
|
Assert.assertTrue(device != null);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testDeviceByDate"})
|
|
|
|
@Test(dependsOnMethods = {"testDeviceByDate"})
|
|
|
|
public void testDeviceByDateAndOwner() {
|
|
|
|
public void testDeviceByDateAndOwner() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier(DEVICE_ID,
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier("12345",
|
|
|
|
|
|
|
|
DEVICE_TYPE), "admin", yesterday(), true);
|
|
|
|
DEVICE_TYPE), "admin", yesterday(), true);
|
|
|
|
Assert.assertTrue(device != null);
|
|
|
|
Assert.assertTrue(device != null);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testGetAvaliableDeviceTypes() {
|
|
|
|
public void testGetAvaliableDeviceTypes() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<String> deviceTypes = deviceMgtService.getAvailableDeviceTypes();
|
|
|
|
List<String> deviceTypes = deviceMgtService.getAvailableDeviceTypes();
|
|
|
|
Assert.assertTrue(!deviceTypes.isEmpty());
|
|
|
|
Assert.assertTrue(!deviceTypes.isEmpty());
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testGetAllDevices() {
|
|
|
|
public void testGetAllDevices() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<Device> devices = deviceMgtService.getAllDevices();
|
|
|
|
List<Device> devices = deviceMgtService.getAllDevices();
|
|
|
|
Assert.assertTrue(!devices.isEmpty());
|
|
|
|
Assert.assertTrue(!devices.isEmpty());
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetAllDevicesPaginated() throws DeviceManagementException {
|
|
|
|
|
|
|
|
PaginationRequest request = new PaginationRequest(0, 100);
|
|
|
|
|
|
|
|
PaginationResult result = deviceMgtService.getAllDevices(request);
|
|
|
|
|
|
|
|
Assert.assertTrue(result.getRecordsTotal() > 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetAllDevicesByName() throws DeviceManagementException {
|
|
|
|
|
|
|
|
PaginationRequest request = new PaginationRequest(0, 100);
|
|
|
|
|
|
|
|
request.setDeviceName(DEVICE_TYPE + "-" + DEVICE_ID);
|
|
|
|
|
|
|
|
PaginationResult result = deviceMgtService.getDevicesByName(request);
|
|
|
|
|
|
|
|
Assert.assertTrue(result.getRecordsTotal() > 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetAllDevicesByNameAndType() throws DeviceManagementException {
|
|
|
|
|
|
|
|
PaginationRequest request = new PaginationRequest(0, 100);
|
|
|
|
|
|
|
|
request.setDeviceName(DEVICE_TYPE + "-" + DEVICE_ID);
|
|
|
|
|
|
|
|
request.setDeviceType(DEVICE_TYPE);
|
|
|
|
|
|
|
|
List<Device> devices = deviceMgtService.getDevicesByNameAndType(request, true);
|
|
|
|
|
|
|
|
Assert.assertTrue(!devices.isEmpty());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetAllDevicesByStatus() throws DeviceManagementException {
|
|
|
|
|
|
|
|
PaginationRequest request = new PaginationRequest(0, 100);
|
|
|
|
|
|
|
|
request.setStatus(EnrolmentInfo.Status.ACTIVE.toString());
|
|
|
|
|
|
|
|
PaginationResult result = deviceMgtService.getDevicesByStatus(request, true);
|
|
|
|
|
|
|
|
Assert.assertTrue(result.getRecordsTotal() > 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testDeviceByDate"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testGetAllDevicesWithInfo() {
|
|
|
|
public void testGetDevicesOfTypePaginated() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
PaginationRequest request = new PaginationRequest(0, 100);
|
|
|
|
|
|
|
|
request.setDeviceType(DEVICE_TYPE);
|
|
|
|
|
|
|
|
PaginationResult result = deviceMgtService.getDevicesByType(request);
|
|
|
|
|
|
|
|
Assert.assertTrue(result.getRecordsTotal() > 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetAllDevicesWithInfo() throws DeviceManagementException {
|
|
|
|
List<Device> devices = deviceMgtService.getAllDevices(true);
|
|
|
|
List<Device> devices = deviceMgtService.getAllDevices(true);
|
|
|
|
Assert.assertTrue(!devices.isEmpty());
|
|
|
|
Assert.assertTrue(!devices.isEmpty());
|
|
|
|
Assert.assertTrue(devices.get(0).getDeviceInfo() != null);
|
|
|
|
Assert.assertTrue(devices.get(0).getDeviceInfo() != null);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetAllDevicesWithInfoPaginated() throws DeviceManagementException {
|
|
|
|
|
|
|
|
PaginationRequest request = new PaginationRequest(0, 100);
|
|
|
|
|
|
|
|
PaginationResult result = deviceMgtService.getAllDevices(request, true);
|
|
|
|
|
|
|
|
Assert.assertTrue(result.getRecordsTotal() > 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testDeviceByDate"})
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
public void testGetLicense() {
|
|
|
|
public void testGetTenantedDevice() throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
PaginationRequest request = new PaginationRequest(0, 100);
|
|
|
|
|
|
|
|
HashMap<Integer, Device> deviceMap = deviceMgtService.getTenantedDevice(new
|
|
|
|
|
|
|
|
DeviceIdentifier
|
|
|
|
|
|
|
|
(DEVICE_ID, DEVICE_TYPE));
|
|
|
|
|
|
|
|
Assert.assertTrue(!deviceMap.isEmpty());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void testGetLicense() throws DeviceManagementException {
|
|
|
|
License license = deviceMgtService.getLicense(DEVICE_TYPE, "ENG");
|
|
|
|
License license = deviceMgtService.getLicense(DEVICE_TYPE, "ENG");
|
|
|
|
Assert.assertTrue(license.getLanguage().equalsIgnoreCase("ENG"));
|
|
|
|
Assert.assertTrue(license.getLanguage().equalsIgnoreCase("ENG"));
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while updating the device status";
|
|
|
|
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(expectedExceptions = DeviceManagementException.class)
|
|
|
|
@Test(expectedExceptions = DeviceManagementException.class)
|
|
|
@ -484,9 +392,58 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
|
|
|
|
Assert.assertTrue(false);
|
|
|
|
Assert.assertTrue(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetDeviesOfUser() throws DeviceManagementException {
|
|
|
|
|
|
|
|
List<Device> devices = deviceMgtService.getDevicesOfUser("admin");
|
|
|
|
|
|
|
|
Assert.assertTrue(!devices.isEmpty());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetDevieByStatus() throws DeviceManagementException {
|
|
|
|
|
|
|
|
Device device = deviceMgtService.getDevice(new DeviceIdentifier(DEVICE_ID,
|
|
|
|
|
|
|
|
DEVICE_TYPE), EnrolmentInfo.Status.ACTIVE);
|
|
|
|
|
|
|
|
Assert.assertTrue(device != null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetDevieByDate() throws DeviceManagementException {
|
|
|
|
|
|
|
|
List<Device> devices = deviceMgtService.getDevices(yesterday());
|
|
|
|
|
|
|
|
Assert.assertTrue(!devices.isEmpty());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetDeviesOfUserPaginated() throws DeviceManagementException {
|
|
|
|
|
|
|
|
PaginationRequest request = new PaginationRequest(0, 100);
|
|
|
|
|
|
|
|
request.setOwner("admin");
|
|
|
|
|
|
|
|
PaginationResult result = deviceMgtService.getDevicesOfUser(request, true);
|
|
|
|
|
|
|
|
Assert.assertTrue(result.getRecordsTotal() > 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetDeviesByOwnership() throws DeviceManagementException {
|
|
|
|
|
|
|
|
PaginationRequest request = new PaginationRequest(0, 100);
|
|
|
|
|
|
|
|
request.setOwnership(EnrolmentInfo.OwnerShip.BYOD.toString());
|
|
|
|
|
|
|
|
PaginationResult result = deviceMgtService.getDevicesByOwnership(request);
|
|
|
|
|
|
|
|
Assert.assertTrue(result.getRecordsTotal() > 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetDeviesByStatus() throws DeviceManagementException {
|
|
|
|
|
|
|
|
PaginationRequest request = new PaginationRequest(0, 100);
|
|
|
|
|
|
|
|
request.setStatus("ACTIVE");
|
|
|
|
|
|
|
|
PaginationResult result = deviceMgtService.getDevicesByStatus(request);
|
|
|
|
|
|
|
|
Assert.assertTrue(result.getRecordsTotal() > 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
|
|
|
|
|
|
|
|
public void testGetDeviesOfUserAndDeviceType() throws DeviceManagementException {
|
|
|
|
|
|
|
|
List<Device> devices = deviceMgtService.getDevicesOfUser("admin", DEVICE_TYPE, true);
|
|
|
|
|
|
|
|
Assert.assertTrue(!devices.isEmpty() && devices.get(0).getType().equalsIgnoreCase
|
|
|
|
|
|
|
|
(DEVICE_TYPE) && devices.get(0).getDeviceInfo() != null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testSendRegistrationEmailSuccessFlow() {
|
|
|
|
public void testSendRegistrationEmailSuccessFlow() throws ConfigurationManagementException, DeviceManagementException {
|
|
|
|
try {
|
|
|
|
|
|
|
|
String recipient = "test-user@wso2.com";
|
|
|
|
String recipient = "test-user@wso2.com";
|
|
|
|
Properties props = new Properties();
|
|
|
|
Properties props = new Properties();
|
|
|
|
props.setProperty("first-name", "Test");
|
|
|
|
props.setProperty("first-name", "Test");
|
|
|
@ -497,13 +454,21 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
|
|
|
|
|
|
|
|
|
|
|
|
deviceMgtService.sendRegistrationEmail(metaInfo);
|
|
|
|
deviceMgtService.sendRegistrationEmail(metaInfo);
|
|
|
|
Assert.assertTrue(true);
|
|
|
|
Assert.assertTrue(true);
|
|
|
|
} catch (ConfigurationManagementException e) {
|
|
|
|
|
|
|
|
Assert.assertTrue(false, "Error in sending registration email : Configration " +
|
|
|
|
|
|
|
|
"related error" + e.getMessage());
|
|
|
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
Assert.assertTrue(false, "Error in sending registration email" +
|
|
|
|
|
|
|
|
e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void testSendEnrollmentInvitation() throws ConfigurationManagementException,
|
|
|
|
|
|
|
|
DeviceManagementException {
|
|
|
|
|
|
|
|
String recipient = "test-user@wso2.com";
|
|
|
|
|
|
|
|
Properties props = new Properties();
|
|
|
|
|
|
|
|
props.setProperty("first-name", "Test");
|
|
|
|
|
|
|
|
props.setProperty("username", "User");
|
|
|
|
|
|
|
|
props.setProperty("password", "!@#$$$%");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EmailMetaInfo metaInfo = new EmailMetaInfo(recipient, props);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deviceMgtService.sendEnrolmentInvitation("template-name", metaInfo);
|
|
|
|
|
|
|
|
Assert.assertTrue(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Date yesterday() {
|
|
|
|
private Date yesterday() {
|
|
|
@ -511,6 +476,4 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
|
|
|
|
cal.add(Calendar.DATE, -1);
|
|
|
|
cal.add(Calendar.DATE, -1);
|
|
|
|
return cal.getTime();
|
|
|
|
return cal.getTime();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|