Search in sources :

Example 76 with ApiDAO

use of org.wso2.carbon.apimgt.core.dao.ApiDAO 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"));
}
Also used : ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) Test(org.testng.annotations.Test)

Example 77 with ApiDAO

use of org.wso2.carbon.apimgt.core.dao.ApiDAO 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);
}
Also used : ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) Test(org.testng.annotations.Test)

Example 78 with ApiDAO

use of org.wso2.carbon.apimgt.core.dao.ApiDAO 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);
}
Also used : ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) Test(org.testng.annotations.Test)

Example 79 with ApiDAO

use of org.wso2.carbon.apimgt.core.dao.ApiDAO 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);
}
Also used : APILifecycleManager(org.wso2.carbon.apimgt.core.api.APILifecycleManager) HashMap(java.util.HashMap) API(org.wso2.carbon.apimgt.core.models.API) APIGateway(org.wso2.carbon.apimgt.core.api.APIGateway) ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) Test(org.testng.annotations.Test)

Example 80 with ApiDAO

use of org.wso2.carbon.apimgt.core.dao.ApiDAO 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);
}
Also used : APILifecycleManager(org.wso2.carbon.apimgt.core.api.APILifecycleManager) APISubscriptionDAO(org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO) API(org.wso2.carbon.apimgt.core.models.API) LifecycleState(org.wso2.carbon.lcm.core.impl.LifecycleState) APIGateway(org.wso2.carbon.apimgt.core.api.APIGateway) ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) Test(org.testng.annotations.Test)

Aggregations

ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)315 Test (org.testng.annotations.Test)305 API (org.wso2.carbon.apimgt.core.models.API)210 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)108 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)102 APILifecycleManager (org.wso2.carbon.apimgt.core.api.APILifecycleManager)75 GatewaySourceGenerator (org.wso2.carbon.apimgt.core.api.GatewaySourceGenerator)65 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)62 APIBuilder (org.wso2.carbon.apimgt.core.models.API.APIBuilder)59 BeforeTest (org.testng.annotations.BeforeTest)50 ArrayList (java.util.ArrayList)48 IdentityProvider (org.wso2.carbon.apimgt.core.api.IdentityProvider)47 Endpoint (org.wso2.carbon.apimgt.core.models.Endpoint)46 LabelDAO (org.wso2.carbon.apimgt.core.dao.LabelDAO)45 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)43 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)36 HashMap (java.util.HashMap)31 SQLException (java.sql.SQLException)30 PolicyDAO (org.wso2.carbon.apimgt.core.dao.PolicyDAO)30 LifecycleState (org.wso2.carbon.lcm.core.impl.LifecycleState)27