From eb734a4b1456f2cafd5435bd3dd5e766b4ac6d3e Mon Sep 17 00:00:00 2001 From: Geeth Munasinghe Date: Mon, 8 Dec 2014 15:42:59 +0530 Subject: [PATCH] Changing the policy interface and test case --- .../mgt/core/DeviceManagementTestCase.java | 19 +++--- .../mgt/common/spi/PolicyManagerService.java | 59 ++++++++++++++++++- 2 files changed, 64 insertions(+), 14 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementTestCase.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementTestCase.java index c096f0bd4..dae28fdfe 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementTestCase.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementTestCase.java @@ -18,23 +18,20 @@ package org.wso2.carbon.device.mgt.core; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.Test; -public class DeviceManagementTestCase extends TestCase { +import static org.junit.Assert.assertEquals; + +public class DeviceManagementTestCase { private static final Log log = LogFactory.getLog(DeviceManagementTestCase.class); - /** - * @return the suite of tests being tested - */ - public static Test suite() { - return new TestSuite(DeviceManagementTestCase.class); + @Test + public void setUp() throws Exception { + log.info("Testing started."); + assertEquals("A", "A"); } - - } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyManagerService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyManagerService.java index 7fd3bf5dc..9cb5ea373 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyManagerService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyManagerService.java @@ -20,11 +20,64 @@ package org.wso2.carbon.policy.mgt.common.spi; import org.wso2.carbon.policy.mgt.common.Policy; +/** + * This interface defines the policy management which should be implemented by the plugins + */ + public interface PolicyManagerService { - void addPolicy(Policy policy); + // void addPolicy(Policy policy); + + /** + * This method adds a policy per device which should be implemented by the related plugins. + * @param deviceId + * @param deviceType + * @param policy + */ + + void addPolicyToDevice(String deviceId, String deviceType, Policy policy); + + /** + * This method adds a policy to device type by the related device type plugins. + * @param deviceType + * @param policy + */ + + void addPolicyToDeviceType(String deviceType,Policy policy); + + /** + * This method adds the policy to specific role. + * @param roleName + * @param policy + */ + void addPolicyToRole(String roleName, Policy policy); + + // Policy getPolicy(); + + /** + * This method gives the device specific policy. + * @param deviceId + * @param deviceType + * @return Policy + */ + + Policy getPolicyOfDevice(String deviceId, String deviceType); + + /** + * This method returns the device type specific policy. + * @param deviceType + * @return Policy + */ + + Policy getPolicyOfDeviceType(String deviceType); + + /** + * This method returns the role specific policy. + * @param roleName + * @return + */ + + Policy getPolicyOfRole(String roleName); - void addPolicy(String deviceId, String deviceType, Policy policy); - void addPolicy(String deviceType,Policy policy); }