Merge branch 'master' of https://github.com/geethkokila/product-cdm
commit
518892fedd
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.policy.mgt.common.impl;
|
||||||
|
|
||||||
|
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||||
|
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 addPolicyToDevice(String deviceId, String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int addPolicyToDeviceType(String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int addPolicyToRole(String roleName, Policy policy) throws FeatureManagementException, PolicyManagementException {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Policy getPolicyOfDevice(String deviceId, String deviceType) throws FeatureManagementException, PolicyManagementException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Policy getPolicyOfDeviceType(String deviceType) throws FeatureManagementException, PolicyManagementException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Policy getPolicyOfRole(String roleName) throws FeatureManagementException, PolicyManagementException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wos2.carbon.policy.mgt.common;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import org.wos2.carbon.policy.mgt.common.utils.PolicyCreator;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.impl.PolicyManagement;
|
||||||
|
|
||||||
|
public class PolicyManagementTestCase {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(PolicyManagementTestCase.class);
|
||||||
|
|
||||||
|
PolicyCreator creator = new PolicyCreator();
|
||||||
|
Policy policy = creator.getPolicy();
|
||||||
|
|
||||||
|
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() {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wos2.carbon.policy.mgt.common.utils;
|
||||||
|
|
||||||
|
import org.wso2.carbon.policy.mgt.common.Feature;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PolicyCreator {
|
||||||
|
|
||||||
|
private Policy policy = new Policy();
|
||||||
|
|
||||||
|
public PolicyCreator() {
|
||||||
|
createPolicy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createPolicy() {
|
||||||
|
|
||||||
|
Feature feature = new Feature();
|
||||||
|
feature.setName("Camera");
|
||||||
|
feature.setCode("502A");
|
||||||
|
feature.setAttribute("disable");
|
||||||
|
|
||||||
|
List<Feature> featureList = new ArrayList<Feature>();
|
||||||
|
featureList.add(feature);
|
||||||
|
|
||||||
|
policy.setFeaturesList(featureList);
|
||||||
|
policy.setPolicyName("Camera_related_policy");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Policy getPolicy() {
|
||||||
|
return policy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue