Search in sources :

Example 1 with APICategoryDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.APICategoryDTO in project carbon-apimgt by wso2.

the class APICategoryMappingUtil method fromCategoryListToCategoryDTOList.

/**
 * Converts api category List to CategoryDTO List.
 *
 * @param categories List of api categories
 * @return CategoryDTO list
 */
private static List<APICategoryDTO> fromCategoryListToCategoryDTOList(List<APICategory> categories) {
    List<APICategoryDTO> categoryDTOs = new ArrayList<>();
    for (APICategory category : categories) {
        APICategoryDTO categoryDTO = new APICategoryDTO();
        categoryDTO.setId(category.getId());
        categoryDTO.setName(category.getName());
        categoryDTO.setDescription(category.getDescription());
        categoryDTO.setNumberOfAPIs(category.getNumberOfAPIs());
        categoryDTOs.add(categoryDTO);
    }
    return categoryDTOs;
}
Also used : ArrayList(java.util.ArrayList) APICategoryDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.APICategoryDTO) APICategory(org.wso2.carbon.apimgt.api.model.APICategory)

Example 2 with APICategoryDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.APICategoryDTO in project carbon-apimgt by wso2.

the class APICategoryMappingUtil method fromCategoryToCategoryDTO.

/**
 * Converts a Category to CategoryDTO
 *
 * @param category
 * @return categoryDTO
 */
public static APICategoryDTO fromCategoryToCategoryDTO(APICategory category) {
    APICategoryDTO categoryDTO = new APICategoryDTO();
    categoryDTO.setId(category.getId());
    categoryDTO.setName(category.getName());
    categoryDTO.setDescription(category.getDescription());
    return categoryDTO;
}
Also used : APICategoryDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.APICategoryDTO)

Example 3 with APICategoryDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.APICategoryDTO in project carbon-apimgt by wso2.

the class APICategoryMappingUtil method fromCategoryDTOToCategory.

/**
 * Converts a CategoryDTO to APICategory
 *
 * @param categoryDTO
 * @return APICategoty
 */
public static APICategory fromCategoryDTOToCategory(APICategoryDTO categoryDTO) {
    APICategory category = new APICategory();
    category.setId(categoryDTO.getId());
    category.setName(categoryDTO.getName());
    category.setDescription(categoryDTO.getDescription());
    return category;
}
Also used : APICategory(org.wso2.carbon.apimgt.api.model.APICategory)

Example 4 with APICategoryDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.APICategoryDTO in project carbon-apimgt by wso2.

the class APICategoryMappingUtil method fromCategoryListToCategoryDTOList.

/**
 * Converts api category List to CategoryDTO List.
 *
 * @param categories List of api categories
 * @return CategoryDTO list
 */
private static List<APICategoryDTO> fromCategoryListToCategoryDTOList(List<APICategory> categories) {
    List<APICategoryDTO> categoryDTOs = new ArrayList<>();
    for (APICategory category : categories) {
        APICategoryDTO categoryDTO = new APICategoryDTO();
        categoryDTO.setId(category.getId());
        categoryDTO.setName(category.getName());
        categoryDTO.setDescription(category.getDescription());
        categoryDTOs.add(categoryDTO);
    }
    return categoryDTOs;
}
Also used : ArrayList(java.util.ArrayList) APICategoryDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APICategoryDTO) APICategory(org.wso2.carbon.apimgt.api.model.APICategory)

Example 5 with APICategoryDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.APICategoryDTO in project carbon-apimgt by wso2.

the class APICategoryMappingUtilTestCase method testCategoryDescription.

@Test
public void testCategoryDescription() throws Exception {
    APICategory category = new APICategory();
    String description = "sample description";
    category.setDescription(description);
    category.setName("test");
    List<APICategory> categories = new ArrayList<APICategory>();
    categories.add(category);
    APICategoryListDTO ListDto = APICategoryMappingUtil.fromCategoryListToCategoryListDTO(categories);
    APICategoryDTO dto = ListDto.getList().get(0);
    Assert.assertEquals("Category description mismatch", description, dto.getDescription());
}
Also used : ArrayList(java.util.ArrayList) APICategoryDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.APICategoryDTO) APICategory(org.wso2.carbon.apimgt.api.model.APICategory) APICategoryListDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.APICategoryListDTO) Test(org.junit.Test)

Aggregations

APICategory (org.wso2.carbon.apimgt.api.model.APICategory)8 ArrayList (java.util.ArrayList)5 APICategoryDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.APICategoryDTO)4 APICategoryDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.APICategoryDTO)3 Test (org.junit.Test)2 APIAdmin (org.wso2.carbon.apimgt.api.APIAdmin)2 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)2 APIAdminImpl (org.wso2.carbon.apimgt.impl.APIAdminImpl)2 APICategoryListDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.APICategoryListDTO)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 APICategoryDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APICategoryDTO)1