Search in sources :

Example 26 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class ProjectEffortsSpreadSheetTest method testCreateRows_projectNotActiveAndHoursExists.

@Test
public void testCreateRows_projectNotActiveAndHoursExists() {
    Project project = filter.getProjects().get(0);
    project.setStatus(Project.Status.CLOSED);
    expect(workTimeService.getEmployees(filter)).andReturn(project.getTeam());
    replay(hoursRepository, projectRepository, workTimeService);
    HoursIndexedBundle bundle = new HoursIndexedBundle(getHours());
    List<SpreadSheetRow<?>> actual = spreadSheet.buildSpreadSheetRows(project, emptyList(), bundle);
    assertEquals(5, actual.size());
}
Also used : Project(com.artezio.arttime.datamodel.Project) Test(org.junit.Test)

Example 27 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class ProjectEffortsSpreadSheetTest method testCreateRows_hoursExistsAndNoTeam.

@Test
public void testCreateRows_hoursExistsAndNoTeam() {
    Project project = filter.getProjects().get(0);
    HoursIndexedBundle bundle = new HoursIndexedBundle(getHours());
    project.getTeam().clear();
    expect(workTimeService.getEmployees(filter)).andReturn(filter.getEmployees());
    replay(workTimeService);
    List<SpreadSheetRow<?>> actual = spreadSheet.buildSpreadSheetRows(project, emptyList(), bundle);
    assertEquals(5, actual.size());
}
Also used : Project(com.artezio.arttime.datamodel.Project) Test(org.junit.Test)

Example 28 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class ProjectEffortsSpreadSheetTest method testIsHighLevel_ifProjectInRowIsSubproject_AndMasterNotInFilter.

@Test
public void testIsHighLevel_ifProjectInRowIsSubproject_AndMasterNotInFilter() throws NoSuchFieldException {
    Project master = new Project();
    Project subproject = new Project(master);
    setField(master, "id", 1L);
    setField(subproject, "id", 2L);
    HeadSpreadSheetRow row = new HeadSpreadSheetRow(subproject);
    List<Project> projects = Arrays.asList(subproject);
    spreadSheet.getFilter().setProjects(projects);
    boolean actual = spreadSheet.isHighLevel(row);
    assertTrue(actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Test(org.junit.Test)

Example 29 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class ProjectEffortsSpreadSheetTest method testCalculateTotalKeysFor_masterProject.

@Test
public void testCalculateTotalKeysFor_masterProject() throws NoSuchFieldException {
    Project master = new Project();
    Project subproject = new Project(master);
    setField(master, "id", 1L);
    setField(subproject, "id", 2L);
    // master head row
    HeadSpreadSheetRow row1 = new HeadSpreadSheetRow(master);
    // master hours
    HoursSpreadSheetRow row2 = new HoursSpreadSheetRow(master, null, null, new ArrayList<>());
    // master totals
    TotalsSpreadSheetRow row3 = new TotalsSpreadSheetRow(master, null, Arrays.asList(row2));
    // subproject head row
    HeadSpreadSheetRow row4 = new HeadSpreadSheetRow(subproject);
    // subproject hours
    HoursSpreadSheetRow row5 = new HoursSpreadSheetRow(subproject, null, null, new ArrayList<>());
    // subproject totals
    TotalsSpreadSheetRow row6 = new TotalsSpreadSheetRow(subproject, null, Arrays.asList(row5));
    // master and subproject totals
    TotalsSpreadSheetRow row7 = new TotalsSpreadSheetRow(subproject, null, Arrays.asList(row2, row5));
    List<SpreadSheetRow<?>> rows = Arrays.asList(row1, row2, row3, row4, row5, row6, row7);
    setField(spreadSheet, "rows", rows);
    List<Integer> expected = Arrays.asList(rows.get(2).getKey(), rows.get(6).getKey());
    List<Integer> actual = spreadSheet.calculateKeysOfTotalsRows(row2);
    assertEquals(2, actual.size());
    ListAssert.assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Test(org.junit.Test)

Example 30 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class SpreadSheetTest method testGetSortedHourTypes_FilterHasNoHourTypes.

@Test
public void testGetSortedHourTypes_FilterHasNoHourTypes() throws NoSuchFieldException {
    List<Employee> employees = new ArrayList<>();
    List<HourType> hourTypes = buildHourTypeList(2);
    HourType hourType = new HourType("1");
    Project project = createProject("1", hourTypes, employees);
    List<Hours> hours = buildHourList(project, employees, hourType, null);
    setField(filter, "hourTypes", new ArrayList<>());
    setField(spreadSheet, "filter", filter);
    setField(spreadSheet, "hourTypeRepository", hourTypeRepository);
    expect(hourTypeRepository.getAll()).andReturn(hourTypes);
    replay(hourTypeRepository);
    SortedSet<HourType> expected = new TreeSet<>(HourType.ACTUALTIME_TYPE_COMPARATOR);
    expected.addAll(hourTypes);
    SortedSet<HourType> actual = spreadSheet.getSortedHourTypes(project, hours);
    assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Test(org.junit.Test)

Aggregations

Project (com.artezio.arttime.datamodel.Project)310 Test (org.junit.Test)278 Employee (com.artezio.arttime.datamodel.Employee)195 HourType (com.artezio.arttime.datamodel.HourType)119 Hours (com.artezio.arttime.datamodel.Hours)108 Date (java.util.Date)61 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)56 Period (com.artezio.arttime.datamodel.Period)43 BigDecimal (java.math.BigDecimal)39 Filter (com.artezio.arttime.filter.Filter)33 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)21 ArrayList (java.util.ArrayList)18 Arrays.asList (java.util.Arrays.asList)18 ProjectRepository (com.artezio.arttime.repositories.ProjectRepository)17 List (java.util.List)17 HoursRepository (com.artezio.arttime.repositories.HoursRepository)13 HashMap (java.util.HashMap)13 Map (java.util.Map)11