Search in sources :

Example 76 with LabelDAO

use of org.wso2.carbon.apimgt.core.dao.LabelDAO in project carbon-apimgt by wso2.

the class APIStoreImplTestCase method getAllLabels.

@Test(description = "get all labels")
public void getAllLabels() throws Exception {
    LabelDAO labelDao = Mockito.mock(LabelDAO.class);
    APIStore apiStore = getApiStoreImpl(labelDao);
    List<Label> labels = new ArrayList<>();
    Label label = new Label.Builder().id("123").name("Default").type("STORE").accessUrls(new ArrayList<>()).build();
    labels.add(label);
    Mockito.when(labelDao.getLabels()).thenReturn(labels);
    List<Label> returnedLabels = apiStore.getAllLabels();
    Assert.assertNotNull(returnedLabels);
    Mockito.verify(labelDao, Mockito.atLeastOnce()).getLabels();
}
Also used : Label(org.wso2.carbon.apimgt.core.models.Label) ArrayList(java.util.ArrayList) LabelDAO(org.wso2.carbon.apimgt.core.dao.LabelDAO) APIStore(org.wso2.carbon.apimgt.core.api.APIStore) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 77 with LabelDAO

use of org.wso2.carbon.apimgt.core.dao.LabelDAO in project carbon-apimgt by wso2.

the class APIStoreImplTestCase method testUpdateDedicatedGatewayWhenDedicatedGatewayIsDisabled.

@Test(description = "Update dedicated gateway when dedicated gateway is disabled")
public void testUpdateDedicatedGatewayWhenDedicatedGatewayIsDisabled() throws APIManagementException {
    ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
    LabelDAO labelDAO = Mockito.mock(LabelDAO.class);
    API api = SampleTestObjectCreator.createDefaultAPI().lifeCycleStatus(APIStatus.PUBLISHED.getStatus()).build();
    String uuid = api.getId();
    Mockito.when(apiDAO.getAPI(uuid)).thenReturn(api);
    String autoGenLabelName = ContainerBasedGatewayConstants.PRIVATE_JET_API_PREFIX + uuid;
    APIStoreImpl apiStore = getApiStoreImpl(apiDAO, labelDAO);
    DedicatedGateway dedicatedGateway = SampleTestObjectCreator.createDedicatedGateway(uuid, false, api.getCreatedBy());
    apiStore.updateDedicatedGateway(dedicatedGateway);
    List<String> labelSet = new ArrayList<>();
    labelSet.add(autoGenLabelName);
    Mockito.verify(apiDAO, Mockito.times(0)).updateDedicatedGateway(dedicatedGateway, labelSet);
}
Also used : ArrayList(java.util.ArrayList) CompositeAPI(org.wso2.carbon.apimgt.core.models.CompositeAPI) API(org.wso2.carbon.apimgt.core.models.API) LabelDAO(org.wso2.carbon.apimgt.core.dao.LabelDAO) ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) DedicatedGateway(org.wso2.carbon.apimgt.core.models.DedicatedGateway) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

LabelDAO (org.wso2.carbon.apimgt.core.dao.LabelDAO)71 Test (org.testng.annotations.Test)70 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)45 API (org.wso2.carbon.apimgt.core.models.API)44 ArrayList (java.util.ArrayList)33 Label (org.wso2.carbon.apimgt.core.models.Label)33 GatewaySourceGenerator (org.wso2.carbon.apimgt.core.api.GatewaySourceGenerator)28 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)26 APILifecycleManager (org.wso2.carbon.apimgt.core.api.APILifecycleManager)26 APIBuilder (org.wso2.carbon.apimgt.core.models.API.APIBuilder)26 Endpoint (org.wso2.carbon.apimgt.core.models.Endpoint)17 PolicyDAO (org.wso2.carbon.apimgt.core.dao.PolicyDAO)16 LifecycleState (org.wso2.carbon.lcm.core.impl.LifecycleState)15 HashMap (java.util.HashMap)14 DedicatedGateway (org.wso2.carbon.apimgt.core.models.DedicatedGateway)14 APIPolicy (org.wso2.carbon.apimgt.core.models.policy.APIPolicy)14 BeforeTest (org.testng.annotations.BeforeTest)13 IdentityProvider (org.wso2.carbon.apimgt.core.api.IdentityProvider)11 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)11 WorkflowExtensionsConfigBuilder (org.wso2.carbon.apimgt.core.workflow.WorkflowExtensionsConfigBuilder)11