use of org.wso2.carbon.apimgt.core.models.DedicatedGateway in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testUpdateDedicatedGatewayWhenDedicatedGatewayIsDisabledAndAPIHasOwnGateway.
@Test(description = "Update dedicated gateway when dedicated gateway is disabled and api has own gateway")
public void testUpdateDedicatedGatewayWhenDedicatedGatewayIsDisabledAndAPIHasOwnGateway() throws APIManagementException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
LabelDAO labelDAO = Mockito.mock(LabelDAO.class);
API api = SampleTestObjectCreator.createDefaultAPI().hasOwnGateway(true).lifeCycleStatus(APIStatus.PUBLISHED.getStatus()).build();
String uuid = api.getId();
Mockito.when(apiDAO.getAPI(uuid)).thenReturn(api);
APIStoreImpl apiStore = getApiStoreImpl(apiDAO, labelDAO);
DedicatedGateway dedicatedGateway = SampleTestObjectCreator.createDedicatedGateway(uuid, false, api.getCreatedBy());
apiStore.updateDedicatedGateway(dedicatedGateway);
List<String> labelSet = new ArrayList<>();
labelSet.add(APIMgtConstants.DEFAULT_LABEL_NAME);
Mockito.verify(apiDAO, Mockito.times(1)).updateDedicatedGateway(dedicatedGateway, labelSet);
}
use of org.wso2.carbon.apimgt.core.models.DedicatedGateway in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testUpdateDedicatedGateway.
@Test(description = "Update dedicated gateway")
public void testUpdateDedicatedGateway() 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;
Mockito.when(labelDAO.getLabelByName(autoGenLabelName)).thenReturn(null);
APIStoreImpl apiStore = getApiStoreImpl(apiDAO, labelDAO);
DedicatedGateway dedicatedGateway = SampleTestObjectCreator.createDedicatedGateway(uuid, true, api.getCreatedBy());
apiStore.updateDedicatedGateway(dedicatedGateway);
List<String> labelSet = new ArrayList<>();
labelSet.add(autoGenLabelName);
Mockito.verify(apiDAO, Mockito.times(1)).updateDedicatedGateway(dedicatedGateway, labelSet);
Mockito.verify(labelDAO, Mockito.times(1)).addLabels(Mockito.anyList());
}
use of org.wso2.carbon.apimgt.core.models.DedicatedGateway in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testUpdateDedicatedGatewayForException.
@Test(description = "Update dedicated gateway for exception", expectedExceptions = APIManagementException.class)
public void testUpdateDedicatedGatewayForException() 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;
Mockito.when(labelDAO.getLabelByName(autoGenLabelName)).thenReturn(null);
APIStoreImpl apiStore = getApiStoreImpl(apiDAO, labelDAO);
DedicatedGateway dedicatedGateway = SampleTestObjectCreator.createDedicatedGateway(uuid, true, api.getCreatedBy());
List<String> labelSet = new ArrayList<>();
labelSet.add(autoGenLabelName);
Mockito.doThrow(APIMgtDAOException.class).when(apiDAO).updateDedicatedGateway(dedicatedGateway, labelSet);
apiStore.updateDedicatedGateway(dedicatedGateway);
}
use of org.wso2.carbon.apimgt.core.models.DedicatedGateway in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testUpdateDedicatedGatewayWhenLabelIsNotNull.
@Test(description = "Update dedicated gateway when label is not null and present in the system")
public void testUpdateDedicatedGatewayWhenLabelIsNotNull() 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;
Label label = new Label.Builder().id(java.util.UUID.randomUUID().toString()).name(autoGenLabelName).accessUrls(null).build();
Mockito.when(labelDAO.getLabelByName(autoGenLabelName)).thenReturn(label);
APIStoreImpl apiStore = getApiStoreImpl(apiDAO, labelDAO);
DedicatedGateway dedicatedGateway = SampleTestObjectCreator.createDedicatedGateway(uuid, true, api.getCreatedBy());
apiStore.updateDedicatedGateway(dedicatedGateway);
List<String> labelSet = new ArrayList<>();
labelSet.add(autoGenLabelName);
Mockito.verify(apiDAO, Mockito.times(1)).updateDedicatedGateway(dedicatedGateway, labelSet);
Mockito.verify(labelDAO, Mockito.times(0)).addLabels(Mockito.anyList());
}
use of org.wso2.carbon.apimgt.core.models.DedicatedGateway 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);
}
Aggregations