use of org.wso2.carbon.apimgt.rest.api.admin.NotFoundException in project carbon-apimgt by wso2.
the class BlacklistApiServiceImplTest method blacklistConditionIdGetTest.
@Test
public void blacklistConditionIdGetTest() throws APIManagementException, NotFoundException {
printTestMethodName();
BlacklistApiServiceImpl blacklistApiService = new BlacklistApiServiceImpl();
String uuid = UUID.randomUUID().toString();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
BlockConditions conditions = new BlockConditions();
conditions.setUuid(uuid);
Mockito.doReturn(conditions).doThrow(new IllegalArgumentException()).when(adminService).getBlockConditionByUUID(uuid);
Response response = blacklistApiService.blacklistConditionIdGet(uuid, null, null, getRequest());
Assert.assertEquals(response.getStatus(), 200);
}
use of org.wso2.carbon.apimgt.rest.api.admin.NotFoundException in project carbon-apimgt by wso2.
the class PoliciesApiServiceImplTest method policiesThrottlingCustomRuleIdDeleteTest.
@Test
public void policiesThrottlingCustomRuleIdDeleteTest() throws APIManagementException, NotFoundException {
printTestMethodName();
PoliciesApiServiceImpl policiesApiService = new PoliciesApiServiceImpl();
String uuid = UUID.randomUUID().toString();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
Mockito.doNothing().doThrow(new IllegalArgumentException()).when(adminService).deleteCustomRule(uuid);
Response response = policiesApiService.policiesThrottlingCustomRuleIdDelete(uuid, null, null, getRequest());
Assert.assertEquals(response.getStatus(), 200);
}
use of org.wso2.carbon.apimgt.rest.api.admin.NotFoundException in project carbon-apimgt by wso2.
the class PoliciesApiServiceImplTest method policiesThrottlingCustomRuleIdGetTest.
@Test
public void policiesThrottlingCustomRuleIdGetTest() throws APIManagementException, NotFoundException {
printTestMethodName();
PoliciesApiServiceImpl policiesApiService = new PoliciesApiServiceImpl();
String uuid = UUID.randomUUID().toString();
CustomPolicy policy = new CustomPolicy(uuid, "Policy");
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
Mockito.doReturn(policy).doThrow(new IllegalArgumentException()).when(adminService).getCustomRuleByUUID(uuid);
Response response = policiesApiService.policiesThrottlingCustomRuleIdGet(uuid, null, null, getRequest());
Assert.assertEquals(response.getStatus(), 200);
}
use of org.wso2.carbon.apimgt.rest.api.admin.NotFoundException in project carbon-apimgt by wso2.
the class PoliciesApiServiceImplTest method policiesThrottlingAdvancedPolicyIdGetTest.
@Test
public void policiesThrottlingAdvancedPolicyIdGetTest() throws APIManagementException, NotFoundException {
printTestMethodName();
PoliciesApiServiceImpl policiesApiService = new PoliciesApiServiceImpl();
String uuid = UUID.randomUUID().toString();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
APIPolicy policy1 = new APIPolicy(uuid, "samplePolicy1");
policy1.setDescription("Sample Policy");
policy1.setDeployed(true);
policy1.setDisplayName("Simple Policy");
Mockito.doReturn(policy1).doThrow(new IllegalArgumentException()).when(adminService).getApiPolicyByUuid(uuid);
Response response = policiesApiService.policiesThrottlingAdvancedIdGet(uuid, null, null, getRequest());
Assert.assertEquals(response.getStatus(), 200);
}
use of org.wso2.carbon.apimgt.rest.api.admin.NotFoundException in project carbon-apimgt by wso2.
the class PoliciesApiServiceImplTest method policiesThrottlingCustomRuleIdPutTest.
@Test
public void policiesThrottlingCustomRuleIdPutTest() throws APIManagementException, NotFoundException {
printTestMethodName();
PoliciesApiServiceImpl policiesApiService = new PoliciesApiServiceImpl();
String uuid = UUID.randomUUID().toString();
CustomPolicy policy = new CustomPolicy(uuid, "Policy");
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
Mockito.doNothing().doThrow(new IllegalArgumentException()).when(adminService).updateCustomRule(policy);
Mockito.doReturn(policy).doThrow(new IllegalArgumentException()).when(adminService).getCustomRuleByUUID(uuid);
CustomRuleDTO dto = CustomPolicyMappingUtil.fromCustomPolicyToDTO(policy);
Response response = policiesApiService.policiesThrottlingCustomRuleIdPut(uuid, dto, null, null, getRequest());
Assert.assertEquals(response.getStatus(), 200);
}
Aggregations