use of org.wso2.carbon.apimgt.core.models.policy.CustomPolicy in project carbon-apimgt by wso2.
the class PolicyDAOImplIT method testAddGetUpdateDeleteCustomPolicy.
@Test
public void testAddGetUpdateDeleteCustomPolicy() throws Exception {
PolicyDAO policyDAO = DAOFactory.getPolicyDAO();
CustomPolicy customPolicy = SampleTestObjectCreator.createDefaultCustomPolicy();
String uuid = policyDAO.addCustomPolicy(customPolicy);
CustomPolicy policyAdded = policyDAO.getCustomPolicyByUuid(uuid);
Assert.assertEquals(customPolicy.getSiddhiQuery(), policyAdded.getSiddhiQuery());
policyAdded.setDescription("updated custom policy");
policyDAO.updateCustomPolicy(policyAdded);
Assert.assertEquals(policyDAO.getCustomPolicyByUuid(uuid).getDescription(), "updated custom policy");
policyDAO.deleteCustomPolicy(uuid);
CustomPolicy policyDeletion = policyDAO.getCustomPolicyByUuid(uuid);
Assert.assertNull(policyDeletion);
}
use of org.wso2.carbon.apimgt.core.models.policy.CustomPolicy in project carbon-apimgt by wso2.
the class CustomPolicyMappingUtilTest method fromCustomPolicyDTOToModelTest.
@Test(description = "Convert DTO to Model")
public void fromCustomPolicyDTOToModelTest() throws Exception {
CustomRuleDTO dto = new CustomRuleDTO();
dto.setPolicyName(name);
CustomPolicy policy = CustomPolicyMappingUtil.fromCustomPolicyDTOToModel(dto);
Assert.assertNotNull(policy);
Assert.assertEquals(policy.getPolicyName(), name);
}
Aggregations