PolicyManagerServiceImpl implements PolicyManagerService { @Override public Policy getAppliedPolicyToDevice( DeviceIdentifier deviceIdentifier) throws PolicyManagementException { return policyManager.getAppliedPolicyToDevice(deviceIdentifier); } PolicyManagerServiceImpl(); @Override Profile addProfile(Profile profile); @Override Profile updateProfile(Profile profile); @Override Policy addPolicy(Policy policy); @Override Policy updatePolicy(Policy policy); @Override boolean deletePolicy(Policy policy); @Override boolean deletePolicy(int policyId); @Override Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier); @Override List<ProfileFeature> getEffectiveFeatures(DeviceIdentifier deviceIdentifier); @Override List<Policy> getPolicies(String deviceType); @Override List<Feature> getFeatures(); @Override PolicyAdministratorPoint getPAP(); @Override PolicyInformationPoint getPIP(); @Override PolicyEvaluationPoint getPEP(); @Override TaskScheduleService getTaskScheduleService(); @Override int getPolicyCount(); @Override Policy getAppliedPolicyToDevice(
            DeviceIdentifier deviceIdentifier); @Override List<ComplianceFeature> checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Object
            deviceResponse); @Override boolean checkCompliance(DeviceIdentifier deviceIdentifier, Object response); @Override NonComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier); @Override boolean isCompliant(DeviceIdentifier deviceIdentifier);  }
@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); }