use of org.wso2.carbon.apimgt.core.exception.APIManagementException in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testCheckIfAPIExistForValidUuid.
@Test(description = "Check if api exist with valid uuid")
public void testCheckIfAPIExistForValidUuid() throws APIManagementException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO);
Mockito.when(apiDAO.isAPIExists("zzzzz")).thenReturn(true);
Assert.assertTrue(apiPublisher.isAPIExists("zzzzz"));
}
use of org.wso2.carbon.apimgt.core.exception.APIManagementException in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testGetLastUpdatedTimeOfEndpoint.
@Test(description = "Get last updated time of endpoint")
public void testGetLastUpdatedTimeOfEndpoint() throws APIManagementException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO);
Mockito.when(apiDAO.getLastUpdatedTimeOfEndpoint(ENDPOINT_ID)).thenReturn("2017-03-19T13:45:30");
apiPublisher.getLastUpdatedTimeOfEndpoint(ENDPOINT_ID);
Mockito.verify(apiDAO, Mockito.times(1)).getLastUpdatedTimeOfEndpoint(ENDPOINT_ID);
}
use of org.wso2.carbon.apimgt.core.exception.APIManagementException in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testRemoveDocumentationInfo.
@Test(description = "Remove Documentation Info")
public void testRemoveDocumentationInfo() throws APIManagementException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO);
apiPublisher.removeDocumentation(DOC_ID);
Mockito.verify(apiDAO, Mockito.times(1)).deleteDocument(DOC_ID);
}
use of org.wso2.carbon.apimgt.core.exception.APIManagementException in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testUpdateCheckListItem.
@Test(description = "Update checklist item")
public void testUpdateCheckListItem() throws APIManagementException, LifecycleException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APILifecycleManager apiLifecycleManager = Mockito.mock(APILifecycleManager.class);
APIGateway gateway = Mockito.mock(APIGateway.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO, apiLifecycleManager, gateway);
API api = SampleTestObjectCreator.createDefaultAPI().build();
String uuid = api.getId();
String lifecycleId = api.getLifecycleInstanceId();
Mockito.when(apiDAO.getAPI(uuid)).thenReturn(api);
Map<String, Boolean> checklist = new HashMap<>();
checklist.put(APIMgtConstants.DEPRECATE_PREVIOUS_VERSIONS, true);
apiPublisher.updateCheckListItem(uuid, APIStatus.CREATED.getStatus(), checklist);
Mockito.verify(apiLifecycleManager, Mockito.times(1)).checkListItemEvent(lifecycleId, APIStatus.CREATED.getStatus(), APIMgtConstants.DEPRECATE_PREVIOUS_VERSIONS, true);
}
use of org.wso2.carbon.apimgt.core.exception.APIManagementException in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testCreateNewAPIVersion.
@Test(description = "Create new API version with valid APIID")
public void testCreateNewAPIVersion() 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);
APISubscriptionDAO apiSubscriptionDAO = Mockito.mock(APISubscriptionDAO.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO, apiSubscriptionDAO, apiLifecycleManager, gateway);
Mockito.when(apiDAO.getAPI(uuid)).thenReturn(api);
Mockito.when(apiSubscriptionDAO.getAPISubscriptionsByAPI(api.getId())).thenReturn(new ArrayList<>());
Mockito.when(apiLifecycleManager.addLifecycle(APIMgtConstants.API_LIFECYCLE, USER)).thenReturn(new LifecycleState());
String newUUid = apiPublisher.createNewAPIVersion(uuid, "2.0.0");
Mockito.verify(apiDAO, Mockito.times(1)).getAPI(uuid);
Mockito.verify(apiDAO, Mockito.times(0)).addAPI(api);
Assert.assertNotEquals(uuid, newUUid);
}
Aggregations