use of org.wso2.carbon.bpel.core.ode.integration.jmx.Instance in project carbon-apimgt by wso2.
the class RestApiUtil method handleBadRequest.
/**
* Logs the error, builds a BadRequestException with specified details and throws it
*
* @param msg error message
* @param log Log instance
* @throws BadRequestException If 400 bad request comes.
*/
public static void handleBadRequest(String msg, Logger log) throws BadRequestException {
BadRequestException badRequestException = buildBadRequestException(msg);
log.error(msg);
throw badRequestException;
}
use of org.wso2.carbon.bpel.core.ode.integration.jmx.Instance 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.bpel.core.ode.integration.jmx.Instance in project carbon-apimgt by wso2.
the class ApplicationsApiServiceImplTestCase method applicationsGetExceptionTestCase.
@Test
public void applicationsGetExceptionTestCase() throws Exception {
ApplicationsApiServiceImpl applicationsApiService = new ApplicationsApiServiceImpl();
String message = "Error while retrieving applications.";
APIManagerFactory instance = Mockito.mock(APIManagerFactory.class);
PowerMockito.mockStatic(APIManagerFactory.class);
PowerMockito.when(APIManagerFactory.getInstance()).thenReturn(instance);
APIManagementException apiManagementException = new APIManagementException(message, ExceptionCodes.APPLICATION_NOT_FOUND);
Mockito.when(instance.getAPIMgtAdminService()).thenThrow(apiManagementException);
Response response = applicationsApiService.applicationsGet(null, getRequest());
Assert.assertEquals(response.getStatus(), 404);
}
use of org.wso2.carbon.bpel.core.ode.integration.jmx.Instance in project carbon-apimgt by wso2.
the class BlacklistApiServiceImplTestCase method applicationsGetExceptionTestCase.
@Test
public void applicationsGetExceptionTestCase() throws Exception {
BlacklistApiServiceImpl blacklistApiService = new BlacklistApiServiceImpl();
String message = "Error while retrieving applications.";
APIManagerFactory instance = Mockito.mock(APIManagerFactory.class);
PowerMockito.mockStatic(APIManagerFactory.class);
PowerMockito.when(APIManagerFactory.getInstance()).thenReturn(instance);
APIManagementException apiManagementException = new APIManagementException(message, ExceptionCodes.APPLICATION_INACTIVE);
Mockito.when(instance.getAPIMgtAdminService()).thenThrow(apiManagementException);
Response response = blacklistApiService.blacklistGet(null, getRequest());
Assert.assertEquals(response.getStatus(), 400);
}
use of org.wso2.carbon.bpel.core.ode.integration.jmx.Instance in project carbon-apimgt by wso2.
the class EndpointsApiServiceImplTestCase method endpointsEndpointIdGatewayConfigGetExceptionTest.
@Test
public void endpointsEndpointIdGatewayConfigGetExceptionTest() throws Exception {
EndpointsApiServiceImpl endpointsApiService = new EndpointsApiServiceImpl();
String message = "Error while retrieving gateway configuration.";
APIManagerFactory instance = Mockito.mock(APIManagerFactory.class);
PowerMockito.mockStatic(APIManagerFactory.class);
PowerMockito.when(APIManagerFactory.getInstance()).thenReturn(instance);
APIManagementException apiManagementException = new APIManagementException(message, ExceptionCodes.ENDPOINT_CONFIG_NOT_FOUND);
Mockito.when(instance.getAPIMgtAdminService()).thenThrow(apiManagementException);
String endpointId = UUID.randomUUID().toString();
Response response = endpointsApiService.endpointsEndpointIdGatewayConfigGet(endpointId, null, getRequest());
Assert.assertEquals(response.getStatus(), 404);
}
Aggregations