use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.APICategoryListDTO 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());
}
use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.APICategoryListDTO in project carbon-apimgt by wso2.
the class APICategoryMappingUtil method fromCategoryListToCategoryListDTO.
/**
* Convert list of API Categories to CategoryListDTO
*
* @param categories List of api categories
* @return CategoryListDTO list containing api category data
*/
public static APICategoryListDTO fromCategoryListToCategoryListDTO(List<APICategory> categories) {
APICategoryListDTO categoryListDTO = new APICategoryListDTO();
categoryListDTO.setCount(categories.size());
categoryListDTO.setList(fromCategoryListToCategoryDTOList(categories));
return categoryListDTO;
}
use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.APICategoryListDTO in project carbon-apimgt by wso2.
the class ApiCategoriesApiServiceImpl method apiCategoriesGet.
public Response apiCategoriesGet(String xWSO2Tenant, MessageContext messageContext) {
try {
String organization = RestApiUtil.getValidatedOrganization(messageContext);
List<APICategory> categoryList = APIUtil.getAllAPICategoriesOfOrganization(organization);
APICategoryListDTO categoryListDTO = APICategoryMappingUtil.fromCategoryListToCategoryListDTO(categoryList);
return Response.ok().entity(categoryListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving API categories";
RestApiUtil.handleInternalServerError(errorMessage, e, log);
}
return null;
}
use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.APICategoryListDTO in project carbon-apimgt by wso2.
the class ApiCategoriesApiServiceImpl method apiCategoriesGet.
@Override
public Response apiCategoriesGet(MessageContext messageContext) {
try {
APIAdmin apiAdmin = new APIAdminImpl();
String organization = RestApiUtil.getOrganization(messageContext);
List<APICategory> categoryList = apiAdmin.getAPICategoriesOfOrganization(organization);
APICategoryListDTO categoryListDTO = APICategoryMappingUtil.fromCategoryListToCategoryListDTO(categoryList);
return Response.ok().entity(categoryListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving API categories";
RestApiUtil.handleInternalServerError(errorMessage, e, log);
}
return null;
}
use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.APICategoryListDTO in project carbon-apimgt by wso2.
the class APICategoryMappingUtilTestCase method testCategoryDescriptionNull.
@Test
public void testCategoryDescriptionNull() throws Exception {
APICategory category = new APICategory();
category.setDescription(null);
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 is null", "", dto.getDescription());
}
Aggregations