Ejemplo n.º 1
0
  @Test
  public void checkProcessCommentAreArchived() throws Exception {
    final TenantServiceAccessor tenantAccessor = getTenantAccessor();
    final SCommentService commentService = tenantAccessor.getCommentService();
    final UserTransactionService transactionService = tenantAccessor.getUserTransactionService();
    final ProcessDefinitionBuilder processDef =
        new ProcessDefinitionBuilder().createNewInstance("processToTestComment", "1.0");
    processDef.addStartEvent("start");
    processDef.addUserTask("step1", ACTOR_NAME);
    processDef.addEndEvent("end");
    processDef.addTransition("start", "step1");
    processDef.addTransition("step1", "end");
    processDef.addActor(ACTOR_NAME);
    final ProcessDefinition definition =
        deployAndEnableProcessWithActor(processDef.done(), ACTOR_NAME, john);
    setSessionInfo(getSession()); // the session was cleaned by api call. This must be improved
    final Callable<Long> getNumberOfComments =
        new Callable<Long>() {

          @Override
          public Long call() throws Exception {
            return commentService.getNumberOfComments(QueryOptions.countQueryOptions());
          }
        };
    final Callable<Long> getNumberOfArchivedComments =
        new Callable<Long>() {

          @Override
          public Long call() throws Exception {
            return commentService.getNumberOfArchivedComments(QueryOptions.countQueryOptions());
          }
        };
    assertEquals(0, (long) transactionService.executeInTransaction(getNumberOfComments));
    final long numberOfInitialArchivedComments =
        transactionService.executeInTransaction(getNumberOfArchivedComments);
    final ProcessInstance processInstance = getProcessAPI().startProcess(definition.getId());
    final Long step1Id = waitForUserTask(processInstance, "step1");
    getProcessAPI().addProcessComment(processInstance.getId(), "kikoo lol");
    setSessionInfo(getSession()); // the session was cleaned by api call. This must be improved
    assertEquals(1, (long) transactionService.executeInTransaction(getNumberOfComments));
    assertEquals(
        numberOfInitialArchivedComments,
        (long) transactionService.executeInTransaction(getNumberOfArchivedComments));
    assignAndExecuteStep(step1Id, john);

    setSessionInfo(getSession()); // the session was cleaned by api call. This must be improved
    assertEquals(
        2,
        (long)
            transactionService.executeInTransaction(getNumberOfComments)); // claim add a comment...
    assertEquals(
        numberOfInitialArchivedComments,
        (long) transactionService.executeInTransaction(getNumberOfArchivedComments));
    waitForProcessToFinish(processInstance);

    setSessionInfo(getSession()); // the session was cleaned by api call. This must be improved
    assertEquals(0, (long) transactionService.executeInTransaction(getNumberOfComments));
    assertEquals(
        numberOfInitialArchivedComments + 2,
        (long) transactionService.executeInTransaction(getNumberOfArchivedComments));
    disableAndDeleteProcess(definition);
  }