use of org.wso2.carbon.apimgt.core.api.APIGateway in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImplTestCase method testAddPolicy.
@Test(description = "Add policy")
public void testAddPolicy() throws APIManagementException {
PolicyDAO policyDAO = Mockito.mock(PolicyDAO.class);
APIGateway apiGateway = Mockito.mock(APIGateway.class);
APIMgtAdminServiceImpl adminService = getAPIMgtAdminServiceImpl(policyDAO, apiGateway);
APIPolicy policy = SampleTestObjectCreator.createDefaultAPIPolicy();
adminService.addApiPolicy(policy);
Mockito.verify(policyDAO, Mockito.times(1)).addApiPolicy(policy);
// Error path
Mockito.doThrow(APIMgtDAOException.class).when(policyDAO).addApiPolicy(policy);
try {
adminService.addApiPolicy(policy);
} catch (APIManagementException e) {
Assert.assertEquals(e.getMessage(), "Couldn't add API policy for uuid: " + policy.getUuid());
}
}
use of org.wso2.carbon.apimgt.core.api.APIGateway in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImplTestCase method testAddPolicyWhenPolicyIdNull.
@Test(description = "Add policy when policy id is null")
public void testAddPolicyWhenPolicyIdNull() throws APIManagementException {
PolicyDAO policyDAO = Mockito.mock(PolicyDAO.class);
APIGateway apiGateway = Mockito.mock(APIGateway.class);
APIMgtAdminServiceImpl adminService = getAPIMgtAdminServiceImpl(policyDAO, apiGateway);
APIPolicy policy = SampleTestObjectCreator.createDefaultAPIPolicy();
policy.setUuid(null);
adminService.addApiPolicy(policy);
Mockito.verify(policyDAO, Mockito.times(1)).addApiPolicy(policy);
}
use of org.wso2.carbon.apimgt.core.api.APIGateway in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImplTestCase method testAddApplicationPolicyWhenPolicyIdNull.
@Test(description = "Test add application policy when the policy ID is null")
public void testAddApplicationPolicyWhenPolicyIdNull() throws APIManagementException {
PolicyDAO policyDAO = Mockito.mock(PolicyDAO.class);
APIGateway apiGateway = Mockito.mock(APIGateway.class);
APIMgtAdminServiceImpl adminService = getAPIMgtAdminServiceImpl(policyDAO, apiGateway);
ApplicationPolicy policy = SampleTestObjectCreator.createDefaultApplicationPolicy();
policy.setUuid(null);
adminService.addApplicationPolicy(policy);
Mockito.verify(policyDAO, Mockito.times(1)).addApplicationPolicy(policy);
}
use of org.wso2.carbon.apimgt.core.api.APIGateway in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImplTestCase method testAddSubscriptionPolicyWhenPolicyIdNull.
@Test(description = "Test add subscription policy when the policy ID is null")
public void testAddSubscriptionPolicyWhenPolicyIdNull() throws APIManagementException {
PolicyDAO policyDAO = Mockito.mock(PolicyDAO.class);
APIGateway apiGateway = Mockito.mock(APIGateway.class);
APIMgtAdminServiceImpl adminService = getAPIMgtAdminServiceImpl(policyDAO, apiGateway);
SubscriptionPolicy policy = SampleTestObjectCreator.createDefaultSubscriptionPolicy();
policy.setUuid(null);
adminService.addSubscriptionPolicy(policy);
Mockito.verify(policyDAO, Mockito.times(1)).addSubscriptionPolicy(policy);
}
use of org.wso2.carbon.apimgt.core.api.APIGateway in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImplTestCase method testUpdateApiPolicy.
@Test(description = "Test update API policy")
public void testUpdateApiPolicy() throws APIManagementException {
PolicyDAO policyDAO = Mockito.mock(PolicyDAO.class);
APIGateway apiGateway = Mockito.mock(APIGateway.class);
APIMgtAdminServiceImpl adminService = getAPIMgtAdminServiceImpl(policyDAO, apiGateway);
APIPolicy apiPolicy = SampleTestObjectCreator.createDefaultAPIPolicy();
adminService.updateApiPolicy(apiPolicy);
Mockito.verify(policyDAO, Mockito.times(1)).updateApiPolicy(apiPolicy);
// Error path
Mockito.doThrow(APIMgtDAOException.class).when(policyDAO).updateApiPolicy(apiPolicy);
try {
adminService.updateApiPolicy(apiPolicy);
} catch (APIManagementException e) {
Assert.assertEquals(e.getMessage(), "Couldn't update API policy for uuid: " + apiPolicy.getUuid());
}
}
Aggregations