use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class WorkflowsApiServiceImplTestCase method testWorkflowsGetException.
@Test
public void testWorkflowsGetException() throws Exception {
printTestMethodName();
WorkflowsApiServiceImpl workflowsApiService = new WorkflowsApiServiceImpl();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
String message = "Error while retrieving workflow information";
Mockito.doThrow(new APIManagementException(message, ExceptionCodes.APIMGT_DAO_EXCEPTION)).when(adminService).retrieveUncompletedWorkflows();
Response response = workflowsApiService.workflowsGet(null, null, null, getRequest());
assertEquals(500, response.getStatus());
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class WorkflowsApiServiceImplTestCase method testWorkflowsWorkflowReferenceIdGetForInvalidReference.
@Test
public void testWorkflowsWorkflowReferenceIdGetForInvalidReference() throws Exception {
printTestMethodName();
WorkflowsApiServiceImpl workflowsApiService = new WorkflowsApiServiceImpl();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
String workflowRefId = UUID.randomUUID().toString();
String message = "Workflow not found for : " + workflowRefId;
Mockito.doThrow(new APIMgtDAOException(message, ExceptionCodes.WORKFLOW_NOT_FOUND)).when(adminService).retrieveWorkflow(workflowRefId);
Response response = workflowsApiService.workflowsWorkflowReferenceIdGet(workflowRefId, getRequest());
assertEquals(404, response.getStatus());
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class WorkflowsApiServiceImplTestCase method testWorkflowsWorkflowReferenceIdPutException.
@Test
public void testWorkflowsWorkflowReferenceIdPutException() throws Exception {
printTestMethodName();
WorkflowsApiServiceImpl workflowsApiService = new WorkflowsApiServiceImpl();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
String workflowRefId = UUID.randomUUID().toString();
String message = "Error while retrieving workflow entry for :" + workflowRefId;
Mockito.doThrow(new APIManagementException(message, ExceptionCodes.APIMGT_DAO_EXCEPTION)).when(adminService).retrieveWorkflow(workflowRefId);
WorkflowRequestDTO workflowRequestDTO = new WorkflowRequestDTO();
workflowRequestDTO.setDescription("Test Desc");
workflowRequestDTO.setStatus(WorkflowRequestDTO.StatusEnum.APPROVED);
Response response = workflowsApiService.workflowsWorkflowReferenceIdPut(workflowRefId, workflowRequestDTO, getRequest());
assertEquals(500, response.getStatus());
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class WorkflowsApiServiceImplTestCase method testWorkflowsWorkflowReferenceIdGet.
@Test
public void testWorkflowsWorkflowReferenceIdGet() throws Exception {
printTestMethodName();
WorkflowsApiServiceImpl workflowsApiService = new WorkflowsApiServiceImpl();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
String workflowRefId = UUID.randomUUID().toString();
WorkflowRequestDTO workflowRequestDTO = new WorkflowRequestDTO();
workflowRequestDTO.setDescription("Test Desc");
workflowRequestDTO.setStatus(WorkflowRequestDTO.StatusEnum.APPROVED);
Workflow workflow = new ApplicationCreationWorkflow(null, null, null);
workflow.setStatus(WorkflowStatus.APPROVED);
LocalDateTime date1 = LocalDateTime.now();
workflow.setCreatedTime(date1);
workflow.setWorkflowDescription("Description 1");
workflow.setWorkflowType(WorkflowConstants.WF_TYPE_AM_APPLICATION_CREATION);
String ref1 = UUID.randomUUID().toString();
workflow.setExternalWorkflowReference(ref1);
Mockito.doReturn(workflow).doThrow(new IllegalArgumentException()).when(adminService).retrieveWorkflow(workflowRefId);
Response response = workflowsApiService.workflowsWorkflowReferenceIdGet(workflowRefId, getRequest());
assertEquals(200, response.getStatus());
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class BlacklistApiServiceImplTest method blacklistConditionIdDeleteTest.
@Test
public void blacklistConditionIdDeleteTest() throws NotFoundException, APIManagementException {
printTestMethodName();
BlacklistApiServiceImpl blacklistApiService = new BlacklistApiServiceImpl();
String uuid = UUID.randomUUID().toString();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
Mockito.doReturn(true).doThrow(new IllegalArgumentException()).when(adminService).deleteBlockConditionByUuid(uuid);
Response response = blacklistApiService.blacklistConditionIdDelete(uuid, null, null, getRequest());
Assert.assertEquals(response.getStatus(), 200);
}
Aggregations