Search in sources :

Example 41 with TimeIntervalColumnHeader

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

the class DaysToWorkingDaysConverterTest method testConvertWorkingDaysToDaysForTasks.

@Test
public void testConvertWorkingDaysToDaysForTasks() {
    List<TimeIntervalColumnHeader> reportItems = Collections.singletonList(new TimeIntervalColumnHeader(0));
    try {
        DaysToWorkingDaysConverter converter = DaysToWorkingDaysConverter.initialize(reportItems, Instant.now());
        Instant thursday0201 = Instant.parse("2018-02-01T07:00:00.000Z");
        // = thursday
        long days = converter.convertWorkingDaysToDays(thursday0201, 0);
        assertEquals(0, days);
        // fri
        days = converter.convertWorkingDaysToDays(thursday0201, 1);
        assertEquals(1, days);
        // mon
        days = converter.convertWorkingDaysToDays(thursday0201, 2);
        assertEquals(4, days);
        // tues
        days = converter.convertWorkingDaysToDays(thursday0201, 3);
        assertEquals(5, days);
        // we
        days = converter.convertWorkingDaysToDays(thursday0201, 4);
        assertEquals(6, days);
        // thurs
        days = converter.convertWorkingDaysToDays(thursday0201, 5);
        assertEquals(7, days);
        // fri
        days = converter.convertWorkingDaysToDays(thursday0201, 6);
        assertEquals(8, days);
        // mon
        days = converter.convertWorkingDaysToDays(thursday0201, 7);
        assertEquals(11, days);
        // tue
        days = converter.convertWorkingDaysToDays(thursday0201, 8);
        assertEquals(12, days);
        // we
        days = converter.convertWorkingDaysToDays(thursday0201, 9);
        assertEquals(13, days);
        // thu
        days = converter.convertWorkingDaysToDays(thursday0201, 10);
        assertEquals(14, days);
        // fri
        days = converter.convertWorkingDaysToDays(thursday0201, 11);
        assertEquals(15, days);
        Instant gruenDonnerstag2018 = Instant.parse("2018-03-29T01:00:00.000Z");
        days = converter.convertWorkingDaysToDays(gruenDonnerstag2018, 0);
        assertEquals(0, days);
        // Karfreitag
        days = converter.convertWorkingDaysToDays(gruenDonnerstag2018, 1);
        // osterdienstag
        assertEquals(5, days);
        // Karfreitag
        days = converter.convertWorkingDaysToDays(gruenDonnerstag2018, 2);
        // ostermittwoch
        assertEquals(6, days);
        Instant freitag0427 = Instant.parse("2018-04-27T19:00:00.000Z");
        days = converter.convertWorkingDaysToDays(freitag0427, 0);
        assertEquals(0, days);
        days = converter.convertWorkingDaysToDays(freitag0427, 1);
        // 30.4.
        assertEquals(3, days);
        days = converter.convertWorkingDaysToDays(freitag0427, 2);
        // 2.5.
        assertEquals(5, days);
    } catch (InvalidArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        fail("");
    }
}
Also used : InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) Instant(java.time.Instant) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) Test(org.junit.Test)

Example 42 with TimeIntervalColumnHeader

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

the class TaskMonitorServiceImplTest method testGetClassificationReportWithReportLineItemDefinitions.

@Test
public void testGetClassificationReportWithReportLineItemDefinitions() throws InvalidArgumentException {
    List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
    List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY);
    List<String> categories = Collections.singletonList("EXTERN");
    List<String> domains = Collections.singletonList("DOMAIN_A");
    CustomField customField = CustomField.CUSTOM_1;
    List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
    List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
    List<MonitorQueryItem> expectedResult = new ArrayList<>();
    MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
    monitorQueryItem.setKey("CLI:000000000000000000000000000000000001");
    monitorQueryItem.setAgeInDays(0);
    monitorQueryItem.setNumberOfTasks(1);
    expectedResult.add(monitorQueryItem);
    doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfClassifications(workbasketIds, states, categories, domains, customField, customFieldValues);
    ClassificationReport actualResult = cut.getClassificationReport(workbasketIds, states, categories, domains, customField, customFieldValues, reportLineItemDefinitions);
    verify(taskanaEngineImplMock, times(1)).openConnection();
    verify(taskanaEngineImplMock, times(2)).getConfiguration();
    verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
    verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
    verify(taskMonitorMapperMock, times(1)).getTaskCountOfClassifications(any(), any(), any(), any(), any(), any());
    verify(taskanaEngineImplMock, times(1)).returnConnection();
    verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
    assertNotNull(actualResult);
    assertEquals(actualResult.getRow("CLI:000000000000000000000000000000000001").getTotalValue(), 1);
    assertEquals(actualResult.getRow("CLI:000000000000000000000000000000000001").getCells()[0], 1);
    assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
