Merge pull request #1062 from ruwany/master

Fixing bugs when getting device by status and adding test cases
revert-70aa11f8
Geeth 7 years ago committed by GitHub
commit f34eb4d8fb

@ -1062,9 +1062,9 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
conn = this.getConnection();
String sql = "SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME AS DEVICE_NAME, t.NAME AS DEVICE_TYPE, " +
"d.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
"e.DATE_OF_ENROLMENT FROM (SELECT e.ID, e.DEVICE_ID, e.OWNER, e.OWNERSHIP, e.STATUS, " +
"e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e " +
"WHERE TENANT_ID = ? AND STATUS = ?) e, DM_DEVICE d, DM_DEVICE_TYPE t " +
"e.DATE_OF_ENROLMENT, e.ENROLMENT_ID FROM (SELECT e.ID, e.DEVICE_ID, e.OWNER, e" +
".OWNERSHIP, e.STATUS, e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE, e.ID AS " +
"ENROLMENT_ID FROM DM_ENROLMENT e WHERE TENANT_ID = ? AND STATUS = ?) e, DM_DEVICE d, DM_DEVICE_TYPE t " +
"WHERE DEVICE_ID = e.DEVICE_ID AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, tenantId);

@ -95,7 +95,7 @@ public class TestDeviceManager implements DeviceManager {
@Override
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device)
throws DeviceManagementException {
return false;
return true;
}
@Override

@ -388,6 +388,17 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
Assert.assertTrue(device != null);
}
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
public void testUpdateDeviceInfo() throws DeviceManagementException,
TransactionManagementException, DeviceDetailsMgtDAOException {
Device device = deviceMgtService.getDevice(new DeviceIdentifier(DEVICE_ID,
DEVICE_TYPE));
boolean status = deviceMgtService.updateDeviceInfo(new DeviceIdentifier(DEVICE_ID,
DEVICE_TYPE), device);
Assert.assertTrue(status);
}
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
public void testDeviceByDateWithNonExistentDevice() throws DeviceManagementException,
TransactionManagementException, DeviceDetailsMgtDAOException {
@ -466,6 +477,12 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
public void testGetAllDevicesByStatus() throws DeviceManagementException {
List<Device> devices = deviceMgtService.getDevicesByStatus(EnrolmentInfo.Status.ACTIVE);
Assert.assertTrue(!devices.isEmpty());
}
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
public void testGetDevicesByStatus() throws DeviceManagementException {
PaginationRequest request = new PaginationRequest(0, 100);
request.setStatus(EnrolmentInfo.Status.ACTIVE.toString());
PaginationResult result = deviceMgtService.getDevicesByStatus(request, true);

Loading…
Cancel
Save