use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.
the class TaskEventResourceTest method testDeleteEvent.
/**
* Test delete event for a task.
* DELETE runtime/tasks/{taskId}/events/{eventId}
*/
public void testDeleteEvent() throws Exception {
try {
Task task = taskService.newTask();
taskService.saveTask(task);
taskService.setAssignee(task.getId(), "kermit");
taskService.addUserIdentityLink(task.getId(), "gonzo", "someType");
List<Event> events = taskService.getTaskEvents(task.getId());
assertEquals(2, events.size());
for (Event event : events) {
HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_EVENT, task.getId(), event.getId()));
closeResponse(executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT));
}
events = taskService.getTaskEvents(task.getId());
assertEquals(0, events.size());
} 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.http.client.methods.HttpDelete in project Activiti by Activiti.
the class ProcessInstanceVariableResourceTest method testDeleteProcessVariable.
/**
* Test deleting a single process variable in, including "not found" check.
*
* DELETE runtime/process-instances/{processInstanceId}/variables/{variableName}
*/
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceVariableResourceTest.testProcess.bpmn20.xml" })
public void testDeleteProcessVariable() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.singletonMap("myVariable", (Object) "processValue"));
// Delete variable
closeResponse(executeRequest(new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE, processInstance.getId(), "myVariable")), HttpStatus.SC_NO_CONTENT));
assertFalse(runtimeService.hasVariable(processInstance.getId(), "myVariable"));
// Run the same delete again, variable is not there so 404 should be returned
closeResponse(executeRequest(new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE, processInstance.getId(), "myVariable")), HttpStatus.SC_NOT_FOUND));
}
use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.
the class ProcessDefinitionIdentityLinksResourceTest method testDeleteCandidateStarterFromProcessDefinition.
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testDeleteCandidateStarterFromProcessDefinition() throws Exception {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
repositoryService.addCandidateStarterGroup(processDefinition.getId(), "admin");
repositoryService.addCandidateStarterUser(processDefinition.getId(), "kermit");
// Delete user candidate
HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINK, processDefinition.getId(), "users", "kermit"));
CloseableHttpResponse response = executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT);
closeResponse(response);
// Check if group-link remains
List<IdentityLink> remainingLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
assertEquals(1, remainingLinks.size());
assertEquals("admin", remainingLinks.get(0).getGroupId());
// Delete group candidate
httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINK, processDefinition.getId(), "groups", "admin"));
response = executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT);
closeResponse(response);
// Check if all links are removed
remainingLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
assertEquals(0, remainingLinks.size());
}
use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.
the class ExecutionVariableResourceTest method testDeleteExecutionVariable.
/**
* Test deleting a single execution variable, including "not found" check.
*/
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-subprocess.bpmn20.xml" })
public void testDeleteExecutionVariable() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processOne", Collections.singletonMap("myVariable", (Object) "processValue"));
Execution childExecution = runtimeService.createExecutionQuery().parentId(processInstance.getId()).singleResult();
assertNotNull(childExecution);
runtimeService.setVariableLocal(childExecution.getId(), "myVariable", "childValue");
// Delete variable local
HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_VARIABLE, childExecution.getId(), "myVariable"));
CloseableHttpResponse response = executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT);
closeResponse(response);
assertFalse(runtimeService.hasVariableLocal(childExecution.getId(), "myVariable"));
// Global variable should remain unaffected
assertTrue(runtimeService.hasVariable(childExecution.getId(), "myVariable"));
// Delete variable global
httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_VARIABLE, childExecution.getId(), "myVariable") + "?scope=global");
response = executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT);
closeResponse(response);
assertFalse(runtimeService.hasVariableLocal(childExecution.getId(), "myVariable"));
assertFalse(runtimeService.hasVariable(childExecution.getId(), "myVariable"));
// Run the same delete again, variable is not there so 404 should be returned
response = executeRequest(httpDelete, HttpStatus.SC_NOT_FOUND);
closeResponse(response);
}
use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.
the class ModelResourceTest method testDeleteModel.
public void testDeleteModel() throws Exception {
Model model = null;
try {
Calendar now = Calendar.getInstance();
now.set(Calendar.MILLISECOND, 0);
processEngineConfiguration.getClock().setCurrentTime(now.getTime());
model = repositoryService.newModel();
model.setCategory("Model category");
model.setKey("Model key");
model.setMetaInfo("Model metainfo");
model.setName("Model name");
model.setVersion(2);
repositoryService.saveModel(model);
HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL, model.getId()));
closeResponse(executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT));
// Check if the model is really gone
assertNull(repositoryService.createModelQuery().modelId(model.getId()).singleResult());
model = null;
} finally {
if (model != null) {
try {
repositoryService.deleteModel(model.getId());
} catch (Throwable ignore) {
// Ignore, model might not be created
}
}
}
}
Aggregations