Adding some testcases for the invalid devices, and parameters.

revert-70aa11f8
sinthuja 7 years ago
parent bd04e3d8b2
commit c5cfa23caa

@ -144,7 +144,8 @@ public class OperationManagementTests extends BaseDeviceManagementTest {
}
@Test(expectedExceptions = InvalidDeviceException.class)
public void addNonInitializedDevicesCommandOperation() throws DeviceManagementException, OperationManagementException,
public void addNonInitializedDevicesCommandOperation() throws DeviceManagementException,
OperationManagementException,
InvalidDeviceException {
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
@ -207,8 +208,8 @@ public class OperationManagementTests extends BaseDeviceManagementTest {
}
private void validateOperationResponse(Activity activity, ActivityStatus.Status expectedStatus) {
Assert.assertEquals(activity.getActivityStatus().size(), NO_OF_DEVICES, "The operation response for add operation only have - " +
activity.getActivityStatus().size());
Assert.assertEquals(activity.getActivityStatus().size(), NO_OF_DEVICES, "The operation response for add " +
"operation only have - " + activity.getActivityStatus().size());
for (ActivityStatus status : activity.getActivityStatus()) {
Assert.assertEquals(status.getStatus(), expectedStatus);
}
@ -223,7 +224,8 @@ public class OperationManagementTests extends BaseDeviceManagementTest {
}
@Test(dependsOnMethods = "addProfileOperation", expectedExceptions = OperationManagementException.class)
public void getOperationsAsNonAdmin() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
public void getOperationsAsNonAdmin() throws DeviceManagementException, OperationManagementException,
InvalidDeviceException {
try {
startTenantFlowAsNonAdmin();
for (DeviceIdentifier deviceIdentifier : deviceIds) {
@ -235,15 +237,18 @@ public class OperationManagementTests extends BaseDeviceManagementTest {
}
@Test(dependsOnMethods = "getOperations")
public void getPendingOperations() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
public void getPendingOperations() throws DeviceManagementException, OperationManagementException,
InvalidDeviceException {
for (DeviceIdentifier deviceIdentifier : deviceIds) {
List operations = this.operationMgtService.getPendingOperations(deviceIdentifier);
Assert.assertEquals(operations.size(), 4, "The pending operations should be 4, but found only " + operations.size());
Assert.assertEquals(operations.size(), 4, "The pending operations should be 4, but found only "
+ operations.size());
}
}
@Test(dependsOnMethods = "getOperations", expectedExceptions = OperationManagementException.class)
public void getPendingOperationsAsNonAdmin() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
public void getPendingOperationsAsNonAdmin() throws DeviceManagementException, OperationManagementException,
InvalidDeviceException {
try {
startTenantFlowAsNonAdmin();
for (DeviceIdentifier deviceIdentifier : deviceIds) {
@ -384,12 +389,14 @@ public class OperationManagementTests extends BaseDeviceManagementTest {
@Test(dependsOnMethods = "getOperationByDeviceAndOperationId")
public void getOperationsByDeviceAndStatus() throws OperationManagementException, DeviceManagementException {
DeviceIdentifier deviceIdentifier = this.deviceIds.get(0);
List operation = this.operationMgtService.getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING);
List operation = this.operationMgtService.getOperationsByDeviceAndStatus(deviceIdentifier,
Operation.Status.PENDING);
Assert.assertEquals(operation.size(), 3);
}
@Test(dependsOnMethods = "getOperationByDeviceAndOperationId", expectedExceptions = OperationManagementException.class)
public void getOperationsByDeviceAndStatusByNonAdmin() throws OperationManagementException, DeviceManagementException {
public void getOperationsByDeviceAndStatusByNonAdmin() throws OperationManagementException,
DeviceManagementException {
startTenantFlowAsNonAdmin();
try {
DeviceIdentifier deviceIdentifier = this.deviceIds.get(0);
@ -476,7 +483,8 @@ public class OperationManagementTests extends BaseDeviceManagementTest {
}
@Test(dependsOnMethods = "getOperationForInactiveDevice", expectedExceptions = OperationManagementException.class)
public void getPaginatedOperationDeviceForInvalidDevice() throws DeviceManagementException, OperationManagementException {
public void getPaginatedOperationDeviceForInvalidDevice() throws DeviceManagementException,
OperationManagementException {
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID, true);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(ADMIN_USER);
@ -484,7 +492,8 @@ public class OperationManagementTests extends BaseDeviceManagementTest {
PaginationRequest request = new PaginationRequest(1, 2);
request.setDeviceType(DEVICE_TYPE);
request.setOwner(ADMIN_USER);
PaginationResult result = this.operationMgtService.getOperations(new DeviceIdentifier(INVALID_DEVICE, DEVICE_TYPE), request);
PaginationResult result = this.operationMgtService.getOperations
(new DeviceIdentifier(INVALID_DEVICE, DEVICE_TYPE), request);
Assert.assertEquals(result.getRecordsFiltered(), 4);
Assert.assertEquals(result.getData().size(), 2);
Assert.assertEquals(result.getRecordsTotal(), 4);
@ -494,45 +503,58 @@ public class OperationManagementTests extends BaseDeviceManagementTest {
}
@Test(dependsOnMethods = "getOperationForInactiveDevice", expectedExceptions = OperationManagementException.class)
public void getPendingOperationDeviceForInvalidDevice() throws DeviceManagementException, OperationManagementException {
public void getPendingOperationDeviceForInvalidDevice() throws DeviceManagementException,
OperationManagementException {
this.operationMgtService.getPendingOperations(new DeviceIdentifier(INVALID_DEVICE, DEVICE_TYPE));
}
@Test(dependsOnMethods = "getPendingOperationDeviceForInvalidDevice", expectedExceptions = OperationManagementException.class)
public void getNextPendingOperationDeviceForInvalidDevice() throws DeviceManagementException, OperationManagementException {
@Test(dependsOnMethods = "getPendingOperationDeviceForInvalidDevice",
expectedExceptions = OperationManagementException.class)
public void getNextPendingOperationDeviceForInvalidDevice() throws DeviceManagementException,
OperationManagementException {
this.operationMgtService.getNextPendingOperation(new DeviceIdentifier(INVALID_DEVICE, DEVICE_TYPE));
}
@Test(dependsOnMethods = "getNextPendingOperationDeviceForInvalidDevice", expectedExceptions = OperationManagementException.class)
@Test(dependsOnMethods = "getNextPendingOperationDeviceForInvalidDevice",
expectedExceptions = OperationManagementException.class)
public void getUpdateOperationForInvalidDevice() throws DeviceManagementException, OperationManagementException {
this.operationMgtService.updateOperation(new DeviceIdentifier(INVALID_DEVICE, DEVICE_TYPE), getOperation(new CommandOperation(),
Operation.Type.COMMAND, COMMAND_OPERATON_CODE));
this.operationMgtService.updateOperation(new DeviceIdentifier(INVALID_DEVICE, DEVICE_TYPE),
getOperation(new CommandOperation(), Operation.Type.COMMAND, COMMAND_OPERATON_CODE));
}
@Test(dependsOnMethods = "getUpdateOperationForInvalidDevice", expectedExceptions = OperationManagementException.class)
public void getOperationByDeviceAndOperationIdInvalidDevice() throws DeviceManagementException, OperationManagementException {
@Test(dependsOnMethods = "getUpdateOperationForInvalidDevice",
expectedExceptions = OperationManagementException.class)
public void getOperationByDeviceAndOperationIdInvalidDevice() throws DeviceManagementException,
OperationManagementException {
this.operationMgtService.getOperationByDeviceAndOperationId(new DeviceIdentifier(INVALID_DEVICE, DEVICE_TYPE),
getOperationId(this.commandActivity.getActivityId()));
}
@Test(dependsOnMethods = "getOperationByDeviceAndOperationIdInvalidDevice", expectedExceptions = OperationManagementException.class)
public void getOperationsByDeviceAndStatusInvalidDevice() throws DeviceManagementException, OperationManagementException {
@Test(dependsOnMethods = "getOperationByDeviceAndOperationIdInvalidDevice",
expectedExceptions = OperationManagementException.class)
public void getOperationsByDeviceAndStatusInvalidDevice() throws DeviceManagementException,
OperationManagementException {
this.operationMgtService.getOperationsByDeviceAndStatus(new DeviceIdentifier(INVALID_DEVICE, DEVICE_TYPE),
Operation.Status.PENDING);
}
@Test(dependsOnMethods = "getOperationsByDeviceAndStatusInvalidDevice", expectedExceptions = OperationManagementException.class)
public void getOperationsInvalidOperationId() throws DeviceManagementException, OperationManagementException {
@Test(dependsOnMethods = "getOperationsByDeviceAndStatusInvalidDevice",
expectedExceptions = OperationManagementException.class)
public void getOperationsInvalidOperationId() throws DeviceManagementException,
OperationManagementException {
this.operationMgtService.getOperation(123445);
}
@Test(dependsOnMethods = "getOperationsInvalidOperationId", expectedExceptions = IllegalArgumentException.class)
public void getOperationsByActivityIdInvalidActivityId() throws DeviceManagementException, OperationManagementException {
public void getOperationsByActivityIdInvalidActivityId() throws DeviceManagementException,
OperationManagementException {
this.operationMgtService.getOperationByActivityId(DeviceManagementConstants.OperationAttributes.ACTIVITY + 0);
}
@Test(dependsOnMethods = "getOperationsByActivityIdInvalidActivityId", expectedExceptions = IllegalArgumentException.class)
public void getOperationByActivityIdAndDeviceInvalidActivityId() throws DeviceManagementException, OperationManagementException {
@Test(dependsOnMethods = "getOperationsByActivityIdInvalidActivityId",
expectedExceptions = IllegalArgumentException.class)
public void getOperationByActivityIdAndDeviceInvalidActivityId() throws DeviceManagementException,
OperationManagementException {
this.operationMgtService.getOperationByActivityIdAndDevice(DeviceManagementConstants.OperationAttributes.ACTIVITY + 0,
new DeviceIdentifier(INVALID_DEVICE, DEVICE_TYPE));
}

Loading…
Cancel
Save