|
|
@ -37,6 +37,7 @@ import java.sql.Connection;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
@ -92,6 +93,7 @@ public class DevicePersistTests extends BaseDeviceManagementTest {
|
|
|
|
public void testAddDeviceTest() {
|
|
|
|
public void testAddDeviceTest() {
|
|
|
|
int tenantId = TestDataHolder.SUPER_TENANT_ID;
|
|
|
|
int tenantId = TestDataHolder.SUPER_TENANT_ID;
|
|
|
|
Device device = TestDataHolder.generateDummyDeviceData(TestDataHolder.TEST_DEVICE_TYPE);
|
|
|
|
Device device = TestDataHolder.generateDummyDeviceData(TestDataHolder.TEST_DEVICE_TYPE);
|
|
|
|
|
|
|
|
device.setName(TestDataHolder.initialDeviceName);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
@ -278,6 +280,7 @@ public class DevicePersistTests extends BaseDeviceManagementTest {
|
|
|
|
pr.setStatusList(Collections.singletonList(Status.ACTIVE.name()));
|
|
|
|
pr.setStatusList(Collections.singletonList(Status.ACTIVE.name()));
|
|
|
|
List<Device> results = deviceDAO.getDevicesByStatus(pr, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
List<Device> results = deviceDAO.getDevicesByStatus(pr, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
Assert.assertEquals(1, results.size(), "No device returned");
|
|
|
|
Assert.assertEquals(1, results.size(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the current status of the " +
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the current status of the " +
|
|
|
|
"enrolment", e);
|
|
|
|
"enrolment", e);
|
|
|
@ -286,4 +289,509 @@ public class DevicePersistTests extends BaseDeviceManagementTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDevicesByTenantId() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
List<Device> results = deviceDAO.getDevices(TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results.size(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceByDeviceId() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
Device results = deviceDAO.getDevice(device.getDeviceIdentifier(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertNotNull(results.getDeviceIdentifier(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceByDeviceIdentifierWithTenantId() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType());
|
|
|
|
|
|
|
|
Device results = deviceDAO.getDevice(deviceIdentifier, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertNotNull(results.getDeviceIdentifier(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceByDeviceData() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType());
|
|
|
|
|
|
|
|
DeviceData deviceData = TestDataHolder.generateDummyDevice(deviceIdentifier);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
Device results = deviceDAO.getDevice(deviceData, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertNotNull(results.getDeviceIdentifier(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceByOwner() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType());
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
Device results = deviceDAO.getDevice(deviceIdentifier, TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertNotNull(results.getDeviceIdentifier(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceByDateSince() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType());
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
Device results = deviceDAO.getDevice(deviceIdentifier, TestDataHolder.getTimeBefore(1), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertNotNull(results.getDeviceIdentifier(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceByDateSinceWithDeviceId() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
Device results = deviceDAO.getDevice(device.getDeviceIdentifier(), TestDataHolder.getTimeBefore(1), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertNotNull(results.getDeviceIdentifier(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceByEnrollmentStatus() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType());
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
Device results = deviceDAO.getDevice(deviceIdentifier, Status.ACTIVE, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(device.getDeviceIdentifier(), results.getDeviceIdentifier(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceByDeviceIdentifier() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType());
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
SingletonMap results = deviceDAO.getDevice(deviceIdentifier);
|
|
|
|
|
|
|
|
Assert.assertNotNull(results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceByDeviceType() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
List<Device> results = deviceDAO.getDevices(device.getType(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results.size(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getAllocatedDevices() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
List<Device> results = deviceDAO.getAllocatedDevices(device.getType(), TestDataHolder.SUPER_TENANT_ID, 1, 0);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results.size(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDevicesOfUser() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
List<Device> results = deviceDAO.getDevicesOfUser(TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results.size(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDevicesOfUserWithDeviceType() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
List<Device> results = deviceDAO.getDevicesOfUser(TestDataHolder.OWNER, device.getType(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results.size(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDevicesOfUserWithDeviceStatus() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
List<String> status = new ArrayList<>() ;
|
|
|
|
|
|
|
|
status.add(Status.ACTIVE.name());
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
List<Device> results = deviceDAO.getDevicesOfUser(TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID, status);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results.size(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getCountOfDevicesInGroup() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
PaginationRequest pr = new PaginationRequest(0, 10);
|
|
|
|
|
|
|
|
pr.setGroupId(1);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getCountOfDevicesInGroup(pr, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(0, results, "No device count returned in group");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device count" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceCountWithOwner() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getDeviceCount(TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceCountWithType() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getDeviceCount(device.getType(), Status.ACTIVE.name(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void setEnrolmentStatusInBulk() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
List<String> devices = new ArrayList<>() ;
|
|
|
|
|
|
|
|
devices.add(device.getDeviceIdentifier());
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
boolean results = deviceDAO.setEnrolmentStatusInBulk(device.getType(), Status.ACTIVE.name(),TestDataHolder.SUPER_TENANT_ID, devices );
|
|
|
|
|
|
|
|
Assert.assertTrue(results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceCount() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getDeviceCount(TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceCountWithPagination() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
PaginationRequest pr = new PaginationRequest(0, 10);
|
|
|
|
|
|
|
|
pr.setDeviceName(device.getName());
|
|
|
|
|
|
|
|
pr.setDeviceType(device.getType());
|
|
|
|
|
|
|
|
pr.setOwner(TestDataHolder.OWNER);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getDeviceCount(pr, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceCountByType() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getDeviceCountByType(device.getType(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceCountByUser() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getDeviceCountByUser(TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceCountByName() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getDeviceCountByName(TestDataHolder.initialDeviceName, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceCountByOwnership() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getDeviceCountByOwnership(EnrolmentInfo.OwnerShip.BYOD.name(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceCountByStatus() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getDeviceCountByStatus(Status.ACTIVE.name(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceCountByStatusWithType() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getDeviceCountByStatus(device.getType(), Status.ACTIVE.name(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getActiveEnrolment() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType());
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
EnrolmentInfo results = deviceDAO.getActiveEnrolment(deviceIdentifier, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertEquals(Status.ACTIVE, results.getStatus(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDeviceEnrolledTenants() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
List<Integer> results = deviceDAO.getDeviceEnrolledTenants();
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results.size(), "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void findGeoClusters() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
GeoQuery geoQuery = new GeoQuery(new GeoCoordinate(123, 123), new GeoCoordinate(123, 123), 12345);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
List<GeoCluster> results = deviceDAO.findGeoClusters(geoQuery, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
Assert.assertNotNull(results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getAppNotInstalledDevices() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
PaginationRequest pr = new PaginationRequest(0, 10);
|
|
|
|
|
|
|
|
pr.setDeviceType(device.getType());
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
List<Device> results = deviceDAO.getAppNotInstalledDevices(pr, TestDataHolder.SUPER_TENANT_ID, "com.google.calc", "1.0.0");
|
|
|
|
|
|
|
|
Assert.assertNotNull(results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getCountOfAppNotInstalledDevices() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
Device device = TestDataHolder.initialTestDevice;
|
|
|
|
|
|
|
|
PaginationRequest pr = new PaginationRequest(0, 10);
|
|
|
|
|
|
|
|
pr.setDeviceType(device.getType());
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getCountOfAppNotInstalledDevices(pr, TestDataHolder.SUPER_TENANT_ID, "com.google.calc", "1.0.0");
|
|
|
|
|
|
|
|
Assert.assertEquals(1, results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getDevicesByEncryptionStatus() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
PaginationRequest pr = new PaginationRequest(0, 10);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
List<Device> results = deviceDAO.getDevicesByEncryptionStatus(pr, TestDataHolder.SUPER_TENANT_ID, false);
|
|
|
|
|
|
|
|
Assert.assertNotNull(results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(dependsOnMethods = "testAddDeviceTest")
|
|
|
|
|
|
|
|
public void getCountOfDevicesByEncryptionStatus() throws DeviceManagementDAOException, TransactionManagementException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
int results = deviceDAO.getCountOfDevicesByEncryptionStatus(TestDataHolder.SUPER_TENANT_ID, true);
|
|
|
|
|
|
|
|
Assert.assertEquals(0, results, "No device returned");
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|