use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class ProcessInstanceVariablesCollectionResourceTest method testCreateMultipleProcessVariables.
/**
* Test creating multiple process variables in a single call.
* POST runtime/process-instance/{processInstanceId}/variables
*/
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceVariablesCollectionResourceTest.testProcess.bpmn20.xml" })
public void testCreateMultipleProcessVariables() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
ArrayNode requestNode = objectMapper.createArrayNode();
// String variable
ObjectNode stringVarNode = requestNode.addObject();
stringVarNode.put("name", "stringVariable");
stringVarNode.put("value", "simple string value");
stringVarNode.put("type", "string");
// Integer
ObjectNode integerVarNode = requestNode.addObject();
integerVarNode.put("name", "integerVariable");
integerVarNode.put("value", 1234);
integerVarNode.put("type", "integer");
// Short
ObjectNode shortVarNode = requestNode.addObject();
shortVarNode.put("name", "shortVariable");
shortVarNode.put("value", 123);
shortVarNode.put("type", "short");
// Long
ObjectNode longVarNode = requestNode.addObject();
longVarNode.put("name", "longVariable");
longVarNode.put("value", 4567890L);
longVarNode.put("type", "long");
// Double
ObjectNode doubleVarNode = requestNode.addObject();
doubleVarNode.put("name", "doubleVariable");
doubleVarNode.put("value", 123.456);
doubleVarNode.put("type", "double");
// Boolean
ObjectNode booleanVarNode = requestNode.addObject();
booleanVarNode.put("name", "booleanVariable");
booleanVarNode.put("value", Boolean.TRUE);
booleanVarNode.put("type", "boolean");
// Date
Calendar varCal = Calendar.getInstance();
String isoString = getISODateString(varCal.getTime());
ObjectNode dateVarNode = requestNode.addObject();
dateVarNode.put("name", "dateVariable");
dateVarNode.put("value", isoString);
dateVarNode.put("type", "date");
// Create local variables with a single request
HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE_COLLECTION, processInstance.getId()));
httpPost.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPost, HttpStatus.SC_CREATED);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertTrue(responseNode.isArray());
assertEquals(7, responseNode.size());
// Check if engine has correct variables set
Map<String, Object> variables = runtimeService.getVariablesLocal(processInstance.getId());
assertEquals(7, variables.size());
assertEquals("simple string value", variables.get("stringVariable"));
assertEquals(1234, variables.get("integerVariable"));
assertEquals((short) 123, variables.get("shortVariable"));
assertEquals(4567890L, variables.get("longVariable"));
assertEquals(123.456, variables.get("doubleVariable"));
assertEquals(Boolean.TRUE, variables.get("booleanVariable"));
assertEquals(dateFormat.parse(isoString), variables.get("dateVariable"));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class ProcessDefinitionIdentityLinksResourceTest method testAddCandidateStarterToUnexistingProcessDefinition.
public void testAddCandidateStarterToUnexistingProcessDefinition() throws Exception {
// Create user candidate
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("user", "kermit");
HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINKS_COLLECTION, "unexisting"));
httpPost.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPost, HttpStatus.SC_NOT_FOUND);
closeResponse(response);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class ProcessDefinitionIdentityLinksResourceTest method testGetIdentityLinksForProcessDefinition.
/**
* Test getting identitylinks for a process definition.
*/
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testGetIdentityLinksForProcessDefinition() throws Exception {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
repositoryService.addCandidateStarterGroup(processDefinition.getId(), "admin");
repositoryService.addCandidateStarterUser(processDefinition.getId(), "kermit");
HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINKS_COLLECTION, processDefinition.getId()));
CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertTrue(responseNode.isArray());
assertEquals(2, responseNode.size());
boolean groupCandidateFound = false;
boolean userCandidateFound = false;
for (int i = 0; i < responseNode.size(); i++) {
ObjectNode link = (ObjectNode) responseNode.get(i);
assertNotNull(link);
if (!link.get("user").isNull()) {
assertEquals("kermit", link.get("user").textValue());
assertEquals("candidate", link.get("type").textValue());
assertTrue(link.get("group").isNull());
assertTrue(link.get("url").asText().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINK, processDefinition.getId(), "users", "kermit")));
userCandidateFound = true;
} else if (!link.get("group").isNull()) {
assertEquals("admin", link.get("group").textValue());
assertEquals("candidate", link.get("type").textValue());
assertTrue(link.get("user").isNull());
assertTrue(link.get("url").asText().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINK, processDefinition.getId(), "groups", "admin")));
groupCandidateFound = true;
}
}
assertTrue(groupCandidateFound);
assertTrue(userCandidateFound);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class ProcessDefinitionResourceTest method testActivateAlreadyActiveProcessDefinition.
/**
* Test activating already active process definition.
* POST repository/process-definitions/{processDefinitionId}
*/
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testActivateAlreadyActiveProcessDefinition() throws Exception {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertFalse(processDefinition.isSuspended());
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("action", "activate");
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
httpPut.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_CONFLICT);
closeResponse(response);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class ProcessDefinitionResourceTest method testSuspendAlreadySuspendedProcessDefinition.
/**
* Test suspending already suspended process definition.
* POST repository/process-definitions/{processDefinitionId}
*/
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testSuspendAlreadySuspendedProcessDefinition() throws Exception {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
repositoryService.suspendProcessDefinitionById(processDefinition.getId());
processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertTrue(processDefinition.isSuspended());
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("action", "suspend");
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
httpPut.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_CONFLICT);
closeResponse(response);
}
Aggregations