protected void verifySingleResultFails(UserOperationLogQuery query) { try { query.singleResult(); fail(); } catch (ProcessEngineException e) {} }
private void verifySingleResultFails(UserOperationLogQuery query) { try { query.singleResult(); fail(); } catch (ProcessEngineException e) {} }
protected void verifyQueryResults(UserOperationLogQuery query, int countExpected) { assertEquals(countExpected, query.list().size()); assertEquals(countExpected, query.count()); if (countExpected == 1) { assertNotNull(query.singleResult()); } else if (countExpected > 1){ verifySingleResultFails(query); } else if (countExpected == 0) { assertNull(query.singleResult()); } }
private void verifyQueryResults(UserOperationLogQuery query, int countExpected) { assertEquals(countExpected, query.list().size()); assertEquals(countExpected, query.count()); if (countExpected == 1) { assertNotNull(query.singleResult()); } else if (countExpected > 1){ verifySingleResultFails(query); } else if (countExpected == 0) { assertNull(query.singleResult()); } }
public void testDeleteStandaloneEntry() { // given String taskId = "myTask"; createTask(taskId); String entryId = historyService.createUserOperationLogQuery().singleResult().getId(); // when historyService.deleteUserOperationLogEntry(entryId); // then assertNull(historyService.createUserOperationLogQuery().singleResult()); deleteTask(taskId, true); }
public void testSetDateProperty() { // given: a single task task = taskService.newTask(); Date now = ClockUtil.getCurrentTime(); task.setDueDate(now); taskService.saveTask(task); UserOperationLogEntry logEntry = historyService.createUserOperationLogQuery().singleResult(); assertEquals(String.valueOf(now.getTime()), logEntry.getNewValue()); }
public void testCaseDeleteEntry() { // given createCaseInstanceByKey(ONE_TASK_CASE_KEY); String taskId = selectSingleTask().getId(); setAssignee(taskId, "demo"); String entryId = historyService.createUserOperationLogQuery().singleResult().getId(); // when historyService.deleteUserOperationLogEntry(entryId); // then assertNull(historyService.createUserOperationLogQuery().singleResult()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testSubmitTaskForm_Complete() { startTestProcess(); formService.submitTaskForm(task.getId(), new HashMap<String, Object>()); // expect: two entries for the resolving (delegation and assignee changed) UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_COMPLETE); assertEquals(1, query.count()); // assert: delete assertFalse(Boolean.parseBoolean(query.property("delete").singleResult().getOrgValue())); assertTrue(Boolean.parseBoolean(query.property("delete").singleResult().getNewValue())); assertProcessEnded(process.getId()); }
@Test public void shouldResolveUserOperationLog_ClaimTask() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); // when identityService.setAuthenticatedUserId("aUserId"); taskService.claim(taskService.createTaskQuery().singleResult().getId(), "aUserId"); identityService.clearAuthentication(); UserOperationLogEntry userOperationLog = historyService.createUserOperationLogQuery().singleResult(); // assume assertThat(userOperationLog, notNullValue()); // then assertThat(userOperationLog.getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); }
@Test public void shouldResolveUserOperationLog_CreateAttachment() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); // when identityService.setAuthenticatedUserId("aUserId"); taskService.createAttachment(null, null, runtimeService.createProcessInstanceQuery().activityIdIn("userTask").singleResult().getId(), null, null, "http://camunda.com"); identityService.clearAuthentication(); UserOperationLogEntry userOperationLog = historyService.createUserOperationLogQuery().singleResult(); // assume assertThat(userOperationLog, notNullValue()); // then assertThat(userOperationLog.getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); }
public void testDeleteEntryWithDeleteHistoryPermissionOnAnyProcessDefinition() { // given startProcessInstanceByKey(ONE_TASK_PROCESS_KEY); String taskId = selectSingleTask().getId(); setAssignee(taskId, "demo"); createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, DELETE_HISTORY); disableAuthorization(); String entryId = historyService.createUserOperationLogQuery().singleResult().getId(); enableAuthorization(); // when historyService.deleteUserOperationLogEntry(entryId); // then disableAuthorization(); assertNull(historyService.createUserOperationLogQuery().singleResult()); enableAuthorization(); }
public void testDeleteTask() { // given: a single task task = taskService.newTask(); taskService.saveTask(task); // then: delete the task taskService.deleteTask(task.getId(), "duplicated"); // expect: one entry for the deletion UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_DELETE); assertEquals(1, query.count()); // assert: details UserOperationLogEntry delete = query.singleResult(); assertEquals(DELETE, delete.getProperty()); assertFalse(Boolean.parseBoolean(delete.getOrgValue())); assertTrue(Boolean.parseBoolean(delete.getNewValue())); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testDeleteOpLogEntry() { // given startTestProcess(); // an op log instance is created taskService.resolveTask(task.getId()); UserOperationLogEntry opLogEntry = historyService.createUserOperationLogQuery().singleResult(); // when the op log instance is deleted historyService.deleteUserOperationLogEntry(opLogEntry.getId()); // then it should be removed from the database assertEquals(0, historyService.createUserOperationLogQuery().count()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testCreateAndCompleteTask() { startTestProcess(); // expect: no entry for the task creation by process engine UserOperationLogQuery query = historyService.createUserOperationLogQuery(); assertEquals(0, query.count()); completeTestProcess(); // expect: one entry for the task completion query = queryOperationDetails(OPERATION_TYPE_COMPLETE); assertEquals(1, query.count()); UserOperationLogEntry complete = query.singleResult(); assertEquals(DELETE, complete.getProperty()); assertTrue(Boolean.parseBoolean(complete.getNewValue())); }
public void testMultipleValueChange() { // given: a single task task = taskService.newTask(); taskService.saveTask(task); // then: change a property twice task.setName("a task"); task.setName("to do"); taskService.saveTask(task); UserOperationLogEntry update = queryOperationDetails(OPERATION_TYPE_UPDATE).singleResult(); assertNull(update.getOrgValue()); assertEquals("to do", update.getNewValue()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testResolveTask() { startTestProcess(); // then: resolve the task taskService.resolveTask(task.getId()); // expect: one entry for the resolving UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_RESOLVE); assertEquals(1, query.count()); // assert: details assertEquals(DelegationState.RESOLVED.toString(), query.singleResult().getNewValue()); completeTestProcess(); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testClaimTask() { startTestProcess(); // then: claim a new the task taskService.claim(task.getId(), "icke"); // expect: one entry for the claim UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_CLAIM); assertEquals(1, query.count()); // assert: details UserOperationLogEntry claim = query.singleResult(); assertEquals(ASSIGNEE, claim.getProperty()); assertEquals("icke", claim.getNewValue()); completeTestProcess(); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testAssignTask() { startTestProcess(); // then: assign the task taskService.setAssignee(task.getId(), "icke"); // expect: one entry for the task assignment UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_ASSIGN); assertEquals(1, query.count()); // assert: details UserOperationLogEntry assign = query.singleResult(); assertEquals(ASSIGNEE, assign.getProperty()); assertEquals("icke", assign.getNewValue()); completeTestProcess(); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testChangeTaskOwner() { startTestProcess(); // then: change the task owner taskService.setOwner(task.getId(), "icke"); // expect: one entry for the owner change UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_SET_OWNER); assertEquals(1, query.count()); // assert: details UserOperationLogEntry change = query.singleResult(); assertEquals(OWNER, change.getProperty()); assertEquals("icke", change.getNewValue()); completeTestProcess(); }
protected void verifyVariableOperationAsserts(int countAssertValue, String operationType) { UserOperationLogQuery logQuery = query().entityType(EntityTypes.VARIABLE).operationType(operationType); assertEquals(countAssertValue, logQuery.count()); if(countAssertValue > 1) { List<UserOperationLogEntry> logEntryList = logQuery.list(); for (UserOperationLogEntry logEntry : logEntryList) { assertEquals(process.getProcessDefinitionId(), logEntry.getProcessDefinitionId()); assertEquals(process.getProcessInstanceId(), logEntry.getProcessInstanceId()); } } else { UserOperationLogEntry logEntry = logQuery.singleResult(); assertEquals(process.getProcessDefinitionId(), logEntry.getProcessDefinitionId()); assertEquals(process.getProcessInstanceId(), logEntry.getProcessInstanceId()); } }