Also used : DetailedMonitorQueryItem(pro.taskana.impl.report.impl.DetailedMonitorQueryItem) MonitorQueryItem(pro.taskana.impl.report.impl.MonitorQueryItem) CustomField(pro.taskana.CustomField) ArrayList(java.util.ArrayList) TaskState(pro.taskana.TaskState) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) ClassificationReport(pro.taskana.impl.report.impl.ClassificationReport) DetailedClassificationReport(pro.taskana.impl.report.impl.DetailedClassificationReport) Test(org.junit.Test)

Example 43 with TimeIntervalColumnHeader

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

the class TaskMonitorServiceImplTest method testGetCategoryReportWithReportLineItemDefinitions.

@Test
public void testGetCategoryReportWithReportLineItemDefinitions() throws InvalidArgumentException {
    List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
    List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY);
    List<String> categories = Collections.singletonList("EXTERN");
    List<String> domains = Collections.singletonList("DOMAIN_A");
    CustomField customField = CustomField.CUSTOM_1;
    List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
    List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
    List<MonitorQueryItem> expectedResult = new ArrayList<>();
    MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
    monitorQueryItem.setKey("EXTERN");
    monitorQueryItem.setAgeInDays(0);
    monitorQueryItem.setNumberOfTasks(1);
    expectedResult.add(monitorQueryItem);
    doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfCategories(workbasketIds, states, categories, domains, customField, customFieldValues);
    CategoryReport actualResult = cut.getCategoryReport(workbasketIds, states, categories, domains, customField, customFieldValues, reportLineItemDefinitions);
    verify(taskanaEngineImplMock, times(1)).openConnection();
    verify(taskanaEngineImplMock, times(2)).getConfiguration();
    verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
    verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
    verify(taskMonitorMapperMock, times(1)).getTaskCountOfCategories(any(), any(), any(), any(), any(), any());
    verify(taskanaEngineImplMock, times(1)).returnConnection();
    verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
    assertNotNull(actualResult);
    assertEquals(actualResult.getRow("EXTERN").getTotalValue(), 1);
    assertEquals(actualResult.getRow("EXTERN").getCells()[0], 1);
    assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
Also used : DetailedMonitorQueryItem(pro.taskana.impl.report.impl.DetailedMonitorQueryItem) MonitorQueryItem(pro.taskana.impl.report.impl.MonitorQueryItem) CustomField(pro.taskana.CustomField) ArrayList(java.util.ArrayList) TaskState(pro.taskana.TaskState) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) CategoryReport(pro.taskana.impl.report.impl.CategoryReport) Test(org.junit.Test)

Example 44 with TimeIntervalColumnHeader

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

the class TaskMonitorServiceImplTest method testGetTaskIdsOfCategoryReportLineItems.

@Test
public void testGetTaskIdsOfCategoryReportLineItems() throws InvalidArgumentException {
    List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
    List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY);
    List<String> categories = Collections.singletonList("EXTERN");
    List<String> domains = Collections.singletonList("DOMAIN_A");
    CustomField customField = CustomField.CUSTOM_1;
    List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
    List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
    SelectedItem selectedItem = new SelectedItem();
    selectedItem.setKey("EXTERN");
    selectedItem.setLowerAgeLimit(1);
    selectedItem.setUpperAgeLimit(5);
    List<SelectedItem> selectedItems = Collections.singletonList(selectedItem);
    List<String> expectedResult = Collections.singletonList("TKI:000000000000000000000000000000000001");
    doReturn(expectedResult).when(taskMonitorMapperMock).getTaskIdsOfCategoriesBySelectedItems(workbasketIds, states, categories, domains, customField, customFieldValues, selectedItems);
    List<String> actualResult = cut.getTaskIdsOfCategoryReportLineItems(workbasketIds, states, categories, domains, customField, customFieldValues, reportLineItemDefinitions, selectedItems);
    verify(taskanaEngineImplMock, times(1)).openConnection();
    verify(taskanaEngineImplMock, times(2)).getConfiguration();
    verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
    verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
    verify(taskMonitorMapperMock, times(1)).getTaskIdsOfCategoriesBySelectedItems(any(), any(), any(), any(), any(), any(), any());
    verify(taskanaEngineImplMock, times(1)).returnConnection();
    verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
    assertNotNull(actualResult);
    assertEquals(expectedResult, actualResult);
}
Also used : CustomField(pro.taskana.CustomField) TaskState(pro.taskana.TaskState) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) Test(org.junit.Test)

