use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project Activiti by Activiti.
the class TaskCommentResourceTest method testGetCommentWithCompletedTask.
/**
* Test getting a comment for a completed task.
* GET runtime/tasks/{taskId}/comments/{commentId}
*/
public void testGetCommentWithCompletedTask() throws Exception {
try {
Task task = taskService.newTask();
taskService.saveTask(task);
// Add a comment as "kermit"
identityService.setAuthenticatedUserId("kermit");
Comment comment = taskService.addComment(task.getId(), null, "This is a comment...");
identityService.setAuthenticatedUserId(null);
taskService.complete(task.getId());
HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT, task.getId(), comment.getId()));
CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals("kermit", responseNode.get("author").textValue());
assertEquals("This is a comment...", responseNode.get("message").textValue());
assertEquals(comment.getId(), responseNode.get("id").textValue());
assertTrue(responseNode.get("taskUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT, task.getId(), comment.getId())));
assertEquals(task.getId(), responseNode.get("taskId").asText());
assertTrue(responseNode.get("processInstanceUrl").isNull());
assertTrue(responseNode.get("processInstanceId").isNull());
} finally {
// Clean adhoc-tasks even if test fails
List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().list();
for (HistoricTaskInstance task : tasks) {
historyService.deleteHistoricTaskInstance(task.getId());
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project Activiti by Activiti.
the class TaskEventResourceTest method testGetEvent.
/**
* Test getting a single event for a task.
* GET runtime/tasks/{taskId}/events/{eventId}
*/
public void testGetEvent() throws Exception {
try {
Calendar now = Calendar.getInstance();
now.set(Calendar.MILLISECOND, 0);
processEngineConfiguration.getClock().setCurrentTime(now.getTime());
Task task = taskService.newTask();
taskService.saveTask(task);
taskService.addUserIdentityLink(task.getId(), "gonzo", "someType");
Event event = taskService.getTaskEvents(task.getId()).get(0);
HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_EVENT, task.getId(), event.getId()));
CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals(event.getId(), responseNode.get("id").textValue());
assertEquals(event.getAction(), responseNode.get("action").textValue());
assertEquals(event.getUserId(), responseNode.get("userId").textValue());
assertTrue(responseNode.get("url").asText().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_EVENT, task.getId(), event.getId())));
assertTrue(responseNode.get("taskUrl").asText().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK, task.getId())));
assertEquals(now.getTime(), getDateFromISOString(responseNode.get("time").textValue()));
} finally {
// Clean adhoc-tasks even if test fails
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
taskService.deleteTask(task.getId(), true);
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project Activiti by Activiti.
the class ProcessInstanceVariableResourceTest method testUpdateProcessVariable.
/**
* Test updating a single process variable, including "not found" check.
*
* PUT runtime/process-instances/{processInstanceId}/variables/{variableName}
*/
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceVariableResourceTest.testProcess.bpmn20.xml" })
public void testUpdateProcessVariable() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.singletonMap("overlappingVariable", (Object) "processValue"));
runtimeService.setVariable(processInstance.getId(), "myVar", "value");
// Update variable
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("name", "myVar");
requestNode.put("value", "updatedValue");
requestNode.put("type", "string");
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE, processInstance.getId(), "myVar"));
httpPut.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals("updatedValue", responseNode.get("value").asText());
// Try updating with mismatch between URL and body variableName
requestNode.put("name", "unexistingVariable");
httpPut.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPut, HttpStatus.SC_BAD_REQUEST));
// Try updating unexisting property
requestNode.put("name", "unexistingVariable");
httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE, processInstance.getId(), "unexistingVariable"));
httpPut.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPut, HttpStatus.SC_NOT_FOUND));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project Activiti by Activiti.
the class ProcessInstanceVariableResourceTest method testGetProcessInstanceVariable.
/**
* Test getting a process instance variable. GET
* runtime/process-instances/{processInstanceId}/variables/{variableName}
*/
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceVariableResourceTest.testProcess.bpmn20.xml" })
public void testGetProcessInstanceVariable() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
runtimeService.setVariable(processInstance.getId(), "variable", "processValue");
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE, processInstance.getId(), "variable")), HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals("processValue", responseNode.get("value").asText());
assertEquals("variable", responseNode.get("name").asText());
assertEquals("string", responseNode.get("type").asText());
// Illegal scope
closeResponse(executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE, processInstance.getId(), "variable") + "?scope=illegal"), HttpStatus.SC_BAD_REQUEST));
// Unexisting process
closeResponse(executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE, "unexisting", "variable")), HttpStatus.SC_NOT_FOUND));
// Unexisting variable
closeResponse(executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE, processInstance.getId(), "unexistingVariable")), HttpStatus.SC_NOT_FOUND));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project Activiti by Activiti.
the class ProcessInstanceVariablesCollectionResourceTest method testGetProcessVariables.
/**
* Test getting all process variables.
* GET runtime/process-instances/{processInstanceId}/variables
*/
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceVariablesCollectionResourceTest.testProcess.bpmn20.xml" })
public void testGetProcessVariables() throws Exception {
Calendar cal = Calendar.getInstance();
// Start process with all types of variables
Map<String, Object> processVariables = new HashMap<String, Object>();
processVariables.put("stringProcVar", "This is a ProcVariable");
processVariables.put("intProcVar", 123);
processVariables.put("longProcVar", 1234L);
processVariables.put("shortProcVar", (short) 123);
processVariables.put("doubleProcVar", 99.99);
processVariables.put("booleanProcVar", Boolean.TRUE);
processVariables.put("dateProcVar", cal.getTime());
processVariables.put("byteArrayProcVar", "Some raw bytes".getBytes());
processVariables.put("overlappingVariable", "process-value");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", processVariables);
// Request all variables (no scope provides) which include global an local
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE_COLLECTION, processInstance.getId())), HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertTrue(responseNode.isArray());
assertEquals(9, responseNode.size());
}
Aggregations