Fixing bugs when getting device by status and adding test cases

4.x.x
Ace 7 years ago
parent 04ef82520f
commit 66c4a345fd

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

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

@ -388,6 +388,17 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
Assert.assertTrue(device != null); 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"}) @Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
public void testDeviceByDateWithNonExistentDevice() throws DeviceManagementException, public void testDeviceByDateWithNonExistentDevice() throws DeviceManagementException,
TransactionManagementException, DeviceDetailsMgtDAOException { TransactionManagementException, DeviceDetailsMgtDAOException {
@ -466,6 +477,12 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"}) @Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
public void testGetAllDevicesByStatus() throws DeviceManagementException { 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); PaginationRequest request = new PaginationRequest(0, 100);
request.setStatus(EnrolmentInfo.Status.ACTIVE.toString()); request.setStatus(EnrolmentInfo.Status.ACTIVE.toString());
PaginationResult result = deviceMgtService.getDevicesByStatus(request, true); PaginationResult result = deviceMgtService.getDevicesByStatus(request, true);

Loading…
Cancel
Save