use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method getLabelsByType.
@Test(description = "get labels by STORE type")
public void getLabelsByType() throws Exception {
LabelDAO labelDao = Mockito.mock(LabelDAO.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(labelDao);
Mockito.when(labelDao.getLabelsByType("GATEWAY")).thenReturn(new ArrayList<Label>());
apiPublisher.getLabelsByType("GATEWAY");
Mockito.verify(labelDao, Mockito.times(1)).getLabelsByType("GATEWAY");
}
use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.
the class LabelMappingUtil method fromLabelToDTO.
/**
* Converts a single Label model object into DTO object.
*
* @param label Label model object
* @return DTO object derived from the label model object
*/
public static LabelDTO fromLabelToDTO(Label label) {
LabelDTO labelDTO = new LabelDTO();
labelDTO.accessUrls(label.getAccessUrls());
labelDTO.description(label.getDescription());
labelDTO.setName(label.getName());
labelDTO.labelUUID(label.getId());
labelDTO.setType(label.getType());
return labelDTO;
}
use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.
the class LabelsApiServiceImplTest method testLabelsPost.
@Test
public void testLabelsPost() throws Exception {
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
Label label1 = new Label.Builder().id("1").name("label1").type("GATEWAY").build();
LabelsApiServiceImpl labelService = new LabelsApiServiceImpl();
Mockito.when(labelService.labelsPost(LabelMappingUtil.fromLabelToDTO(label1), "application/json", getRequest())).thenReturn(Response.status(Response.Status.CREATED).entity(LabelMappingUtil.fromLabelToDTO(label1)).build());
Response response = labelService.labelsPost(LabelMappingUtil.fromLabelToDTO(label1), "application/json", getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.CREATED);
}
use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.
the class LabelsApiServiceImplTest method testLabelsLabelIdPut.
@Test
public void testLabelsLabelIdPut() throws Exception {
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
List<Label> labels = new ArrayList<>();
Label label1 = new Label.Builder().id("1").name("label1").type("GATEWAY").build();
Label label2 = new Label.Builder().id("2").name("label2").type("STORE").build();
labels.add(label1);
labels.add(label2);
LabelsApiServiceImpl labelService = new LabelsApiServiceImpl();
Mockito.when(labelService.labelsLabelIdPut("1", LabelMappingUtil.fromLabelToDTO(label1), "application/Json", getRequest())).thenReturn(Response.status(Response.Status.OK).entity(LabelMappingUtil.fromLabelArrayToListDTO(labels)).build());
Response response = labelService.labelsLabelIdPut("1", LabelMappingUtil.fromLabelToDTO(label1), "application/Json", getRequest());
Assert.assertEquals(response.getEntity(), LabelMappingUtil.fromLabelArrayToListDTO(labels));
}
use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.
the class TestMappingUtilTestCase method testLabelsListToLabelListDTOMapping.
@Test(description = "Label list to Label list DTO mapping ")
void testLabelsListToLabelListDTOMapping() {
Label label1 = SampleTestObjectCreator.createLabel("label1").build();
Label label2 = SampleTestObjectCreator.createLabel("label1").build();
List<Label> labels = new ArrayList<>();
labels.add(label1);
labels.add(label2);
LabelListDTO labelListDTO = MappingUtil.toLabelListDTO(labels);
assertEquals((Integer) labels.size(), labelListDTO.getCount());
assertEquals(label1.getId(), labelListDTO.getList().get(0).getLabelId());
assertEquals(label1.getName(), labelListDTO.getList().get(0).getName());
assertEquals(label2.getId(), labelListDTO.getList().get(1).getLabelId());
assertEquals(label2.getName(), labelListDTO.getList().get(1).getName());
}
Aggregations