Search in sources :

Example 11 with DedicatedGatewayDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.dto.DedicatedGatewayDTO in project carbon-apimgt by wso2.

the class MappingUtil method toDedicatedGatewayDTO.

/**
 * This method maps the the DedicatedGateway object to DedicatedGatewayDTO
 *
 * @param dedicatedGateway  DedicatedGateway object
 * @return Dedicated Gateway Object
 */
public static DedicatedGatewayDTO toDedicatedGatewayDTO(DedicatedGateway dedicatedGateway) {
    DedicatedGatewayDTO dedicatedGatewayDTO = new DedicatedGatewayDTO();
    dedicatedGatewayDTO.setIsEnabled(dedicatedGateway.isEnabled());
    return dedicatedGatewayDTO;
}
Also used : DedicatedGatewayDTO(org.wso2.carbon.apimgt.rest.api.publisher.dto.DedicatedGatewayDTO)

Example 12 with DedicatedGatewayDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.dto.DedicatedGatewayDTO in project carbon-apimgt by wso2.

the class MappingUtil method fromDTOtoDedicatedGateway.

/**
 * This method maps the the DedicatedGatewayDTO object to DedicatedGateway Object
 *
 * @param dedicatedGatewayDTO contains data of DedicatedGateway
 * @param apiId UUID of the API
 * @param username username
 * @return Dedicated Gateway Object
 */
public static DedicatedGateway fromDTOtoDedicatedGateway(DedicatedGatewayDTO dedicatedGatewayDTO, String apiId, String username) {
    DedicatedGateway dedicatedGateway = new DedicatedGateway();
    dedicatedGateway.setApiId(apiId);
    dedicatedGateway.setUpdatedBy(username);
    if (dedicatedGatewayDTO.getIsEnabled() != null) {
        dedicatedGateway.setEnabled(dedicatedGatewayDTO.getIsEnabled());
    } else {
        dedicatedGateway.setEnabled(false);
    }
    return dedicatedGateway;
}
Also used : DedicatedGateway(org.wso2.carbon.apimgt.core.models.DedicatedGateway)

Example 13 with DedicatedGatewayDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.dto.DedicatedGatewayDTO in project carbon-apimgt by wso2.

the class ApisApiServiceImplTestCase method testApisApiIdDedicatedGatewayPut.

@Test
public void testApisApiIdDedicatedGatewayPut() throws Exception {
    printTestMethodName();
    ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
    APIPublisher apiPublisher = Mockito.mock(APIPublisherImpl.class);
    PowerMockito.mockStatic(RestAPIPublisherUtil.class);
    PowerMockito.when(RestAPIPublisherUtil.getApiPublisher(USER)).thenReturn(apiPublisher);
    String apiId = UUID.randomUUID().toString();
    Mockito.doReturn(true).when(apiPublisher).isAPIExists(apiId);
    DedicatedGateway dedicatedGateway = new DedicatedGateway();
    dedicatedGateway.setEnabled(true);
    Mockito.doNothing().when(apiPublisher).updateDedicatedGateway(Mockito.any());
    Mockito.doReturn(dedicatedGateway).when(apiPublisher).getDedicatedGateway(apiId);
    DedicatedGatewayDTO dedicatedGatewayDTO = new DedicatedGatewayDTO();
    dedicatedGatewayDTO.setIsEnabled(true);
    Response response = apisApiService.apisApiIdDedicatedGatewayPut(apiId, dedicatedGatewayDTO, null, null, getRequest());
    assertEquals(200, response.getStatus());
}
Also used : WorkflowResponse(org.wso2.carbon.apimgt.core.api.WorkflowResponse) GeneralWorkflowResponse(org.wso2.carbon.apimgt.core.workflow.GeneralWorkflowResponse) Response(javax.ws.rs.core.Response) APIPublisher(org.wso2.carbon.apimgt.core.api.APIPublisher) DedicatedGatewayDTO(org.wso2.carbon.apimgt.rest.api.publisher.dto.DedicatedGatewayDTO) DedicatedGateway(org.wso2.carbon.apimgt.core.models.DedicatedGateway) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 14 with DedicatedGatewayDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.dto.DedicatedGatewayDTO in project carbon-apimgt by wso2.

the class ApisApiServiceImplTestCase method testApisApiIdDedicatedGatewayPutForException.

@Test
public void testApisApiIdDedicatedGatewayPutForException() throws Exception {
    printTestMethodName();
    ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
    APIPublisher apiPublisher = Mockito.mock(APIPublisherImpl.class);
    PowerMockito.mockStatic(RestAPIPublisherUtil.class);
    PowerMockito.when(RestAPIPublisherUtil.getApiPublisher(USER)).thenReturn(apiPublisher);
    String apiId = UUID.randomUUID().toString();
    Mockito.doReturn(true).when(apiPublisher).isAPIExists(apiId);
    Mockito.doThrow(new APIManagementException("Error while creating dedicated container based gateway", ExceptionCodes.DEDICATED_CONTAINER_GATEWAY_CREATION_FAILED)).when(apiPublisher).updateDedicatedGateway(Mockito.any());
    Response response = apisApiService.apisApiIdDedicatedGatewayPut(apiId, new DedicatedGatewayDTO(), null, null, getRequest());
    assertEquals(ExceptionCodes.DEDICATED_CONTAINER_GATEWAY_CREATION_FAILED.getHttpStatusCode(), response.getStatus());
    assertTrue(response.getEntity().toString().contains(ExceptionCodes.DEDICATED_CONTAINER_GATEWAY_CREATION_FAILED.getErrorMessage()));
}
Also used : WorkflowResponse(org.wso2.carbon.apimgt.core.api.WorkflowResponse) GeneralWorkflowResponse(org.wso2.carbon.apimgt.core.workflow.GeneralWorkflowResponse) Response(javax.ws.rs.core.Response) APIManagementException(org.wso2.carbon.apimgt.core.exception.APIManagementException) APIPublisher(org.wso2.carbon.apimgt.core.api.APIPublisher) DedicatedGatewayDTO(org.wso2.carbon.apimgt.rest.api.publisher.dto.DedicatedGatewayDTO) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

DedicatedGateway (org.wso2.carbon.apimgt.core.models.DedicatedGateway)8 Response (javax.ws.rs.core.Response)6 Test (org.junit.Test)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)6 APIPublisher (org.wso2.carbon.apimgt.core.api.APIPublisher)5 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)5 DedicatedGatewayDTO (org.wso2.carbon.apimgt.rest.api.publisher.dto.DedicatedGatewayDTO)5 DedicatedGatewayDTO (org.wso2.carbon.apimgt.rest.api.store.dto.DedicatedGatewayDTO)5 HashMap (java.util.HashMap)4 APIMgtResourceNotFoundException (org.wso2.carbon.apimgt.core.exception.APIMgtResourceNotFoundException)4 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)4 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)3 GeneralWorkflowResponse (org.wso2.carbon.apimgt.core.workflow.GeneralWorkflowResponse)3 Request (org.wso2.msf4j.Request)3