PolicyManagerServiceImpl implements PolicyManagerService { @Override public boolean checkCompliance(DeviceIdentifier deviceIdentifier, Object response) throws PolicyComplianceException { List<ComplianceFeature> complianceFeatures = monitoringManager.checkPolicyCompliance(deviceIdentifier, response); if(complianceFeatures == null || complianceFeatures.isEmpty()) { return true; } else { return false; } } 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 = "applyPolicy") public void checkCompliance() throws PolicyComplianceException, DeviceManagementException { new MonitoringTask().execute(); List<ComplianceFeature> complianceFeatures = new ArrayList<>(); ComplianceFeature complianceFeature = new ComplianceFeature(); ProfileFeature profileFeature = new ProfileFeature(); profileFeature.setContent("{'enable':'false'}"); profileFeature.setDeviceType(DEVICE_TYPE_A); profileFeature.setFeatureCode(POLICY1_FEATURE1_CODE); complianceFeature.setFeature(profileFeature); complianceFeature.setFeatureCode(profileFeature.getFeatureCode()); complianceFeature.setMessage("Test message"); complianceFeature.setCompliance(true); complianceFeatures.add(complianceFeature); Device device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider(). getDevice(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A), false); List<Device> deviceList = new ArrayList<>(); deviceList.add(device); MonitoringManager manager = new MonitoringManagerImpl(); manager.addMonitoringOperation(deviceList); policyManagerService.checkCompliance(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A), complianceFeatures); boolean deviceCompliance = policyManagerService.isCompliant(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A)); Assert.assertTrue(deviceCompliance, "Policy was not compliant"); }