use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method apisApiIdGatewayConfigGetWhenGatewayConfigNullTestCase.
@Test
public void apisApiIdGatewayConfigGetWhenGatewayConfigNullTestCase() throws Exception {
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
String apiID = UUID.randomUUID().toString();
String gatewayConfig = null;
Mockito.when(adminService.getAPIGatewayServiceConfig(apiID)).thenReturn(gatewayConfig);
APIManagerFactory instance = Mockito.mock(APIManagerFactory.class);
PowerMockito.mockStatic(APIManagerFactory.class);
PowerMockito.when(APIManagerFactory.getInstance()).thenReturn(instance);
Mockito.when(instance.getAPIMgtAdminService()).thenReturn(adminService);
Response response = apisApiService.apisApiIdGatewayConfigGet(apiID, null, getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method apisGetApisEmptyStatusTestCase.
@Test
public void apisGetApisEmptyStatusTestCase() throws Exception {
String labels = "ZONE_ONE,ZONE_TWO";
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
Response response = apisApiService.apisGet(labels, "", getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method apisGetApisEmptyLabelsTestCase.
@Test
public void apisGetApisEmptyLabelsTestCase() throws Exception {
String labels = "";
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
Response response = apisApiService.apisGet(labels, "Published", getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class ThreatProtectionPoliciesApiServiceImplTestCase method testThreatProtectionPoliciesGet.
@Test
public void testThreatProtectionPoliciesGet() throws Exception {
PowerMockito.mockStatic(APIManagerFactory.class);
APIManagerFactory apiManagerFactory = Mockito.mock(APIManagerFactory.class);
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.when(APIManagerFactory.getInstance()).thenReturn(apiManagerFactory);
Mockito.when(apiManagerFactory.getAPIMgtAdminService()).thenReturn(adminService);
List<ThreatProtectionPolicy> policyList = new ArrayList<>();
policyList.add(createThreatProtectionPolicy());
policyList.add(createThreatProtectionPolicy());
policyList.add(createThreatProtectionPolicy());
Mockito.when(adminService.getThreatProtectionPolicyList()).thenReturn(policyList);
ThreatProtectionPoliciesApiServiceImpl apiService = new ThreatProtectionPoliciesApiServiceImpl();
Response response = apiService.threatProtectionPoliciesGet(getRequest());
Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
// Error path
Mockito.when(adminService.getThreatProtectionPolicyList()).thenThrow(APIManagementException.class);
response = apiService.threatProtectionPoliciesGet(getRequest());
Assert.assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class ThreatProtectionPoliciesApiServiceImplTestCase method testThreatProtectionPoliciesThreatProtectionPolicyIdDelete.
@Test
public void testThreatProtectionPoliciesThreatProtectionPolicyIdDelete() throws Exception {
PowerMockito.mockStatic(APIManagerFactory.class);
APIManagerFactory apiManagerFactory = Mockito.mock(APIManagerFactory.class);
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.when(APIManagerFactory.getInstance()).thenReturn(apiManagerFactory);
Mockito.when(apiManagerFactory.getAPIMgtAdminService()).thenReturn(adminService);
ThreatProtectionPoliciesApiServiceImpl apiService = new ThreatProtectionPoliciesApiServiceImpl();
Response response = apiService.threatProtectionPoliciesThreatProtectionPolicyIdDelete("ID", getRequest());
Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
// Error path
Mockito.doThrow(APIManagementException.class).when(adminService).deleteThreatProtectionPolicy(Mockito.anyString());
response = apiService.threatProtectionPoliciesThreatProtectionPolicyIdDelete("ID", getRequest());
Assert.assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
}
Aggregations