use of org.wso2.carbon.apimgt.impl.importexport.lifecycle.LifeCycle in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testGetAPILifeCycleDataExceptionWhenRetrievingAPISummary.
@Test(description = "Could not retrieve api summary when Getting api lifecycle data", expectedExceptions = APIManagementException.class)
public void testGetAPILifeCycleDataExceptionWhenRetrievingAPISummary() throws APIManagementException, LifecycleException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO);
Mockito.when(apiDAO.getAPISummary(API_ID)).thenThrow(new APIMgtDAOException("Couldn't retrieve API Summary for " + API_ID));
apiPublisher.getAPILifeCycleData(API_ID);
}
use of org.wso2.carbon.apimgt.impl.importexport.lifecycle.LifeCycle in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testCreateNewAPIVersionAndCheckNewApiLifecycleAddFailure.
@Test(description = "Create new API version with APIID and new API lifecycle add get failed", expectedExceptions = { LifecycleException.class, APIManagementException.class })
public void testCreateNewAPIVersionAndCheckNewApiLifecycleAddFailure() throws APIManagementException, LifecycleException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APILifecycleManager apiLifecycleManager = Mockito.mock(APILifecycleManager.class);
API api = SampleTestObjectCreator.createDefaultAPI().build();
String uuid = api.getId();
APIGateway gateway = Mockito.mock(APIGateway.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO, apiLifecycleManager, gateway);
Mockito.when(apiDAO.getAPI(uuid)).thenReturn(api);
Mockito.when(apiLifecycleManager.addLifecycle(APIMgtConstants.API_LIFECYCLE, USER)).thenThrow(new LifecycleException(""));
apiPublisher.createNewAPIVersion(uuid, "2.0.0");
Mockito.verify(apiDAO, Mockito.times(0)).addAPI(api);
}
use of org.wso2.carbon.apimgt.impl.importexport.lifecycle.LifeCycle in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testGetLifeCycleEventsExceptionFindingApiSummaryResource.
@Test(description = "Exception finding APISummary Resource when getting lifecycle events list of an API", expectedExceptions = APIManagementException.class)
public void testGetLifeCycleEventsExceptionFindingApiSummaryResource() throws APIManagementException, LifecycleException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
Mockito.when(apiDAO.getAPISummary(API_ID)).thenThrow(new APIMgtDAOException("Couldn't find APISummary Resource for ID " + API_ID));
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO);
apiPublisher.getLifeCycleEvents(API_ID);
}
use of org.wso2.carbon.apimgt.impl.importexport.lifecycle.LifeCycle in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testGetAPILifeCycleDataForNullAPI.
@Test(description = "Get api lifecycle data for a null api", expectedExceptions = APIManagementException.class)
public void testGetAPILifeCycleDataForNullAPI() throws APIManagementException, LifecycleException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO);
Mockito.when(apiDAO.getAPISummary(API_ID)).thenThrow(new APIMgtDAOException("API with ID " + API_ID + " does not exist", ExceptionCodes.API_NOT_FOUND));
apiPublisher.getAPILifeCycleData(API_ID);
}
use of org.wso2.carbon.apimgt.impl.importexport.lifecycle.LifeCycle in project carbon-apimgt by wso2.
the class RestApiUtilTestCase method testGetErrorDTO.
@Test(description = "Testing get Error DTO")
public void testGetErrorDTO() throws Exception {
ErrorHandler errorHandler = Mockito.mock(ErrorHandler.class);
when(errorHandler.getErrorCode()).thenReturn((long) 900300);
when(errorHandler.getErrorMessage()).thenReturn("Lifecycle exception occurred");
when(errorHandler.getErrorDescription()).thenReturn("Error occurred while changing lifecycle state");
ErrorDTO errorDTOExpected = new ErrorDTO();
errorDTOExpected.setCode((long) 900300);
errorDTOExpected.setMessage("Lifecycle exception occurred");
errorDTOExpected.setDescription("Error occurred while changing lifecycle state");
ErrorDTO errorDTO1 = RestApiUtil.getErrorDTO(errorHandler);
Assert.assertEquals(errorDTO1.getCode(), errorDTOExpected.getCode());
Assert.assertEquals(errorDTO1.getMessage(), errorDTOExpected.getMessage());
Assert.assertEquals(errorDTO1.getDescription(), errorDTOExpected.getDescription());
}
Aggregations