Search in sources :

Example 6 with Project

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

the class PersonalEffortsSpreadSheetTest method createProject.

private Project createProject(String code, List<HourType> hourTypes, List<Employee> employees) {
    Project project = new Project();
    project.setAccountableHours(hourTypes);
    project.setCode(code);
    project.getTeam().addAll(employees);
    return project;
}
Also used : Project(com.artezio.arttime.datamodel.Project)

Example 7 with Project

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

the class PersonalEffortsSpreadSheetTest method testGetValue_FromHoursSpreadSheetRow_EmployeeIsTeamMember.

@Test
public void testGetValue_FromHoursSpreadSheetRow_EmployeeIsTeamMember() {
    Project prj = new Project();
    Employee emp = new Employee();
    prj.getTeam().add(emp);
    HourType hourType = new HourType();
    Date date = new Date();
    List<Hours> hours = Collections.singletonList(new Hours(prj, date, emp, hourType));
    HoursSpreadSheetRow hoursSpreadSheetRow = new HoursSpreadSheetRow(prj, emp, hourType, hours);
    Hours expected = hours.get(0);
    Object actual = spreadSheet.getValue(hoursSpreadSheetRow, date);
    assertEquals(Hours.class, actual.getClass());
    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)

Example 8 with Project

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

the class PersonalEffortsSpreadSheetTest method testCalculateKeysOfTotals.

@Test
public void testCalculateKeysOfTotals() throws NoSuchFieldException {
    Date date = new Date(2017, 1, 1);
    Employee employee = new Employee("test");
    Project project = new Project();
    HourType hourType = new HourType("test");
    List<Hours> hours = Collections.singletonList(new Hours(project, date, employee, hourType));
    List<Integer> expected = Collections.singletonList(employee.hashCode() + project.hashCode() + hourType.hashCode() + 1237);
    List<HoursSpreadSheetRow> hoursSpreadSheetRows = Collections.singletonList(new HoursSpreadSheetRow(project, employee, hourType, hours));
    TotalsSpreadSheetRow totalRow = new TotalsSpreadSheetRow(project, hourType, hoursSpreadSheetRows);
    totalRow.setEmployee(employee);
    List<SpreadSheetRow> spreadSheetRows = Arrays.asList(new HeadSpreadSheetRow(employee), new HoursSpreadSheetRow(project, employee, hourType, hours), totalRow);
    spreadSheet = new PersonalEffortsSpreadSheet(hoursRepository, projectRepository, hourTypeRepository, employeeRepository, workTimeService, filter);
    setField(spreadSheet, "rows", spreadSheetRows);
    SpreadSheetRow spreadSheetRow = new HoursSpreadSheetRow(project, employee, hourType, hours);
    List<Integer> actual = spreadSheet.calculateKeysOfTotalsRows(spreadSheetRow);
    ListAssert.assertEquals(expected, actual);
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 9 with Project

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

the class ProjectEffortsSpreadSheetTest method testHasTeam_EmployeeNotInFilter.

@Test
public void testHasTeam_EmployeeNotInFilter() throws NoSuchFieldException {
    Employee employee = new Employee("employee");
    spreadSheet.getFilter().setEmployees(emptyList());
    Project master = createProject("master", emptyList(), asList(employee));
    Project subproject = createProject("subproject", emptyList(), asList(employee));
    setField(subproject, "master", master);
    assertFalse(spreadSheet.hasTeam(master, asList(subproject)));
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 10 with Project

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

the class ProjectEffortsSpreadSheetTest method testCreateRows_projectNotActiveAndNoHours.

@Test
public void testCreateRows_projectNotActiveAndNoHours() {
    Project project = new Project();
    project.setStatus(Project.Status.CLOSED);
    HoursIndexedBundle bundle = new HoursIndexedBundle(emptyList());
    List<SpreadSheetRow<?>> actual = spreadSheet.buildSpreadSheetRows(project, emptyList(), bundle);
    assertTrue(actual.isEmpty());
}
Also used : Project(com.artezio.arttime.datamodel.Project) 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