private void ensureTaskExists(Status status) { HistoricTaskInstance historicTaskInstance = engine.getHistoryService().createHistoricTaskInstanceQuery().taskId(taskId).singleResult(); if (historicTaskInstance == null) { throw new InvalidRequestException(status, "No task found for task id " + taskId); } }
private void ensureTaskExists(Status status) { HistoricTaskInstance historicTaskInstance = engine.getHistoryService().createHistoricTaskInstanceQuery().taskId(taskId).singleResult(); if (historicTaskInstance == null) { throw new InvalidRequestException(status, "No task found for task id " + taskId); } }
private void ensureTaskExists(Status status) { HistoricTaskInstance historicTaskInstance = engine.getHistoryService().createHistoricTaskInstanceQuery().taskId(taskId).singleResult(); if (historicTaskInstance == null) { throw new InvalidRequestException(status, "No task found for task id " + taskId); } }
private void ensureTaskExists(Status status) { HistoricTaskInstance historicTaskInstance = engine.getHistoryService().createHistoricTaskInstanceQuery().taskId(taskId).singleResult(); if (historicTaskInstance == null) { throw new InvalidRequestException(status, "No task found for task id " + taskId); } }
@Test public void testQueryByTaskIdAsPost() { String taskId = MockProvider.EXAMPLE_HISTORIC_TASK_INST_ID; Map<String, Object> params = new HashMap<String, Object>(); params.put("taskId", taskId); given() .contentType(POST_JSON_CONTENT_TYPE) .body(params) .then().expect().statusCode(Status.OK.getStatusCode()) .when().post(HISTORIC_TASK_INSTANCE_RESOURCE_URL); verify(mockedQuery).taskId(taskId); }
@Test public void testGetTaskAttachmentsForNonExistingTaskId() { when(historicTaskInstanceQueryMock.taskId(NON_EXISTING_ID)).thenReturn(historicTaskInstanceQueryMock); when(historicTaskInstanceQueryMock.singleResult()).thenReturn(null); given().pathParam("id", NON_EXISTING_ID) .header("accept", MediaType.APPLICATION_JSON) .then().expect() .statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON) .body(containsString("No task found for task id " + NON_EXISTING_ID)) .when().get(SINGLE_TASK_ATTACHMENTS_URL); }
@Test public void testGetTaskCommentsForNonExistingTask() { when(historicTaskInstanceQueryMock.taskId(NON_EXISTING_ID)).thenReturn(historicTaskInstanceQueryMock); when(historicTaskInstanceQueryMock.singleResult()).thenReturn(null); given() .pathParam("id", NON_EXISTING_ID) .header("accept", MediaType.APPLICATION_JSON) .then().expect() .statusCode(Status.NOT_FOUND.getStatusCode()) .contentType(ContentType.JSON) .body(containsString("No task found for task id " + NON_EXISTING_ID)) .when() .get(SINGLE_TASK_COMMENTS_URL); }
@Test public void testAddCommentToNonExistingTask() { when(historicTaskInstanceQueryMock.taskId(eq(NON_EXISTING_ID))).thenReturn(historicTaskInstanceQueryMock); when(historicTaskInstanceQueryMock.singleResult()).thenReturn(null); Map<String, Object> json = new HashMap<String, Object>(); json.put("message", EXAMPLE_TASK_COMMENT_FULL_MESSAGE); given() .pathParam("id", NON_EXISTING_ID) .contentType(ContentType.JSON) .body(json) .header("accept", MediaType.APPLICATION_JSON) .then().expect() .statusCode(Status.BAD_REQUEST.getStatusCode()) .body(containsString("No task found for task id " + NON_EXISTING_ID)) .when() .post(SINGLE_TASK_ADD_COMMENT_URL); }
@Test public void testQueryByTaskId() { String taskId = MockProvider.EXAMPLE_HISTORIC_TASK_INST_ID; given() .queryParam("taskId", taskId) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(HISTORIC_TASK_INSTANCE_RESOURCE_URL); verify(mockedQuery).taskId(taskId); }
@Test public void testCreateTaskAttachmentWithUrlToNonExistingTask() { when(historicTaskInstanceQueryMock.taskId(eq(NON_EXISTING_ID))).thenReturn(historicTaskInstanceQueryMock); when(historicTaskInstanceQueryMock.singleResult()).thenReturn(null); given() .pathParam("id", NON_EXISTING_ID) .multiPart("attachment-name", EXAMPLE_TASK_ATTACHMENT_NAME) .multiPart("attachment-description", EXAMPLE_TASK_ATTACHMENT_DESCRIPTION) .multiPart("attachment-type", EXAMPLE_TASK_ATTACHMENT_TYPE) .multiPart("url", EXAMPLE_TASK_ATTACHMENT_URL) .header("accept", MediaType.APPLICATION_JSON) .then().expect() .statusCode(Status.BAD_REQUEST.getStatusCode()) .body(containsString("No task found for task id " + NON_EXISTING_ID)) .when() .post(SINGLE_TASK_ADD_ATTACHMENT_URL); }
@Test public void testCreateTaskAttachmentWithContentToNonExistingTask() { when(historicTaskInstanceQueryMock.taskId(eq(NON_EXISTING_ID))).thenReturn(historicTaskInstanceQueryMock); when(historicTaskInstanceQueryMock.singleResult()).thenReturn(null); given() .pathParam("id", NON_EXISTING_ID) .multiPart("attachment-name", EXAMPLE_TASK_ATTACHMENT_NAME) .multiPart("attachment-description", EXAMPLE_TASK_ATTACHMENT_DESCRIPTION) .multiPart("attachment-type", EXAMPLE_TASK_ATTACHMENT_TYPE) .multiPart("content", createMockByteData()) .header("accept", MediaType.APPLICATION_JSON) .then().expect() .statusCode(Status.BAD_REQUEST.getStatusCode()) .body(containsString("No task found for task id " + NON_EXISTING_ID)) .when() .post(SINGLE_TASK_ADD_ATTACHMENT_URL); }
public void testDeleteStandaloneTask() { // given String taskId = "myTask"; createTask(taskId); // when historyService.deleteHistoricTaskInstance(taskId); // then disableAuthorization(); HistoricTaskInstanceQuery query = historyService .createHistoricTaskInstanceQuery() .taskId(taskId); verifyQueryResults(query, 0); enableAuthorization(); deleteTask(taskId, true); }
public void testDeleteProcessTaskWithDeleteHistoryPermissionOnProcessDefinition() { // given startProcessInstanceByKey(PROCESS_KEY); String taskId = selectSingleTask().getId(); createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, DELETE_HISTORY); // when historyService.deleteHistoricTaskInstance(taskId); // then disableAuthorization(); HistoricTaskInstanceQuery query = historyService .createHistoricTaskInstanceQuery() .taskId(taskId); verifyQueryResults(query, 0); enableAuthorization(); }
public void testDeleteProcessTaskWithDeleteHistoryPermissionOnAnyProcessDefinition() { // given startProcessInstanceByKey(PROCESS_KEY); String taskId = selectSingleTask().getId(); createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, DELETE_HISTORY); // when historyService.deleteHistoricTaskInstance(taskId); // then disableAuthorization(); HistoricTaskInstanceQuery query = historyService .createHistoricTaskInstanceQuery() .taskId(taskId); verifyQueryResults(query, 0); enableAuthorization(); }
public void testHistoricTaskInstanceCaseInstanceId() { Task task = taskService.newTask(); task.setCaseInstanceId("aCaseInstanceId"); taskService.saveTask(task); HistoricTaskInstance hti = historyService .createHistoricTaskInstanceQuery() .taskId(task.getId()) .singleResult(); assertEquals("aCaseInstanceId", hti.getCaseInstanceId()); task.setCaseInstanceId("anotherCaseInstanceId"); taskService.saveTask(task); hti = historyService .createHistoricTaskInstanceQuery() .taskId(task.getId()) .singleResult(); assertEquals("anotherCaseInstanceId", hti.getCaseInstanceId()); // Finally, delete task taskService.deleteTask(task.getId(), true); }
@Deployment public void testHistoricTaskInstanceQueryByProcessVariableValue() throws Exception { int historyLevel = processEngineConfiguration.getHistoryLevel().getId(); if (historyLevel >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("hallo", "steffen"); String processInstanceId = runtimeService.startProcessInstanceByKey("HistoricTaskInstanceTest", variables).getId(); Task runtimeTask = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); String taskId = runtimeTask.getId(); HistoricTaskInstance historicTaskInstance = historyService .createHistoricTaskInstanceQuery() .processVariableValueEquals("hallo", "steffen") .singleResult(); assertNotNull(historicTaskInstance); assertEquals(taskId, historicTaskInstance.getId()); taskService.complete(taskId); assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskId(taskId).count()); historyService.deleteHistoricTaskInstance(taskId); assertEquals(0, historyService.createHistoricTaskInstanceQuery().count()); } }
@Test public void testTaskAttachments() { int historyLevel = processEngineConfiguration.getHistoryLevel().getId(); if (historyLevel> ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) { Task task = taskService.newTask(); task.setOwner("johndoe"); taskService.saveTask(task); String taskId = task.getId(); identityService.setAuthenticatedUserId("johndoe"); // Fetch the task again and update taskService.createAttachment("web page", taskId, "someprocessinstanceid", "weatherforcast", "temperatures and more", "http://weather.com"); Attachment attachment = taskService.getTaskAttachments(taskId).get(0); assertEquals("weatherforcast", attachment.getName()); assertEquals("temperatures and more", attachment.getDescription()); assertEquals("web page", attachment.getType()); assertEquals(taskId, attachment.getTaskId()); assertEquals("someprocessinstanceid", attachment.getProcessInstanceId()); assertEquals("http://weather.com", attachment.getUrl()); assertNull(taskService.getAttachmentContent(attachment.getId())); // Finally, clean up taskService.deleteTask(taskId); assertEquals(0, taskService.getTaskComments(taskId).size()); assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskId(taskId).list().size()); taskService.deleteTask(taskId, true); } }
@Test public void testDeleteTaskWithDeleteReason() { // ACT-900: deleteReason can be manually specified - can only be validated when historyLevel > ACTIVITY if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) { Task task = taskService.newTask(); task.setName("test task"); taskService.saveTask(task); assertNotNull(task.getId()); taskService.deleteTask(task.getId(), "deleted for testing purposes"); HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery() .taskId(task.getId()).singleResult(); assertNotNull(historicTaskInstance); assertEquals("deleted for testing purposes", historicTaskInstance.getDeleteReason()); // Delete historic task that is left behind, will not be cleaned up because this is not part of a process taskService.deleteTask(task.getId(), true); } }
public void testDeleteHistoricTaskInstanceAfterDeletingDeployment() { // given String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId(); String taskId = selectSingleTask().getId(); disableAuthorization(); taskService.complete(taskId); enableAuthorization(); createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, DELETE_HISTORY); disableAuthorization(); repositoryService.deleteDeployment(deploymentId); enableAuthorization(); // when historyService.deleteHistoricTaskInstance(taskId); // then disableAuthorization(); HistoricTaskInstanceQuery query = historyService .createHistoricTaskInstanceQuery() .taskId(taskId); verifyQueryResults(query, 0); enableAuthorization(); disableAuthorization(); historyService.deleteHistoricProcessInstance(processInstanceId); enableAuthorization(); }
.createHistoricTaskInstanceQuery().taskId(subTask.getId()).singleResult();