Search in sources :

Example 1 with TaskQueryItem

use of pro.taskana.impl.report.impl.TaskQueryItem in project taskana by Taskana.

the class ProvideTaskStatusReportAccTest method testCompleteTaskStatusReportWithStateFilter.

@Test
public void testCompleteTaskStatusReportWithStateFilter() {
    // given
    TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
    // when
    TaskStatusReport report = taskMonitorService.getTaskStatusReport(null, Collections.singletonList(TaskState.READY));
    // then
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(reportToString(report));
    }
    assertNotNull(report);
    assertEquals(3, report.rowSize());
    ReportRow<TaskQueryItem> row1 = report.getRow("DOMAIN_A");
    assertArrayEquals(new int[] { 22 }, row1.getCells());
    assertEquals(22, row1.getTotalValue());
    ReportRow<TaskQueryItem> row2 = report.getRow("DOMAIN_B");
    assertArrayEquals(new int[] { 9 }, row2.getCells());
    assertEquals(9, row2.getTotalValue());
    ReportRow<TaskQueryItem> row3 = report.getRow("DOMAIN_C");
    assertArrayEquals(new int[] { 10 }, row3.getCells());
    assertEquals(10, row3.getTotalValue());
    ReportRow<TaskQueryItem> sumRow = report.getSumRow();
    assertArrayEquals(new int[] { 41 }, sumRow.getCells());
    assertEquals(41, sumRow.getTotalValue());
}
Also used : TaskQueryItem(pro.taskana.impl.report.impl.TaskQueryItem) TaskMonitorService(pro.taskana.TaskMonitorService) TaskStatusReport(pro.taskana.impl.report.impl.TaskStatusReport) Test(org.junit.Test) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)

Example 2 with TaskQueryItem

use of pro.taskana.impl.report.impl.TaskQueryItem in project taskana by Taskana.

the class TaskMonitorServiceImplTest method testGetTotalNumberOfTaskStateReport.

@Test
public void testGetTotalNumberOfTaskStateReport() {
    // given
    TaskQueryItem queryItem1 = new TaskQueryItem();
    queryItem1.setCount(50);
    queryItem1.setState(TaskState.READY);
    queryItem1.setDomain("DOMAIN_X");
    TaskQueryItem queryItem2 = new TaskQueryItem();
    queryItem2.setCount(30);
    queryItem2.setState(TaskState.COMPLETED);
    queryItem2.setDomain("DOMAIN_X");
    List<TaskQueryItem> queryItems = Arrays.asList(queryItem1, queryItem2);
    when(taskMonitorMapperMock.getTasksCountByState(eq(null), eq(Collections.emptyList()))).thenReturn(queryItems);
    // when
    TaskStatusReport report = cut.getTaskStatusReport(null, Collections.emptyList());
    // then
    InOrder inOrder = inOrder(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineImplMock);
    inOrder.verify(taskanaEngineImplMock).openConnection();
    inOrder.verify(taskMonitorMapperMock).getTasksCountByState(eq(null), eq(Collections.emptyList()));
    inOrder.verify(taskanaEngineImplMock).returnConnection();
    assertNotNull(report);
    assertEquals(1, report.rowSize());
    assertArrayEquals(new int[0], report.getRow("DOMAIN_X").getCells());
    assertArrayEquals(new int[0], report.getSumRow().getCells());
    assertEquals(80, report.getRow("DOMAIN_X").getTotalValue());
    assertEquals(80, report.getSumRow().getTotalValue());
}
Also used : TaskQueryItem(pro.taskana.impl.report.impl.TaskQueryItem) InOrder(org.mockito.InOrder) TaskStatusReport(pro.taskana.impl.report.impl.TaskStatusReport) Test(org.junit.Test)

Example 3 with TaskQueryItem

use of pro.taskana.impl.report.impl.TaskQueryItem in project taskana by Taskana.

the class TaskMonitorServiceImplTest method testGetTaskStateReportWithoutFilters.