Example 45 with TimeIntervalColumnHeader

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

the class TaskMonitorServiceImplTest method testGetDetailedClassificationReportWithReportLineItemDefinitions.

@Test
public void testGetDetailedClassificationReportWithReportLineItemDefinitions() throws InvalidArgumentException {
    List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
    List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY);
    List<String> categories = Collections.singletonList("EXTERN");
    List<String> domains = Collections.singletonList("DOMAIN_A");
    CustomField customField = CustomField.CUSTOM_1;
    List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
    List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
    List<DetailedMonitorQueryItem> expectedResult = new ArrayList<>();
    DetailedMonitorQueryItem detailedMonitorQueryItem = new DetailedMonitorQueryItem();
    detailedMonitorQueryItem.setKey("CLI:000000000000000000000000000000000001");
    detailedMonitorQueryItem.setAttachmentKey("CLI:000000000000000000000000000000000006");
    detailedMonitorQueryItem.setAgeInDays(0);
    detailedMonitorQueryItem.setNumberOfTasks(1);
    expectedResult.add(detailedMonitorQueryItem);
    doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfDetailedClassifications(workbasketIds, states, categories, domains, customField, customFieldValues);
    DetailedClassificationReport actualResult = cut.getDetailedClassificationReport(workbasketIds, states, categories, domains, customField, customFieldValues, reportLineItemDefinitions);
    verify(taskanaEngineImplMock, times(1)).openConnection();
    verify(taskanaEngineImplMock, times(2)).getConfiguration();
    verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
    verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
    verify(taskMonitorMapperMock, times(1)).getTaskCountOfDetailedClassifications(any(), any(), any(), any(), any(), any());
    verify(taskanaEngineImplMock, times(1)).returnConnection();
    verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
    DetailedReportRow line = actualResult.getRow("CLI:000000000000000000000000000000000001");
    assertNotNull(actualResult);
    assertEquals(line.getTotalValue(), 1);
    assertEquals(line.getDetailRows().get("CLI:000000000000000000000000000000000006").getTotalValue(), 1);
    assertEquals(line.getCells()[0], 1);
    assertEquals(line.getDetailRows().get("CLI:000000000000000000000000000000000006").getCells()[0], 1);
    assertEquals(actualResult.getSumRow().getTotalValue(), 1);
    assertEquals(actualResult.getSumRow().getCells()[0], 1);
}
Also used : CustomField(pro.taskana.CustomField) ArrayList(java.util.ArrayList) DetailedClassificationReport(pro.taskana.impl.report.impl.DetailedClassificationReport) DetailedMonitorQueryItem(pro.taskana.impl.report.impl.DetailedMonitorQueryItem) DetailedReportRow(pro.taskana.impl.report.impl.DetailedReportRow) TaskState(pro.taskana.TaskState) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) Test(org.junit.Test)

Aggregations

TimeIntervalColumnHeader (pro.taskana.impl.report.impl.TimeIntervalColumnHeader)75 Test (org.junit.Test)57 TaskMonitorService (pro.taskana.TaskMonitorService)46 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)46 ArrayList (java.util.ArrayList)25 CustomField (pro.taskana.CustomField)19 DetailedMonitorQueryItem (pro.taskana.impl.report.impl.DetailedMonitorQueryItem)13 TaskState (pro.taskana.TaskState)12 DetailedClassificationReport (pro.taskana.impl.report.impl.DetailedClassificationReport)10 CategoryReport (pro.taskana.impl.report.impl.CategoryReport)9 ClassificationReport (pro.taskana.impl.report.impl.ClassificationReport)9 CustomFieldValueReport (pro.taskana.impl.report.impl.CustomFieldValueReport)9 WorkbasketLevelReport (pro.taskana.impl.report.impl.WorkbasketLevelReport)9 DetailedReportRow (pro.taskana.impl.report.impl.DetailedReportRow)8 SelectedItem (pro.taskana.impl.SelectedItem)6 AbstractAccTest (acceptance.AbstractAccTest)4 DaysToWorkingDaysConverter (pro.taskana.impl.DaysToWorkingDaysConverter)4 MonitorQueryItem (pro.taskana.impl.report.impl.MonitorQueryItem)4 WithAccessId (pro.taskana.security.WithAccessId)4 Task (pro.taskana.Task)3