use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.
the class APIGatewayPublisherImplTestCase method testDeleteAPIWhenLabelAreEmpty.
@Test
public void testDeleteAPIWhenLabelAreEmpty() throws GatewayException, ContainerBasedGatewayException {
APIGatewayPublisherImpl apiGatewayPublisher = new APIGatewayPublisherImpl();
Broker broker = Mockito.mock(BrokerImpl.class, Mockito.RETURNS_DEEP_STUBS);
BrokerUtil.initialize(broker);
ContainerBasedGatewayGenerator containerBasedGatewayGenerator = Mockito.mock(ContainerBasedGatewayGenerator.class);
apiGatewayPublisher.setContainerBasedGatewayGenerator(containerBasedGatewayGenerator);
List<String> labels = new ArrayList<>();
API api = SampleTestObjectCreator.createDefaultAPI().lifeCycleStatus(APIStatus.PUBLISHED.getStatus()).hasOwnGateway(true).labels(labels).build();
apiGatewayPublisher.deleteAPI(api);
Mockito.verify(containerBasedGatewayGenerator, Mockito.times(0)).removeContainerBasedGateway("label", api);
}
use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.
the class APIGatewayPublisherImplTestCase method testDeleteAPIWhenAPIHasOwnGateway.
@Test
public void testDeleteAPIWhenAPIHasOwnGateway() throws GatewayException, ContainerBasedGatewayException {
APIGatewayPublisherImpl apiGatewayPublisher = new APIGatewayPublisherImpl();
Broker broker = Mockito.mock(BrokerImpl.class, Mockito.RETURNS_DEEP_STUBS);
BrokerUtil.initialize(broker);
ContainerBasedGatewayGenerator containerBasedGatewayGenerator = Mockito.mock(ContainerBasedGatewayGenerator.class);
apiGatewayPublisher.setContainerBasedGatewayGenerator(containerBasedGatewayGenerator);
List<String> labels = new ArrayList<>();
labels.add("label");
API api = SampleTestObjectCreator.createDefaultAPI().lifeCycleStatus(APIStatus.PUBLISHED.getStatus()).hasOwnGateway(true).labels(labels).build();
apiGatewayPublisher.deleteAPI(api);
Mockito.verify(containerBasedGatewayGenerator, Mockito.times(1)).removeContainerBasedGateway("label", api);
}
use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImplTestCase method testDeleteLabel.
@Test(description = "Delete a label")
public void testDeleteLabel() throws APIManagementException {
LabelDAO labelDAO = Mockito.mock(LabelDAO.class);
APIMgtAdminServiceImpl adminService = getAPIMgtAdminServiceImpl(labelDAO);
Label label = SampleTestObjectCreator.createLabel("Public", SampleTestObjectCreator.LABEL_TYPE_STORE).build();
String labelId = label.getId();
adminService.deleteLabel(labelId);
Mockito.verify(labelDAO, Mockito.times(1)).deleteLabel(labelId);
}
use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImplTestCase method testRegisterGatewayLabelsWhenOverwriteLabelsNull.
@Test(description = "Register gateway labels when overwriteLabels value is null")
public void testRegisterGatewayLabelsWhenOverwriteLabelsNull() throws APIManagementException {
LabelDAO labelDAO = Mockito.mock(LabelDAO.class);
List<Label> labels = new ArrayList<>();
Label label1 = SampleTestObjectCreator.createLabel("testLabel1", SampleTestObjectCreator.LABEL_TYPE_STORE).build();
labels.add(label1);
APIMgtAdminServiceImpl adminService = getAPIMgtAdminServiceImpl(labelDAO);
adminService.registerGatewayLabels(labels, null);
Mockito.verify(labelDAO, Mockito.times(1)).addLabels(labels);
}
use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImplTestCase method testDeleteLabelException.
@Test(description = "Exception when deleting a label", expectedExceptions = APIManagementException.class)
public void testDeleteLabelException() throws APIManagementException {
LabelDAO labelDAO = Mockito.mock(LabelDAO.class);
APIMgtAdminServiceImpl adminService = getAPIMgtAdminServiceImpl(labelDAO);
Label label = SampleTestObjectCreator.createLabel("Public", SampleTestObjectCreator.LABEL_TYPE_STORE).build();
String labelId = label.getId();
Mockito.doThrow(new APIMgtDAOException("Error occurred while deleting label [labelId] " + labelId)).when(labelDAO).deleteLabel(labelId);
adminService.deleteLabel(labelId);
Mockito.verify(labelDAO, Mockito.times(1)).deleteLabel(labelId);
}
Aggregations