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;
public class PolicyManagement implements PolicyManagerService {
@Override
public int addPolicy(Policy policy) {
return 0;
}
@Override
public int addPolicyToDevice(String deviceId, String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException {
return 0;
@ -39,6 +44,11 @@ public class PolicyManagement implements PolicyManagerService {
return 0;
}
@Override
public Policy getPolicy() {
return null;
}
@Override
public Policy getPolicyOfDevice(String deviceId, String deviceType) throws FeatureManagementException, PolicyManagementException {
return null;

@ -28,13 +28,20 @@ import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
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.
* @param deviceId
* @param deviceType
* @param policy
* @return
*/
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.
* @param deviceType
* @param policy
* @return
*/
int addPolicyToDeviceType(String deviceType,Policy policy) throws FeatureManagementException, PolicyManagementException;
@ -51,10 +59,16 @@ public interface PolicyManagerService {
* This method adds the policy to specific role.
* @param roleName
* @param policy
* @return
*/
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.

@ -32,28 +32,24 @@ public class PolicyManagementTestCase {
private static final Log log = LogFactory.getLog(PolicyManagementTestCase.class);
PolicyCreator creator = new PolicyCreator();
Policy policy = creator.getPolicy();
Policy policy = PolicyCreator.createPolicy();
private PolicyManagement policyManagement = new PolicyManagement();
@Test(groups = "policy.mgt.test", description = "Testing the first test case with testng.")
public void testPolicy() {
Assert.assertEquals("A", "A");
@Test(groups = "policy.mgt.test", description = "Testing the adding policy to a device")
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")
public void testAddPolicy() {
try {
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();
}
@Test(groups = "policy.mgt.test", description = "Testing the adding policy to a user Role")
public void testAddPolicyToRole() throws FeatureManagementException, PolicyManagementException {
Assert.assertEquals(policyManagement.addPolicyToRole("Admin", policy), 0);
}
}

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

Loading…
Cancel
Save