Changing the policy test cases

revert-70aa11f8
Geeth Munasinghe 10 years ago
parent ee030e136d
commit 6f79ae79e2

@ -24,6 +24,11 @@ import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.common.spi.PolicyManagerService; import org.wso2.carbon.policy.mgt.common.spi.PolicyManagerService;
public class PolicyManagement implements PolicyManagerService { public class PolicyManagement implements PolicyManagerService {
@Override
public int addPolicy(Policy policy) {
return 0;
}
@Override @Override
public int addPolicyToDevice(String deviceId, String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException { public int addPolicyToDevice(String deviceId, String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException {
return 0; return 0;
@ -39,6 +44,11 @@ public class PolicyManagement implements PolicyManagerService {
return 0; return 0;
} }
@Override
public Policy getPolicy() {
return null;
}
@Override @Override
public Policy getPolicyOfDevice(String deviceId, String deviceType) throws FeatureManagementException, PolicyManagementException { public Policy getPolicyOfDevice(String deviceId, String deviceType) throws FeatureManagementException, PolicyManagementException {
return null; return null;

@ -28,13 +28,20 @@ import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
public interface PolicyManagerService { public interface PolicyManagerService {
// void addPolicy(Policy policy); /**
* This method adds a policy to the platform
* @param policy
* @return
*/
int addPolicy(Policy policy);
/** /**
* This method adds a policy per device which should be implemented by the related plugins. * This method adds a policy per device which should be implemented by the related plugins.
* @param deviceId * @param deviceId
* @param deviceType * @param deviceType
* @param policy * @param policy
* @return
*/ */
int addPolicyToDevice(String deviceId, String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException; int addPolicyToDevice(String deviceId, String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException;
@ -43,6 +50,7 @@ public interface PolicyManagerService {
* This method adds a policy to device type by the related device type plugins. * This method adds a policy to device type by the related device type plugins.
* @param deviceType * @param deviceType
* @param policy * @param policy
* @return
*/ */
int addPolicyToDeviceType(String deviceType,Policy policy) throws FeatureManagementException, PolicyManagementException; int addPolicyToDeviceType(String deviceType,Policy policy) throws FeatureManagementException, PolicyManagementException;
@ -51,10 +59,16 @@ public interface PolicyManagerService {
* This method adds the policy to specific role. * This method adds the policy to specific role.
* @param roleName * @param roleName
* @param policy * @param policy
* @return
*/ */
int addPolicyToRole(String roleName, Policy policy) throws FeatureManagementException, PolicyManagementException; int addPolicyToRole(String roleName, Policy policy) throws FeatureManagementException, PolicyManagementException;
// Policy getPolicy(); /**
* This method returns the policy of whole platform
* @return
*/
Policy getPolicy();
/** /**
* This method gives the device specific policy. * This method gives the device specific policy.

@ -32,28 +32,24 @@ public class PolicyManagementTestCase {
private static final Log log = LogFactory.getLog(PolicyManagementTestCase.class); private static final Log log = LogFactory.getLog(PolicyManagementTestCase.class);
PolicyCreator creator = new PolicyCreator(); Policy policy = PolicyCreator.createPolicy();
Policy policy = creator.getPolicy();
private PolicyManagement policyManagement = new PolicyManagement(); private PolicyManagement policyManagement = new PolicyManagement();
@Test(groups = "policy.mgt.test", description = "Testing the first test case with testng.")
public void testPolicy() { @Test(groups = "policy.mgt.test", description = "Testing the adding policy to a device")
Assert.assertEquals("A", "A"); public void testAddPolicy() throws FeatureManagementException, PolicyManagementException {
Assert.assertEquals(policyManagement.addPolicyToDevice("1212-ESDD-12ER-7890", "MD", policy), 0);
} }
@Test(groups = "policy.mgt.test", description = "Testing the adding policy to a device type")
public void testAddPolicyToDeviceType() throws FeatureManagementException, PolicyManagementException {
Assert.assertEquals(policyManagement.addPolicyToDeviceType("MD", policy), 0);
}
@Test(groups = "policy.mgt.test", description = "Testing the adding policy to a device") @Test(groups = "policy.mgt.test", description = "Testing the adding policy to a user Role")
public void testAddPolicy() { public void testAddPolicyToRole() throws FeatureManagementException, PolicyManagementException {
try { Assert.assertEquals(policyManagement.addPolicyToRole("Admin", policy), 0);
Assert.assertEquals(policyManagement.addPolicyToDevice("1212-ESDD-12ER-7890", "MD", policy), 0);
} catch (FeatureManagementException e) {
log.error("Feature management exception happened.", e);
Assert.fail();
} catch (PolicyManagementException e) {
log.error("Policy management exception happened.", e);
Assert.fail();
}
} }
} }

@ -26,13 +26,9 @@ import java.util.List;
public class PolicyCreator { public class PolicyCreator {
private Policy policy = new Policy(); private static Policy policy = new Policy();
public PolicyCreator() { public static Policy createPolicy() {
createPolicy();
}
private void createPolicy() {
Feature feature = new Feature(); Feature feature = new Feature();
feature.setName("Camera"); feature.setName("Camera");
@ -45,9 +41,6 @@ public class PolicyCreator {
policy.setFeaturesList(featureList); policy.setFeaturesList(featureList);
policy.setPolicyName("Camera_related_policy"); policy.setPolicyName("Camera_related_policy");
}
public Policy getPolicy() {
return policy; return policy;
} }

Loading…
Cancel
Save