use of org.wso2.carbon.apimgt.rest.api.store.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;
}
use of org.wso2.carbon.apimgt.rest.api.store.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;
}
use of org.wso2.carbon.apimgt.rest.api.store.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());
}
use of org.wso2.carbon.apimgt.rest.api.store.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()));
}
Aggregations