mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Changing the policy test cases
This commit is contained in:
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() {
|
|
||||||
Assert.assertEquals("A", "A");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@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 device")
|
||||||
public void testAddPolicy() {
|
public void testAddPolicy() throws FeatureManagementException, PolicyManagementException {
|
||||||
try {
|
Assert.assertEquals(policyManagement.addPolicyToDevice("1212-ESDD-12ER-7890", "MD", policy), 0);
|
||||||
Assert.assertEquals(policyManagement.addPolicyToDevice("1212-ESDD-12ER-7890", "MD", policy), 0);
|
}
|
||||||
} catch (FeatureManagementException e) {
|
|
||||||
log.error("Feature management exception happened.", e);
|
@Test(groups = "policy.mgt.test", description = "Testing the adding policy to a device type")
|
||||||
Assert.fail();
|
public void testAddPolicyToDeviceType() throws FeatureManagementException, PolicyManagementException {
|
||||||
} catch (PolicyManagementException e) {
|
Assert.assertEquals(policyManagement.addPolicyToDeviceType("MD", policy), 0);
|
||||||
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 {
|
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…
Reference in New Issue
Block a user