@Test
public void testGetTaskStateReportWithoutFilters() {
    // given
    TaskQueryItem queryItem1 = new TaskQueryItem();
    queryItem1.setCount(50);
    queryItem1.setState(TaskState.READY);
    queryItem1.setDomain("DOMAIN_X");
    TaskQueryItem queryItem2 = new TaskQueryItem();
    queryItem2.setCount(30);
    queryItem2.setState(TaskState.COMPLETED);
    queryItem2.setDomain("DOMAIN_X");
    List<TaskQueryItem> queryItems = Arrays.asList(queryItem1, queryItem2);
    when(taskMonitorMapperMock.getTasksCountByState(null, null)).thenReturn(queryItems);
    // when
    TaskStatusReport report = cut.getTaskStatusReport();
    // then
    InOrder inOrder = inOrder(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineImplMock);
    inOrder.verify(taskanaEngineImplMock).openConnection();
    inOrder.verify(taskMonitorMapperMock).getTasksCountByState(eq(null), eq(null));
    inOrder.verify(taskanaEngineImplMock).returnConnection();
    assertNotNull(report);
    assertEquals(1, report.rowSize());
    assertArrayEquals(new int[] { 50, 0, 30 }, report.getRow("DOMAIN_X").getCells());
    assertArrayEquals(new int[] { 50, 0, 30 }, report.getSumRow().getCells());
    assertEquals(80, report.getRow("DOMAIN_X").getTotalValue());
    assertEquals(80, report.getSumRow().getTotalValue());
}
Also used : TaskQueryItem(pro.taskana.impl.report.impl.TaskQueryItem) InOrder(org.mockito.InOrder) TaskStatusReport(pro.taskana.impl.report.impl.TaskStatusReport) Test(org.junit.Test)

Example 4 with TaskQueryItem

use of pro.taskana.impl.report.impl.TaskQueryItem in project taskana by Taskana.

the class TaskMonitorServiceImpl method getTaskStatusReport.

@Override
public TaskStatusReport getTaskStatusReport(List<String> domains, List<TaskState> states) {
    try {
        taskanaEngineImpl.openConnection();
        List<TaskQueryItem> tasks = taskMonitorMapper.getTasksCountByState(domains, states);
        TaskStatusReport report = new TaskStatusReport(states);
        report.addItems(tasks);
        return report;
    } finally {
        taskanaEngineImpl.returnConnection();
    }
}
Also used : TaskQueryItem(pro.taskana.impl.report.impl.TaskQueryItem) TaskStatusReport(pro.taskana.impl.report.impl.TaskStatusReport)

Example 5 with TaskQueryItem

use of pro.taskana.impl.report.impl.TaskQueryItem in project taskana by Taskana.

the class ProvideTaskStatusReportAccTest method testCompleteTaskStatusReport.

@Test
public void testCompleteTaskStatusReport() {
    // given
    TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
    // when
    TaskStatusReport report = taskMonitorService.getTaskStatusReport();
    // then
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(reportToString(report));
    }
    assertNotNull(report);
    assertEquals(3, report.rowSize());
    ReportRow<TaskQueryItem> row1 = report.getRow("DOMAIN_A");
    assertArrayEquals(new int[] { 22, 4, 0 }, row1.getCells());
    assertEquals(26, row1.getTotalValue());
    ReportRow<TaskQueryItem> row2 = report.getRow("DOMAIN_B");
    assertArrayEquals(new int[] { 9, 3, 0 }, row2.getCells());
    assertEquals(12, row2.getTotalValue());
    ReportRow<TaskQueryItem> row3 = report.getRow("DOMAIN_C");
    assertArrayEquals(new int[] { 10, 2, 0 }, row3.getCells());
    assertEquals(12, row3.getTotalValue());
    ReportRow<TaskQueryItem> sumRow = report.getSumRow();
    assertArrayEquals(new int[] { 41, 9, 0 }, sumRow.getCells());
    assertEquals(50, sumRow.getTotalValue());
}
Also used : TaskQueryItem(pro.taskana.impl.report.impl.TaskQueryItem) TaskMonitorService(pro.taskana.TaskMonitorService) TaskStatusReport(pro.taskana.impl.report.impl.TaskStatusReport) Test(org.junit.Test) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)

Aggregations

TaskQueryItem (pro.taskana.impl.report.impl.TaskQueryItem)6 TaskStatusReport (pro.taskana.impl.report.impl.TaskStatusReport)6 Test (org.junit.Test)5 TaskMonitorService (pro.taskana.TaskMonitorService)3 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)3 InOrder (org.mockito.InOrder)2