@Test(dependsOnMethods = "activatePolicy")
public void applyPolicy() throws PolicyManagementException, OperationManagementException {

    new DelegationTask().execute();
    Policy appliedPolicy = policyManagerService.getAppliedPolicyToDevice(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A));
    Assert.assertEquals(appliedPolicy.getPolicyName(), POLICY1, POLICY1 + " was not applied on " + DEVICE1);
    List<? extends Operation> operations = operationManager.getPendingOperations(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A));
    boolean policyOperationFound = false;
    for (Operation operation : operations) {
        if (policyOperationFound) {
            break;
        }
        if (PolicyOperation.POLICY_OPERATION_CODE.equals(operation.getCode())) {
            Object o = operation.getPayLoad();
            if (o instanceof ArrayList) {
                ArrayList profileOps = (ArrayList) o;
                for (Object op : profileOps) {
                    if (op instanceof ProfileOperation) {
                        ProfileOperation profileOperation = (ProfileOperation) op;
                        if (POLICY1_FEATURE1_CODE.equals(profileOperation.getCode())) {
                            policyOperationFound = true;
                            break;
                        }
                    }
                }
            }
        }
    }
    Assert.assertTrue(policyOperationFound, "Policy operation for " + POLICY1 + " was not added to " + DEVICE1);
}