use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class JobResourceTest method testExecuteUnexistingJob.
/**
* Test executing an unexisting job.
*/
@Deployment(resources = { "org/activiti/rest/service/api/management/JobResourceTest.testTimerProcess.bpmn20.xml" })
public void testExecuteUnexistingJob() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerProcess");
Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(timerJob);
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("action", "execute");
HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB, "unexistingjob"));
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 JobResourceTest method testExecuteJob.
/**
* Test executing a single job.
*/
@Deployment(resources = { "org/activiti/rest/service/api/management/JobResourceTest.testTimerProcess.bpmn20.xml" })
public void testExecuteJob() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerProcess");
Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(timerJob);
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("action", "execute");
HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB, timerJob.getId()));
httpPost.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPost, HttpStatus.SC_NO_CONTENT);
closeResponse(response);
// Job should be executed
assertNull(managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class UserCollectionResourceTest method testCreateUser.
public void testCreateUser() throws Exception {
try {
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("id", "testuser");
requestNode.put("firstName", "Frederik");
requestNode.put("lastName", "Heremans");
requestNode.put("password", "test");
requestNode.put("email", "no-reply@activiti.org");
HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION, "testuser"));
httpPost.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPost, HttpStatus.SC_CREATED);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals("testuser", responseNode.get("id").textValue());
assertEquals("Frederik", responseNode.get("firstName").textValue());
assertEquals("Heremans", responseNode.get("lastName").textValue());
assertEquals("no-reply@activiti.org", responseNode.get("email").textValue());
assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, "testuser")));
assertNotNull(identityService.createUserQuery().userId("testuser").singleResult());
} finally {
try {
identityService.deleteUser("testuser");
} catch (Throwable t) {
// Ignore, user might not have been created by test
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class UserInfoResourceTest method testUpdateInfoForUnexistingUser.
/**
* Test update the info for an unexisting user.
*/
public void testUpdateInfoForUnexistingUser() throws Exception {
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("value", "Updated value");
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO, "unexisting", "key1"));
httpPut.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPut, HttpStatus.SC_NOT_FOUND));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class UserInfoResourceTest method testGetUserInfoCollection.
/**
* Test getting the collection of info for a user.
*/
public void testGetUserInfoCollection() throws Exception {
User savedUser = null;
try {
User newUser = identityService.newUser("testuser");
newUser.setFirstName("Fred");
newUser.setLastName("McDonald");
newUser.setEmail("no-reply@activiti.org");
identityService.saveUser(newUser);
savedUser = newUser;
identityService.setUserInfo(newUser.getId(), "key1", "Value 1");
identityService.setUserInfo(newUser.getId(), "key2", "Value 2");
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO_COLLECTION, newUser.getId())), HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertTrue(responseNode.isArray());
assertEquals(2, responseNode.size());
boolean foundFirst = false;
boolean foundSecond = false;
for (int i = 0; i < responseNode.size(); i++) {
ObjectNode info = (ObjectNode) responseNode.get(i);
assertNotNull(info.get("key").textValue());
assertNotNull(info.get("url").textValue());
if (info.get("key").textValue().equals("key1")) {
foundFirst = true;
assertTrue(info.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO, newUser.getId(), "key1")));
} else if (info.get("key").textValue().equals("key2")) {
assertTrue(info.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO, newUser.getId(), "key2")));
foundSecond = true;
}
}
assertTrue(foundFirst);
assertTrue(foundSecond);
} finally {
// Delete user after test passes or fails
if (savedUser != null) {
identityService.deleteUser(savedUser.getId());
}
}
}
Aggregations