Search in sources :

Example 6 with CompositeAPIDTO

use of org.wso2.carbon.apimgt.rest.api.store.dto.CompositeAPIDTO in project carbon-apimgt by wso2.

the class CompositeAPIMappingUtilTestCase method testToCompositeAPIDTOAndViceVersa.

@Test
public void testToCompositeAPIDTOAndViceVersa() {
    List<String> labels = new ArrayList<>();
    labels.add("label1");
    // Test compositeAPI to CompositeAPIDTO
    CompositeAPI compositeAPI = SampleTestObjectCreator.createCompositeAPIModelBuilder().labels(labels).build();
    CompositeAPIDTO compositeAPIDTO = CompositeAPIMappingUtil.toCompositeAPIDTO(compositeAPI);
    assertEquals(compositeAPI.getId(), compositeAPIDTO.getId());
    assertEquals(compositeAPI.getName(), compositeAPIDTO.getName());
    assertEquals(compositeAPI.getProvider(), compositeAPIDTO.getProvider());
    assertEquals(compositeAPI.getVersion(), compositeAPIDTO.getVersion());
    assertEquals(compositeAPI.getContext(), compositeAPIDTO.getContext());
    assertEquals(compositeAPI.getDescription(), compositeAPIDTO.getDescription());
    assertEquals(compositeAPI.getLabels().size(), compositeAPIDTO.getLabels().size());
    assertEquals(compositeAPI.getApplicationId(), compositeAPIDTO.getApplicationId());
    // Test CompositeAPIDTO to compositeAPI
    CompositeAPI compositeAPIGenerated = CompositeAPIMappingUtil.toAPI(compositeAPIDTO).build();
    assertEquals(compositeAPIGenerated.getId(), compositeAPIDTO.getId());
    assertEquals(compositeAPIGenerated.getName(), compositeAPIDTO.getName());
    assertEquals(compositeAPIGenerated.getProvider(), compositeAPIDTO.getProvider());
    assertEquals(compositeAPIGenerated.getVersion(), compositeAPIDTO.getVersion());
    assertEquals(compositeAPIGenerated.getContext(), compositeAPIDTO.getContext());
    assertEquals(compositeAPIGenerated.getDescription(), compositeAPIDTO.getDescription());
    assertEquals(compositeAPIGenerated.getLabels().size(), compositeAPIDTO.getLabels().size());
    assertEquals(compositeAPIGenerated.getApplicationId(), compositeAPIDTO.getApplicationId());
}
Also used : ArrayList(java.util.ArrayList) CompositeAPIDTO(org.wso2.carbon.apimgt.rest.api.store.dto.CompositeAPIDTO) CompositeAPI(org.wso2.carbon.apimgt.core.models.CompositeAPI) Test(org.testng.annotations.Test)

Aggregations

CompositeAPIDTO (org.wso2.carbon.apimgt.rest.api.store.dto.CompositeAPIDTO)5 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)4 HashMap (java.util.HashMap)3 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)3 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)3 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)3 Application (org.wso2.carbon.apimgt.core.models.Application)2 ArrayList (java.util.ArrayList)1 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 Test (org.testng.annotations.Test)1 APIMgtResourceAlreadyExistsException (org.wso2.carbon.apimgt.core.exception.APIMgtResourceAlreadyExistsException)1 APIMgtResourceNotFoundException (org.wso2.carbon.apimgt.core.exception.APIMgtResourceNotFoundException)1 Request (org.wso2.msf4j.Request)1