Search in sources :

Example 31 with CustomPolicy

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);
}
Also used : CustomPolicy(org.wso2.carbon.apimgt.core.models.policy.CustomPolicy) PolicyDAO(org.wso2.carbon.apimgt.core.dao.PolicyDAO) Test(org.testng.annotations.Test)

Example 32 with CustomPolicy

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);
}
Also used : CustomRuleDTO(org.wso2.carbon.apimgt.rest.api.admin.dto.CustomRuleDTO) CustomPolicy(org.wso2.carbon.apimgt.core.models.policy.CustomPolicy) Test(org.testng.annotations.Test)

Aggregations

CustomPolicy (org.wso2.carbon.apimgt.core.models.policy.CustomPolicy)29 Test (org.testng.annotations.Test)12 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)10 PolicyDAO (org.wso2.carbon.apimgt.core.dao.PolicyDAO)7 ArrayList (java.util.ArrayList)6 CustomRuleDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.CustomRuleDTO)6 APIMgtAdminService (org.wso2.carbon.apimgt.core.api.APIMgtAdminService)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Connection (java.sql.Connection)4 PreparedStatement (java.sql.PreparedStatement)4 SQLException (java.sql.SQLException)4 Response (javax.ws.rs.core.Response)4 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)4 APIMgtAdminServiceImpl (org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl)4 PoliciesApiServiceImpl (org.wso2.carbon.apimgt.rest.api.admin.impl.PoliciesApiServiceImpl)4 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)4 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2