Search in sources :

Example 1 with UriTemplateDTO

use of org.wso2.carbon.apimgt.rest.api.core.dto.UriTemplateDTO in project carbon-apimgt by wso2.

the class MappingUtilTestCase method convertToResourceListDtoTest.

@Test
public void convertToResourceListDtoTest() {
    List<UriTemplate> uriTemplateList = new ArrayList<>();
    uriTemplateList.add(SampleTestObjectCreator.createUniqueUriTemplate());
    uriTemplateList.add(SampleTestObjectCreator.createUniqueUriTemplate());
    uriTemplateList.add(SampleTestObjectCreator.createUniqueUriTemplate());
    uriTemplateList.add(SampleTestObjectCreator.createUniqueUriTemplate());
    List<UriTemplateDTO> uriTemplateDTOList = MappingUtil.convertToResourceListDto(uriTemplateList);
    Assert.assertEquals(uriTemplateDTOList.size(), uriTemplateList.size());
    for (int i = 0; i < uriTemplateDTOList.size(); i++) {
        Assert.assertEquals(uriTemplateList.get(i).getUriTemplate(), uriTemplateDTOList.get(i).getUriTemplate());
        Assert.assertEquals(uriTemplateList.get(i).getAuthType(), uriTemplateDTOList.get(i).getAuthType());
        Assert.assertEquals(uriTemplateList.get(i).getHttpVerb(), uriTemplateDTOList.get(i).getHttpVerb());
        Assert.assertEquals(uriTemplateList.get(i).getPolicy().getUuid(), uriTemplateDTOList.get(i).getPolicy());
    }
}
Also used : UriTemplateDTO(org.wso2.carbon.apimgt.rest.api.core.dto.UriTemplateDTO) ArrayList(java.util.ArrayList) UriTemplate(org.wso2.carbon.apimgt.core.models.UriTemplate) Endpoint(org.wso2.carbon.apimgt.core.models.Endpoint) Test(org.testng.annotations.Test)

Example 2 with UriTemplateDTO

use of org.wso2.carbon.apimgt.rest.api.core.dto.UriTemplateDTO in project carbon-apimgt by wso2.

the class MappingUtil method convertToResourceListDto.

/**
 * Convert Uritemplate list to UriTemplateDTO list
 *
 * @param resourcesOfApi list of uriTemplates
 * @return ResourcesListDTO
 */
public static List<UriTemplateDTO> convertToResourceListDto(List<UriTemplate> resourcesOfApi) {
    List<UriTemplateDTO> uriTemplateDTOArrayList = new ArrayList<>();
    resourcesOfApi.forEach((v) -> {
        UriTemplateDTO uriTemplateDTO = new UriTemplateDTO();
        uriTemplateDTO.setUriTemplate(v.getUriTemplate());
        uriTemplateDTO.setAuthType(v.getAuthType());
        uriTemplateDTO.setPolicy(v.getPolicy().getUuid());
        uriTemplateDTO.setHttpVerb(v.getHttpVerb());
        uriTemplateDTO.setScope("");
        uriTemplateDTOArrayList.add(uriTemplateDTO);
    });
    return uriTemplateDTOArrayList;
}
Also used : UriTemplateDTO(org.wso2.carbon.apimgt.rest.api.core.dto.UriTemplateDTO) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 UriTemplateDTO (org.wso2.carbon.apimgt.rest.api.core.dto.UriTemplateDTO)2 Test (org.testng.annotations.Test)1 Endpoint (org.wso2.carbon.apimgt.core.models.Endpoint)1 UriTemplate (org.wso2.carbon.apimgt.core.models.UriTemplate)1