use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class WorkflowsApiServiceImplTestCase method testWorkflowsGetWithoutType.
@Test
public void testWorkflowsGetWithoutType() throws Exception {
printTestMethodName();
WorkflowsApiServiceImpl workflowsApiService = new WorkflowsApiServiceImpl();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
List<Workflow> workflowList = new ArrayList<>();
Mockito.doReturn(workflowList).doThrow(new IllegalArgumentException()).when(adminService).retrieveUncompletedWorkflows();
Response response = workflowsApiService.workflowsGet(null, null, null, getRequest());
assertEquals(200, response.getStatus());
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class LabelsApiServiceImplTest method testLabelsPost.
@Test
public void testLabelsPost() throws Exception {
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
Label label1 = new Label.Builder().id("1").name("label1").type("GATEWAY").build();
LabelsApiServiceImpl labelService = new LabelsApiServiceImpl();
Mockito.when(labelService.labelsPost(LabelMappingUtil.fromLabelToDTO(label1), "application/json", getRequest())).thenReturn(Response.status(Response.Status.CREATED).entity(LabelMappingUtil.fromLabelToDTO(label1)).build());
Response response = labelService.labelsPost(LabelMappingUtil.fromLabelToDTO(label1), "application/json", getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.CREATED);
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class LabelsApiServiceImplTest method testLabelsLabelIdPut.
@Test
public void testLabelsLabelIdPut() throws Exception {
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
List<Label> labels = new ArrayList<>();
Label label1 = new Label.Builder().id("1").name("label1").type("GATEWAY").build();
Label label2 = new Label.Builder().id("2").name("label2").type("STORE").build();
labels.add(label1);
labels.add(label2);
LabelsApiServiceImpl labelService = new LabelsApiServiceImpl();
Mockito.when(labelService.labelsLabelIdPut("1", LabelMappingUtil.fromLabelToDTO(label1), "application/Json", getRequest())).thenReturn(Response.status(Response.Status.OK).entity(LabelMappingUtil.fromLabelArrayToListDTO(labels)).build());
Response response = labelService.labelsLabelIdPut("1", LabelMappingUtil.fromLabelToDTO(label1), "application/Json", getRequest());
Assert.assertEquals(response.getEntity(), LabelMappingUtil.fromLabelArrayToListDTO(labels));
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class LabelsApiServiceImplTest method testLabelsDelete.
@Test
public void testLabelsDelete() throws Exception {
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
LabelsApiServiceImpl labelService = new LabelsApiServiceImpl();
Mockito.doNothing().when(labelService.labelsLabelIdDelete("1", getRequest()));
Response response = labelService.labelsLabelIdDelete("1", getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.OK);
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class EndpointsApiServiceImplTestCase method endpointsGetTest.
@Test
public void endpointsGetTest() throws Exception {
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
Endpoint endpointOne = SampleTestObjectCreator.createUniqueEndpoint();
Endpoint endpointTwo = SampleTestObjectCreator.createUniqueEndpoint();
Endpoint endpointThree = SampleTestObjectCreator.createUniqueEndpoint();
List<Endpoint> endpointList = new ArrayList<>();
endpointList.add(endpointOne);
endpointList.add(endpointTwo);
endpointList.add(endpointThree);
Mockito.when(apiMgtAdminService.getAllEndpoints()).thenReturn(endpointList);
EndpointsApiServiceImpl endpointsApiService = new EndpointsApiServiceImpl();
Response response = endpointsApiService.endpointsGet(null, null, getRequest());
Assert.assertEquals(response.getStatus(), 200);
Assert.assertEquals(((EndpointListDTO) response.getEntity()).getList().size(), 3);
}
Aggregations