From b9b3c4ff43684ef1d7ab6c0d6f662ee80974fef7 Mon Sep 17 00:00:00 2001 From: sinthuja Date: Thu, 28 Sep 2017 17:20:29 +0530 Subject: [PATCH] Adding more testcases for non existing device Ids. --- .../core/operation/OperationManagementTests.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java index c06f4ae70f..9ba56c160a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java @@ -343,6 +343,17 @@ public class OperationManagementTests extends BaseDeviceManagementTest { Assert.assertTrue(operation.getType().equals(Operation.Type.POLICY)); } + @Test(dependsOnMethods = "updateOperation", expectedExceptions = OperationManagementException.class) + public void getNextPendingOperationAsNonAdmin() throws OperationManagementException { + startTenantFlowAsNonAdmin(); + try { + DeviceIdentifier deviceIdentifier = this.deviceIds.get(0); + this.operationMgtService.getNextPendingOperation(deviceIdentifier); + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + } + @Test(dependsOnMethods = "getNextPendingOperation") public void getOperationByDeviceAndOperationId() throws OperationManagementException { DeviceIdentifier deviceIdentifier = this.deviceIds.get(0); @@ -485,4 +496,9 @@ public class OperationManagementTests extends BaseDeviceManagementTest { this.operationMgtService.getPendingOperations(new DeviceIdentifier(INVALID_DEVICE, DEVICE_TYPE)); } + @Test(dependsOnMethods = "getPendingOperationDeviceForInvalidDevice", expectedExceptions = OperationManagementException.class) + public void getNextPendingOperationDeviceForInvalidDevice() throws DeviceManagementException, OperationManagementException { + this.operationMgtService.getNextPendingOperation(new DeviceIdentifier(INVALID_DEVICE, DEVICE_TYPE)); + } + }