use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.
the class FormServiceRestOnlyIntegrationTest method testGetTaskFormTest.
@Test
public void testGetTaskFormTest() throws Exception {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(RestURI.CONTAINER_ID, CONTAINER_ID);
valuesMap.put(RestURI.PROCESS_ID, HIRING_PROCESS_ID);
Marshaller marshaller = MarshallerFactory.getMarshaller(marshallingFormat, ClassLoader.getSystemClassLoader());
Map<String, Object> params = new HashMap<String, Object>();
params.put("name", "john");
// start process instance
WebTarget clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + START_PROCESS_POST_URI, valuesMap));
logger.info("[POST] " + clientRequest.getUri());
response = clientRequest.request(getMediaType()).post(createEntity(marshaller.marshall(params)));
Assert.assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Long result = response.readEntity(JaxbLong.class).unwrap();
assertNotNull(result);
// find tasks by process instance id
valuesMap.put(RestURI.PROCESS_INST_ID, result);
clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), QUERY_URI + "/" + TASK_BY_PROCESS_INST_ID_GET_URI, valuesMap));
logger.info("[GET] " + clientRequest.getUri());
response = clientRequest.request(getMediaType()).get();
Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
TaskSummaryList taskSummaryList = marshaller.unmarshall(response.readEntity(String.class), TaskSummaryList.class);
logger.debug("Form content is '{}'", taskSummaryList);
assertNotNull(taskSummaryList);
TaskSummary[] task = taskSummaryList.getTasks();
assertEquals(1, task.length);
Long taskId = task[0].getId();
valuesMap.put(RestURI.TASK_INSTANCE_ID, taskId);
changeUser(USER_JOHN, DEFAULT_PASSWORD);
clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), FORM_URI + "/" + TASK_FORM_GET_URI, valuesMap));
logger.info("[GET] " + clientRequest.getUri());
response = clientRequest.request(getMediaType()).get();
Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
String formdata = response.readEntity(String.class);
logger.debug("Form content is '{}'", formdata);
assertNotNull(formdata);
assertFalse(formdata.isEmpty());
clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + ABORT_PROCESS_INST_DEL_URI, valuesMap));
logger.info("[DELETE] " + clientRequest.getUri());
response = clientRequest.request().delete();
int noContentStatusCode = Response.Status.NO_CONTENT.getStatusCode();
int okStatusCode = Response.Status.OK.getStatusCode();
assertTrue("Wrong status code returned: " + response.getStatus(), response.getStatus() == noContentStatusCode || response.getStatus() == okStatusCode);
}
use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.
the class CaseManagementRuntimeDataServiceBase method getCaseTasks.
public TaskSummaryList getCaseTasks(String caseId, String user, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
List<Status> actualStatus = safeTaskStatus(status);
user = getUser(user);
sort = safeTaskSummarySort(sort);
Collection<TaskSummary> taskSummaries = caseRuntimeDataService.getCaseTasksAssignedAsPotentialOwner(caseId, user, actualStatus, ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
TaskSummaryList tasks = ConvertUtils.convertToTaskSummaryList(taskSummaries);
return tasks;
}
Aggregations