|
|
@ -89,7 +89,7 @@ public class DeviceTypeManagementServiceTest {
|
|
|
|
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
|
|
|
|
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
|
|
|
|
.toReturn(this.deviceManagementProviderService);
|
|
|
|
.toReturn(this.deviceManagementProviderService);
|
|
|
|
Mockito.when(this.deviceManagementProviderService.getDeviceTypes()).thenThrow(new DeviceManagementException());
|
|
|
|
Mockito.when(this.deviceManagementProviderService.getDeviceTypes()).thenThrow(new DeviceManagementException());
|
|
|
|
Response response = this.deviceTypeManagementService.getDeviceTypes();
|
|
|
|
Response response = this.deviceTypeManagementService.getDeviceTypes(MODIFIED_SINCE);
|
|
|
|
Assert.assertNotNull(response, "The response object is null.");
|
|
|
|
Assert.assertNotNull(response, "The response object is null.");
|
|
|
|
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
|
|
|
|
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
|
|
|
|
"The response status should be 500.");
|
|
|
|
"The response status should be 500.");
|
|
|
@ -100,7 +100,7 @@ public class DeviceTypeManagementServiceTest {
|
|
|
|
public void testExistingDeviceTypesModifiedError() throws Exception {
|
|
|
|
public void testExistingDeviceTypesModifiedError() throws Exception {
|
|
|
|
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
|
|
|
|
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
|
|
|
|
.toReturn(this.deviceManagementProviderService);
|
|
|
|
.toReturn(this.deviceManagementProviderService);
|
|
|
|
Mockito.when(this.deviceManagementProviderService.getAvailableDeviceTypes()).thenThrow(new
|
|
|
|
Mockito.when(this.deviceManagementProviderService.getDeviceTypes()).thenThrow(new
|
|
|
|
DeviceManagementException());
|
|
|
|
DeviceManagementException());
|
|
|
|
Response response = this.deviceTypeManagementService.getDeviceTypes(MODIFIED_SINCE);
|
|
|
|
Response response = this.deviceTypeManagementService.getDeviceTypes(MODIFIED_SINCE);
|
|
|
|
Assert.assertNotNull(response, "The response object is null.");
|
|
|
|
Assert.assertNotNull(response, "The response object is null.");
|
|
|
@ -142,8 +142,9 @@ public class DeviceTypeManagementServiceTest {
|
|
|
|
Mockito.when(this.deviceManagementProviderService.getFeatureManager(Mockito.anyString())).thenReturn(null);
|
|
|
|
Mockito.when(this.deviceManagementProviderService.getFeatureManager(Mockito.anyString())).thenReturn(null);
|
|
|
|
Response response = this.deviceTypeManagementService.getFeatures(TEST_DEVICE_TYPE, MODIFIED_SINCE);
|
|
|
|
Response response = this.deviceTypeManagementService.getFeatures(TEST_DEVICE_TYPE, MODIFIED_SINCE);
|
|
|
|
Assert.assertNotNull(response, "The response object is null.");
|
|
|
|
Assert.assertNotNull(response, "The response object is null.");
|
|
|
|
Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode(),
|
|
|
|
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),
|
|
|
|
"The response status should be 404.");
|
|
|
|
"The response status should be 200.");
|
|
|
|
|
|
|
|
Assert.assertEquals(response.getEntity().toString(), "[]", "The response should be [].");
|
|
|
|
Mockito.reset(deviceManagementProviderService);
|
|
|
|
Mockito.reset(deviceManagementProviderService);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -151,7 +152,7 @@ public class DeviceTypeManagementServiceTest {
|
|
|
|
public void testGetDeviceTypes() throws Exception {
|
|
|
|
public void testGetDeviceTypes() throws Exception {
|
|
|
|
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
|
|
|
|
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
|
|
|
|
.toReturn(this.deviceManagementProviderService);
|
|
|
|
.toReturn(this.deviceManagementProviderService);
|
|
|
|
Response response = this.deviceTypeManagementService.getDeviceTypes();
|
|
|
|
Response response = this.deviceTypeManagementService.getDeviceTypes(MODIFIED_SINCE);
|
|
|
|
Assert.assertNotNull(response, "The response object is null.");
|
|
|
|
Assert.assertNotNull(response, "The response object is null.");
|
|
|
|
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),
|
|
|
|
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),
|
|
|
|
"The response status should be 200.");
|
|
|
|
"The response status should be 200.");
|
|
|
@ -163,7 +164,7 @@ public class DeviceTypeManagementServiceTest {
|
|
|
|
.toReturn(this.deviceManagementProviderService);
|
|
|
|
.toReturn(this.deviceManagementProviderService);
|
|
|
|
List<DeviceType> deviceTypes = DeviceMgtAPITestHelper.getDummyDeviceTypeList(5);
|
|
|
|
List<DeviceType> deviceTypes = DeviceMgtAPITestHelper.getDummyDeviceTypeList(5);
|
|
|
|
Mockito.when(this.deviceManagementProviderService.getDeviceTypes()).thenReturn(deviceTypes);
|
|
|
|
Mockito.when(this.deviceManagementProviderService.getDeviceTypes()).thenReturn(deviceTypes);
|
|
|
|
Response response = this.deviceTypeManagementService.getDeviceTypes();
|
|
|
|
Response response = this.deviceTypeManagementService.getDeviceTypes(MODIFIED_SINCE);
|
|
|
|
Assert.assertNotNull(response, "The response object is null.");
|
|
|
|
Assert.assertNotNull(response, "The response object is null.");
|
|
|
|
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),
|
|
|
|
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),
|
|
|
|
"The response state should be 200");
|
|
|
|
"The response state should be 200");
|
|
|
|