use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class TableResourceTest method testGetTables.
/**
* Test getting tables. GET management/tables
*/
public void testGetTables() throws Exception {
Map<String, Long> tableCounts = managementService.getTableCount();
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TABLES_COLLECTION)), HttpStatus.SC_OK);
// Check table array
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertTrue(responseNode.isArray());
assertEquals(tableCounts.size(), responseNode.size());
for (int i = 0; i < responseNode.size(); i++) {
ObjectNode table = (ObjectNode) responseNode.get(i);
assertNotNull(table.get("name").textValue());
assertNotNull(table.get("count").longValue());
assertTrue(table.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TABLE, table.get("name").textValue())));
assertEquals(((Long) tableCounts.get(table.get("name").textValue())).longValue(), table.get("count").longValue());
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class UserResourceTest method testUpdateUserNullFields.
/**
* Test updating a single user passing in no fields in the json, user should remain unchanged.
*/
public void testUpdateUserNullFields() 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;
ObjectNode taskUpdateRequest = objectMapper.createObjectNode();
taskUpdateRequest.putNull("firstName");
taskUpdateRequest.putNull("lastName");
taskUpdateRequest.putNull("email");
taskUpdateRequest.putNull("password");
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId()));
httpPut.setEntity(new StringEntity(taskUpdateRequest.toString()));
CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals("testuser", responseNode.get("id").textValue());
assertTrue(responseNode.get("firstName").isNull());
assertTrue(responseNode.get("lastName").isNull());
assertTrue(responseNode.get("email").isNull());
assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId())));
// Check user is updated in activiti
newUser = identityService.createUserQuery().userId(newUser.getId()).singleResult();
assertNull(newUser.getLastName());
assertNull(newUser.getFirstName());
assertNull(newUser.getEmail());
} finally {
// Delete user after test fails
if (savedUser != null) {
identityService.deleteUser(savedUser.getId());
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class UserResourceTest method testUpdateUserNoFields.
/**
* Test updating a single user passing in no fields in the json, user should remain unchanged.
*/
public void testUpdateUserNoFields() 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;
ObjectNode taskUpdateRequest = objectMapper.createObjectNode();
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId()));
httpPut.setEntity(new StringEntity(taskUpdateRequest.toString()));
CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals("testuser", responseNode.get("id").textValue());
assertEquals("Fred", responseNode.get("firstName").textValue());
assertEquals("McDonald", responseNode.get("lastName").textValue());
assertEquals("no-reply@activiti.org", responseNode.get("email").textValue());
assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId())));
// Check user is updated in activiti
newUser = identityService.createUserQuery().userId(newUser.getId()).singleResult();
assertEquals("McDonald", newUser.getLastName());
assertEquals("Fred", newUser.getFirstName());
assertEquals("no-reply@activiti.org", newUser.getEmail());
assertNull(newUser.getPassword());
} finally {
// Delete user after test fails
if (savedUser != null) {
identityService.deleteUser(savedUser.getId());
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class UserResourceTest method testUpdateUser.
/**
* Test updating a single user.
*/
public void testUpdateUser() 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;
ObjectNode taskUpdateRequest = objectMapper.createObjectNode();
taskUpdateRequest.put("firstName", "Tijs");
taskUpdateRequest.put("lastName", "Barrez");
taskUpdateRequest.put("email", "no-reply@alfresco.org");
taskUpdateRequest.put("password", "updatedpassword");
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId()));
httpPut.setEntity(new StringEntity(taskUpdateRequest.toString()));
CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals("testuser", responseNode.get("id").textValue());
assertEquals("Tijs", responseNode.get("firstName").textValue());
assertEquals("Barrez", responseNode.get("lastName").textValue());
assertEquals("no-reply@alfresco.org", responseNode.get("email").textValue());
assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId())));
// Check user is updated in activiti
newUser = identityService.createUserQuery().userId(newUser.getId()).singleResult();
assertEquals("Barrez", newUser.getLastName());
assertEquals("Tijs", newUser.getFirstName());
assertEquals("no-reply@alfresco.org", newUser.getEmail());
assertEquals("updatedpassword", newUser.getPassword());
} finally {
// Delete user after test fails
if (savedUser != null) {
identityService.deleteUser(savedUser.getId());
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class JobResourceTest method testIllegalActionOnJob.
/**
* Test executing an unexisting job.
*/
@Deployment(resources = { "org/activiti/rest/service/api/management/JobResourceTest.testTimerProcess.bpmn20.xml" })
public void testIllegalActionOnJob() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerProcess");
Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(timerJob);
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("action", "unexistinAction");
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_BAD_REQUEST);
closeResponse(response);
}
Aggregations