use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.
the class HistoricProcessInstanceResourceTest method testGetProcessInstance.
/**
* Test retrieval of historic process instance.
* GET history/historic-process-instances/{processInstanceId}
*/
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testGetProcessInstance() throws Exception {
ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder().processDefinitionKey("oneTaskProcess").processInstanceName("processName").start();
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE, processInstance.getId())), HttpStatus.SC_OK);
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals(processInstance.getId(), responseNode.get("id").textValue());
assertEquals("processName", responseNode.get("name").textValue());
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(task);
taskService.complete(task.getId());
response = executeRequest(new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE, processInstance.getId())), HttpStatus.SC_NO_CONTENT);
assertEquals(HttpStatus.SC_NO_CONTENT, response.getStatusLine().getStatusCode());
closeResponse(response);
}
use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.
the class JobResourceTest method testDeleteJob.
/**
* Test deleting a single job.
*/
@Deployment(resources = { "org/activiti/rest/service/api/management/JobResourceTest.testTimerProcess.bpmn20.xml" })
public void testDeleteJob() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerProcess");
Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(timerJob);
HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB, timerJob.getId()));
CloseableHttpResponse response = executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT);
closeResponse(response);
// Job should be deleted
assertNull(managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult());
}
use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.
the class UserInfoResourceTest method testDeleteInfoForUserWithoutInfo.
/**
* Test deleting the info for a user who doesn't have that info set
*/
public void testDeleteInfoForUserWithoutInfo() 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;
closeResponse(executeRequest(new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO, "testuser", "key1")), HttpStatus.SC_NOT_FOUND));
} finally {
// Delete user after test passes or fails
if (savedUser != null) {
identityService.deleteUser(savedUser.getId());
}
}
}
use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.
the class UserInfoResourceTest method testDeleteUserInfo.
/**
* Test deleting info for a user.
*/
public void testDeleteUserInfo() 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");
closeResponse(executeRequest(new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO, newUser.getId(), "key1")), HttpStatus.SC_NO_CONTENT));
// Check if info is actually deleted
assertNull(identityService.getUserInfo(newUser.getId(), "key1"));
} finally {
// Delete user after test passes or fails
if (savedUser != null) {
identityService.deleteUser(savedUser.getId());
}
}
}
use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.
the class GroupResourceTest method testDeleteGroup.
/**
* Test deleting a single group.
*/
public void testDeleteGroup() throws Exception {
try {
Group testGroup = identityService.newGroup("testgroup");
testGroup.setName("Test group");
testGroup.setType("Test type");
identityService.saveGroup(testGroup);
closeResponse(executeRequest(new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, "testgroup")), HttpStatus.SC_NO_CONTENT));
assertNull(identityService.createGroupQuery().groupId("testgroup").singleResult());
} finally {
try {
identityService.deleteGroup("testgroup");
} catch (Throwable ignore) {
// Ignore, since the group may not have been created in the test
// or already deleted
}
}
}
Aggregations