use of org.wso2.carbon.apimgt.rest.api.admin.impl.PoliciesApiServiceImpl 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);
}
use of org.wso2.carbon.apimgt.rest.api.admin.impl.PoliciesApiServiceImpl in project carbon-apimgt by wso2.
the class PoliciesApiServiceImplTest method policiesThrottlingAdvancedPolicyIdDeleteTest.
@Test
public void policiesThrottlingAdvancedPolicyIdDeleteTest() 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).deletePolicyByUuid(uuid, APIMgtAdminService.PolicyLevel.api);
Response response = policiesApiService.policiesThrottlingAdvancedIdDelete(uuid, null, null, getRequest());
Assert.assertEquals(response.getStatus(), 200);
}
use of org.wso2.carbon.apimgt.rest.api.admin.impl.PoliciesApiServiceImpl in project carbon-apimgt by wso2.
the class PoliciesApiServiceImplTest method policiesThrottlingApplicationPolicyIdPutTest.
@Test
public void policiesThrottlingApplicationPolicyIdPutTest() throws APIManagementException, NotFoundException {
printTestMethodName();
PoliciesApiServiceImpl policiesApiService = new PoliciesApiServiceImpl();
String uuid = UUID.randomUUID().toString();
ApplicationThrottlePolicyDTO dto = new ApplicationThrottlePolicyDTO();
ApplicationPolicy policy = ApplicationThrottlePolicyMappingUtil.fromApplicationThrottlePolicyDTOToModel(dto);
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
Mockito.doNothing().doThrow(new IllegalArgumentException()).when(adminService).updateApplicationPolicy(policy);
Mockito.doReturn(policy).doThrow(new IllegalArgumentException()).when(adminService).getApplicationPolicyByUuid(uuid);
Response response = policiesApiService.policiesThrottlingApplicationIdPut(uuid, dto, null, null, getRequest());
Assert.assertEquals(response.getStatus(), 200);
}
use of org.wso2.carbon.apimgt.rest.api.admin.impl.PoliciesApiServiceImpl in project carbon-apimgt by wso2.
the class PoliciesApiServiceImplTest method policiesThrottlingCustomGetTest.
@Test
public void policiesThrottlingCustomGetTest() throws APIManagementException, NotFoundException {
printTestMethodName();
PoliciesApiServiceImpl policiesApiService = new PoliciesApiServiceImpl();
CustomPolicy policy1 = new CustomPolicy(UUID.randomUUID().toString(), "SamplePolicy1");
CustomPolicy policy2 = new CustomPolicy(UUID.randomUUID().toString(), "SamplePolicy2");
List<CustomPolicy> policies = new ArrayList<>();
policies.add(policy1);
policies.add(policy2);
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
Mockito.doReturn(policies).doThrow(new IllegalArgumentException()).when(adminService).getCustomRules();
Response response = policiesApiService.policiesThrottlingCustomGet(null, null, getRequest());
Assert.assertEquals(response.getStatus(), 200);
}
use of org.wso2.carbon.apimgt.rest.api.admin.impl.PoliciesApiServiceImpl in project carbon-apimgt by wso2.
the class PoliciesApiServiceImplTest method policiesThrottlingSubscriptionPolicyIdGetTest.
@Test
public void policiesThrottlingSubscriptionPolicyIdGetTest() throws APIManagementException, NotFoundException {
printTestMethodName();
PoliciesApiServiceImpl policiesApiService = new PoliciesApiServiceImpl();
String uuid = UUID.randomUUID().toString();
SubscriptionPolicy policy = new SubscriptionPolicy(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).getSubscriptionPolicyByUuid(uuid);
Response response = policiesApiService.policiesThrottlingSubscriptionIdGet(uuid, null, null, getRequest());
Assert.assertEquals(response.getStatus(), 200);
}
Aggregations