Search in sources :

Example 36 with DedicatedGateway

use of org.wso2.carbon.apimgt.core.models.DedicatedGateway 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 37 with DedicatedGateway

use of org.wso2.carbon.apimgt.core.models.DedicatedGateway 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 38 with DedicatedGateway

use of org.wso2.carbon.apimgt.core.models.DedicatedGateway 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)

Aggregations

DedicatedGateway (org.wso2.carbon.apimgt.core.models.DedicatedGateway)33 Test (org.testng.annotations.Test)20 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)20 API (org.wso2.carbon.apimgt.core.models.API)19 LabelDAO (org.wso2.carbon.apimgt.core.dao.LabelDAO)14 ArrayList (java.util.ArrayList)12 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)9 GatewaySourceGenerator (org.wso2.carbon.apimgt.core.api.GatewaySourceGenerator)8 IdentityProvider (org.wso2.carbon.apimgt.core.api.IdentityProvider)8 BeforeTest (org.testng.annotations.BeforeTest)7 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)7 Label (org.wso2.carbon.apimgt.core.models.Label)5 HashMap (java.util.HashMap)4 Response (javax.ws.rs.core.Response)4 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 APIPublisher (org.wso2.carbon.apimgt.core.api.APIPublisher)4 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)4 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)4 APIMgtResourceNotFoundException (org.wso2.carbon.apimgt.core.exception.APIMgtResourceNotFoundException)4