use of org.wso2.carbon.apimgt.rest.api.publisher.dto.LabelDTO in project carbon-apimgt by wso2.
the class LabelMappingUtil method fromLabelArrayToListDTO.
/**
* Converts an array of label model objects into REST API DTO objects.
*
* @param labelList An array of Label model objects
* @return A List DTO of Label DTOs derived from the array of model objects
*/
public static LabelListDTO fromLabelArrayToListDTO(List<Label> labelList) {
LabelListDTO listDTO = new LabelListDTO();
List<LabelDTO> labelDTOList = new ArrayList<>();
if (labelList != null) {
for (Label label : labelList) {
LabelDTO dto = fromLabelToDTO(label);
labelDTOList.add(dto);
}
}
listDTO.setCount(labelDTOList.size());
listDTO.setList(labelDTOList);
return listDTO;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.dto.LabelDTO in project carbon-apimgt by wso2.
the class MappingUtilTestCase method convertToLabelsTest.
@Test
public void convertToLabelsTest() {
List<LabelDTO> labelDTOList = new ArrayList<>();
labelDTOList.add(SampleTestObjectCreator.createUniqueLabelDTO());
labelDTOList.add(SampleTestObjectCreator.createUniqueLabelDTO());
labelDTOList.add(SampleTestObjectCreator.createUniqueLabelDTO());
labelDTOList.add(SampleTestObjectCreator.createUniqueLabelDTO());
List<Label> labelList = MappingUtil.convertToLabels(labelDTOList);
Assert.assertEquals(labelList.size(), labelDTOList.size());
for (int i = 0; i < labelDTOList.size(); i++) {
Assert.assertEquals(labelList.get(i).getName(), labelDTOList.get(i).getName());
Assert.assertEquals(labelList.get(i).getAccessUrls(), labelDTOList.get(i).getAccessUrls());
}
}
use of org.wso2.carbon.apimgt.rest.api.publisher.dto.LabelDTO in project carbon-apimgt by wso2.
the class MappingUtil method toLabelDTO.
/**
* Converts label List to LabelListDTO} List.
*
* @param labels list of labels
* @return LabelDTO list
*/
private static List<LabelDTO> toLabelDTO(List<Label> labels) {
List<LabelDTO> labelDTOs = new ArrayList<>();
for (Label label : labels) {
LabelDTO labelDTO = new LabelDTO();
labelDTO.setLabelId(label.getId());
labelDTO.setName(label.getName());
labelDTO.setAccessUrls(label.getAccessUrls());
labelDTOs.add(labelDTO);
}
return labelDTOs;
}
Aggregations