Search in sources :

Example 1 with CountDownAsyncJobListener

use of org.jbpm.test.listener.CountDownAsyncJobListener in project jbpm by kiegroup.

the class LogCleanupCommandTest method skipProcessLog.

@Test(timeout = 10000)
public void skipProcessLog() throws Exception {
    CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(1);
    ((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
    // Generate data
    KieSession kieSession = createKSession(HELLO_WORLD);
    startProcess(kieSession, HELLO_WORLD_ID, 1);
    // Verify presence of data
    Assertions.assertThat(getProcessLogSize(HELLO_WORLD_ID)).isEqualTo(1);
    Assertions.assertThat(getNodeInstanceLogSize(HELLO_WORLD_ID)).isPositive();
    // Schedule cleanup job
    scheduleLogCleanup(true, false, false, getTomorrow(), null, HELLO_WORLD_ID);
    countDownListener.waitTillCompleted();
    // Verify that the process log has not been touched
    Assertions.assertThat(getProcessLogSize(HELLO_WORLD_ID)).isEqualTo(1);
    Assertions.assertThat(getNodeInstanceLogSize(HELLO_WORLD_ID)).isPositive();
}
Also used : CountDownAsyncJobListener(org.jbpm.test.listener.CountDownAsyncJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) KieSession(org.kie.api.runtime.KieSession) Test(org.junit.Test)

Example 2 with CountDownAsyncJobListener

use of org.jbpm.test.listener.CountDownAsyncJobListener in project jbpm by kiegroup.

the class LogCleanupCommandTest method deleteAllLogsOlderThanNow.

@Ignore
@Test(timeout = 10000)
@BZ("1190881")
public void deleteAllLogsOlderThanNow() throws Exception {
    CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(1);
    ((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
    deleteAllLogsOlderThan(null, countDownListener);
    Assertions.assertThat(getProcessLogSize(HELLO_WORLD_ID)).isZero();
    Assertions.assertThat(getNodeInstanceLogSize(HELLO_WORLD_ID)).isZero();
}
Also used : CountDownAsyncJobListener(org.jbpm.test.listener.CountDownAsyncJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) Ignore(org.junit.Ignore) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 3 with CountDownAsyncJobListener

use of org.jbpm.test.listener.CountDownAsyncJobListener in project jbpm by kiegroup.

the class LogCleanupCommandTest method deleteAllLogsOlderThanTomorrow.

@Ignore
@Test(timeout = 10000)
public void deleteAllLogsOlderThanTomorrow() throws Exception {
    CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(1);
    ((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
    deleteAllLogsOlderThan(getTomorrow(), countDownListener);
    Assertions.assertThat(getProcessLogSize(HELLO_WORLD_ID)).isZero();
    Assertions.assertThat(getNodeInstanceLogSize(HELLO_WORLD_ID)).isZero();
}
Also used : CountDownAsyncJobListener(org.jbpm.test.listener.CountDownAsyncJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with CountDownAsyncJobListener

use of org.jbpm.test.listener.CountDownAsyncJobListener in project jbpm by kiegroup.

the class LogCleanupCommandTest method deleteAllLogsOlderThanPeriod.

@Ignore
@Test(timeout = 10000)
@BZ("1190881")
public void deleteAllLogsOlderThanPeriod() throws Exception {
    CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(1);
    ((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
    // Generate data
    KieSession kieSession = createKSession(HELLO_WORLD);
    startProcess(kieSession, HELLO_WORLD_ID, 3);
    countDownListener.waitTillCompleted();
    startProcess(kieSession, HELLO_WORLD_ID, 2);
    // Verify presence of data
    Assertions.assertThat(getProcessLogSize(HELLO_WORLD_ID)).isEqualTo(5);
    Assertions.assertThat(getNodeInstanceLogSize(HELLO_WORLD_ID)).isPositive();
    // Schedule cleanup job
    scheduleLogCleanup(false, false, false, null, "8s", HELLO_WORLD_ID);
    countDownListener.waitTillCompleted();
    // Verify absence of data
    Assertions.assertThat(getProcessLogSize(HELLO_WORLD_ID)).isEqualTo(2);
}
Also used : CountDownAsyncJobListener(org.jbpm.test.listener.CountDownAsyncJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) KieSession(org.kie.api.runtime.KieSession) Ignore(org.junit.Ignore) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 5 with CountDownAsyncJobListener

use of org.jbpm.test.listener.CountDownAsyncJobListener in project jbpm by kiegroup.

the class LogCleanupCommandTest method deleteAllLogsOlderThanYesterday.

@Test(timeout = 10000)
public void deleteAllLogsOlderThanYesterday() throws Exception {
    CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(1);
    ((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
    deleteAllLogsOlderThan(getYesterday(), countDownListener);
    Assertions.assertThat(getProcessLogSize(HELLO_WORLD_ID)).isPositive();
    Assertions.assertThat(getNodeInstanceLogSize(HELLO_WORLD_ID)).isPositive();
}
Also used : CountDownAsyncJobListener(org.jbpm.test.listener.CountDownAsyncJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) Test(org.junit.Test)

Aggregations

ExecutorServiceImpl (org.jbpm.executor.impl.ExecutorServiceImpl)13 CountDownAsyncJobListener (org.jbpm.test.listener.CountDownAsyncJobListener)13 Test (org.junit.Test)13 KieSession (org.kie.api.runtime.KieSession)9 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)7 HashMap (java.util.HashMap)6 QueryContext (org.kie.api.runtime.query.QueryContext)5 AsyncWorkItemHandler (org.jbpm.executor.impl.wih.AsyncWorkItemHandler)4 Ignore (org.junit.Ignore)4 WorkItemManager (org.kie.api.runtime.process.WorkItemManager)4 BZ (qa.tools.ikeeper.annotation.BZ)4 UserTransaction (javax.transaction.UserTransaction)2 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)1 ErrorInfo (org.kie.api.executor.ErrorInfo)1 TaskService (org.kie.api.task.TaskService)1