AsyncCaseInstanceAuditEventProducer implements CaseEventListener, Cacheable { @Override public void afterCaseStarted(CaseStartEvent event) { CaseFileInstance caseFile = event.getCaseFile(); if (caseFile == null) { return; } List<CaseRoleAssignmentLog> caseRoleAssignmentsLogs = new ArrayList<>(); Collection<CaseRoleInstance> caseRoleAssignments = ((CaseFileInstanceImpl)caseFile).getAssignments(); if (caseRoleAssignments != null && !caseRoleAssignments.isEmpty()) { for (CaseRoleInstance roleAssignment : caseRoleAssignments) { logger.debug("Role {} has following assignments {}", roleAssignment.getRoleName(), roleAssignment.getRoleAssignments()); if (roleAssignment.getRoleAssignments() != null && !roleAssignment.getRoleAssignments().isEmpty()) { roleAssignment.getRoleAssignments().forEach(entity -> { CaseRoleAssignmentLog assignmentLog = new CaseRoleAssignmentLog(event.getProcessInstanceId(), event.getCaseId(), roleAssignment.getRoleName(), entity); caseRoleAssignmentsLogs.add(assignmentLog); }); } } } else { CaseRoleAssignmentLog assignmentLog = new CaseRoleAssignmentLog(event.getProcessInstanceId(), event.getCaseId(), "*", TaskModelProvider.getFactory().newGroup(AuthorizationManager.PUBLIC_GROUP)); caseRoleAssignmentsLogs.add(assignmentLog); } Map<String, Object> initialData = caseFile.getData(); List<CaseFileData> caseFileDataLogs = new ArrayList<>(); if (!initialData.isEmpty()) { initialData.forEach((name, value) -> { if (value != null) { List<CaseFileData> indexedValues = indexManager.index(event, name, value); caseFileDataLogs.addAll(indexedValues); } }); } sendMessage(AFTER_CASE_STARTED_EVENT_TYPE, new AuditCaseInstanceData(event.getCaseId(), caseFileDataLogs, caseRoleAssignmentsLogs), 8); } AsyncCaseInstanceAuditEventProducer(); ConnectionFactory getConnectionFactory(); void setConnectionFactory(ConnectionFactory connectionFactory); Queue getQueue(); void setQueue(Queue queue); boolean isTransacted(); void setTransacted(boolean transacted); @Override void afterCaseStarted(CaseStartEvent event); @Override void afterCaseReopen(CaseReopenEvent event); @Override void afterCaseRoleAssignmentAdded(CaseRoleAssignmentEvent event); @Override void afterCaseRoleAssignmentRemoved(CaseRoleAssignmentEvent event); @Override void afterCaseDataAdded(CaseDataEvent event); @Override void afterCaseDataRemoved(CaseDataEvent event); @Override void close();  }
@Test public void testCaseStarted() throws JMSException { CaseFileInstanceImpl caseFile = new CaseFileInstanceImpl("TEST-01", "case"); CaseStartEvent event = new CaseStartEvent("user", "TEST-01", "test", "case", caseFile, 1L); logProducer.afterCaseStarted(event); verify(message, times(1)).setStringProperty(eq("LogType"), eq("Case")); verify(message, times(1)).setIntProperty(eq("EventType"), eq(AFTER_CASE_STARTED_EVENT_TYPE)); verify(producer, times(1)).setPriority(eq(8)); verify(producer, times(1)).send(eq(message)); }