Search in sources :

Example 71 with HourType

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

the class HoursIndexedBundleTest method testContainsHours_ByProjectAndEmployee_ifContainsOnlyEmployee.

@Test
public void testContainsHours_ByProjectAndEmployee_ifContainsOnlyEmployee() {
    Project project1 = createProject(1L);
    Project project2 = createProject(2L);
    Employee employee = new Employee("employee");
    HourType hourType = new HourType();
    Hours hour = new Hours(project1, new Date(), employee, hourType);
    List<Hours> hours = Arrays.asList(hour);
    bundle = createHoursIndexedBundle(hours);
    boolean actual = bundle.containsHours(project2, employee);
    assertFalse(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 72 with HourType

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

the class HoursIndexedBundleTest method testFindHours_ByProjectAndEmployee_NoHours.

@Test
public void testFindHours_ByProjectAndEmployee_NoHours() {
    Project project1 = createProject(1L);
    Project project2 = createProject(2L);
    Employee employee1 = new Employee("employee1");
    Employee employee2 = new Employee("employee2");
    Employee employee3 = new Employee("employee3");
    HourType type1 = new HourType("regular");
    Hours hours1 = createHours(project1, employee1, type1);
    Hours hours2 = createHours(project1, employee2, type1);
    bundle = createHoursIndexedBundle(Arrays.asList(hours1, hours2));
    assertTrue(bundle.findHours(project2, employee1).isEmpty());
    assertTrue(bundle.findHours(project1, employee3).isEmpty());
}
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 73 with HourType

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

the class HoursIndexedBundleTest method testFindHours_ByProjectAndEmployee.

@Test
public void testFindHours_ByProjectAndEmployee() {
    Project project1 = createProject(1L);
    Project project2 = createProject(2L);
    Employee employee1 = new Employee("employee1");
    Employee employee2 = new Employee("employee2");
    HourType type1 = new HourType("regular");
    HourType type2 = new HourType("overtime");
    Hours hours1 = createHours(project1, employee1, type1);
    Hours hours2 = createHours(project2, employee1, type2);
    Hours hours3 = createHours(project1, employee2, type1);
    bundle = createHoursIndexedBundle(Arrays.asList(hours1, hours2, hours3));
    List<Hours> actual = bundle.findHours(project1, employee1);
    ListAssert.assertEquals(Arrays.asList(hours1), 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 74 with HourType

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

the class HoursSpreadSheetRowTest method testGetRowTotal.

@Test
public void testGetRowTotal() throws Exception {
    Project project = new Project();
    Employee employee = new Employee();
    HourType hourType = new HourType();
    Date date1 = sdf.parse("1-01-2014");
    Date date2 = sdf.parse("2-01-2014");
    Date date3 = sdf.parse("3-01-2014");
    Date date4 = sdf.parse("4-01-2014");
    Hours hour1 = new Hours(project, date1, employee, hourType);
    hour1.setQuantity(BigDecimal.ONE);
    Hours hour2 = new Hours(project, date2, employee, hourType);
    hour2.setQuantity(BigDecimal.TEN);
    List<Hours> hours = Arrays.asList(hour1, hour2);
    row = new HoursSpreadSheetRow(project, employee, hourType, hours);
    row.getValuesMap().put(date3, new Hours(project, date3, employee, hourType));
    row.getValuesMap().put(date4, null);
    BigDecimal actual = row.getRowTotal();
    assertEquals(new BigDecimal("11"), 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) Date(java.util.Date) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 75 with HourType

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

the class HoursSpreadSheetRowTest method testGet_ifNotContainsValue.

@Test
public void testGet_ifNotContainsValue() throws Exception {
    Employee employee = new Employee();
    HourType hourType = new HourType();
    Date date = sdf.parse("1-01-2014");
    Project project = new Project();
    row = new HoursSpreadSheetRow(project, employee, hourType, new ArrayList<>());
    Hours actual = row.get(date);
    assertNull(actual.getQuantity());
}
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) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Aggregations

HourType (com.artezio.arttime.datamodel.HourType)172 Test (org.junit.Test)158 Project (com.artezio.arttime.datamodel.Project)120 Employee (com.artezio.arttime.datamodel.Employee)115 Hours (com.artezio.arttime.datamodel.Hours)103 Date (java.util.Date)60 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)54 Period (com.artezio.arttime.datamodel.Period)45 BigDecimal (java.math.BigDecimal)41 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)21 HashMap (java.util.HashMap)16 HoursRepository (com.artezio.arttime.repositories.HoursRepository)13 Map (java.util.Map)11 Arrays.asList (java.util.Arrays.asList)10 List (java.util.List)10 Filter (com.artezio.arttime.filter.Filter)7 Mail (com.artezio.arttime.services.mailing.Mail)7 ArrayList (java.util.ArrayList)7 HourTypeRepository (com.artezio.arttime.repositories.HourTypeRepository)6 RangePeriodSelector (com.artezio.arttime.web.criteria.RangePeriodSelector)6