Exemplo n.º 1
0
  @Test
  public void deleteLogsByVersion() {
    KieSession kieSession = createKSession(HELLO_WORLD_PROCESS);
    startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 7);
    disposeRuntimeManager();
    kieSession = createKSession(HELLO_WORLD_PROCESS2);
    startProcess(kieSession, HELLO_WORLD_PROCESS2_ID, 2);

    // Delete all logs of version 1.1
    ProcessInstanceLogDeleteBuilder deleteBuilder =
        auditService.processInstanceLogDelete().processVersion("1.0");
    int deleteResult = deleteBuilder.build().execute();
    Assertions.assertThat(deleteResult).isEqualTo(7);

    // Make sure that the 1.1 version logs are gone
    List<ProcessInstanceLog> resultList =
        auditService.processInstanceLogQuery().processVersion("1.0").build().getResultList();
    Assertions.assertThat(resultList).hasSize(0);

    // Now check that 1.0 version logs are present
    resultList =
        auditService.processInstanceLogQuery().processVersion("1.1").build().getResultList();
    Assertions.assertThat(resultList).hasSize(2);
    Assertions.assertThat(resultList).extracting("processVersion").containsExactly("1.1", "1.1");
  }
Exemplo n.º 2
0
  @Test
  public void deleteLogsWithStatusActive() {
    KieSession kieSession = null;
    List<ProcessInstance> instanceList1 = null;
    List<ProcessInstance> instanceList2 = null;

    try {
      kieSession = createKSession(HELLO_WORLD_PROCESS, HUMAN_TASK);
      instanceList1 = startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 3);
      instanceList2 = startProcess(kieSession, HUMAN_TASK_ID, 5);

      ProcessInstanceLogDeleteBuilder deleteBuilder =
          auditService.processInstanceLogDelete().status(ProcessInstance.STATE_ACTIVE);
      int deleteResult = deleteBuilder.build().execute();
      Assertions.assertThat(deleteResult).isEqualTo(5);

      ProcessInstanceLogQueryBuilder queryBuilder =
          auditService.processInstanceLogQuery().status(ProcessInstance.STATE_COMPLETED);
      List<ProcessInstanceLog> queryList = queryBuilder.build().getResultList();

      Assertions.assertThat(queryList).hasSize(3);
      Assertions.assertThat(queryList)
          .extracting("processId")
          .containsExactly(HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID);
      Assertions.assertThat(queryList)
          .extracting("processVersion")
          .containsExactly("1.0", "1.0", "1.0");
      Assertions.assertThat(queryList)
          .extracting("status")
          .containsExactly(
              ProcessInstance.STATE_COMPLETED,
              ProcessInstance.STATE_COMPLETED,
              ProcessInstance.STATE_COMPLETED);
    } finally {
      if (instanceList2 != null) {
        abortProcess(kieSession, instanceList2);
      }
      if (kieSession != null) {
        kieSession.dispose();
      }
    }
  }