Search in sources :

Example 66 with HourType

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

the class ProjectRepositoryTest method testCreateProject.

@Test
public void testCreateProject() throws NoSuchFieldException {
    HourType hourType = new HourType("type");
    WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
    entityManager.persist(hourType);
    entityManager.persist(calendar);
    entityManager.flush();
    entityManager.clear();
    Employee manager = new Employee("manager");
    Employee resource = new Employee("slave");
    resource.setCalendar(calendar);
    Project project = new Project();
    project.addManager(manager);
    project.getAccountableHours().add(hourType);
    project.addTeamMember(resource);
    assertNull(project.getId());
    setField(projectRepository, "employeeRepository", employeeRepository);
    expect(employeeRepository.create(resource)).andReturn(getPersisted(resource));
    expect(employeeRepository.create(manager)).andReturn(getPersisted(manager));
    replay(employeeRepository);
    Project actual = projectRepository.create(project);
    entityManager.flush();
    verify(employeeRepository);
    assertNotNull(actual.getId());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Project(com.artezio.arttime.datamodel.Project) HourType(com.artezio.arttime.datamodel.HourType) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 67 with HourType

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

the class HourTypeConverterTest method testGetAsString_ifHourType.

@Test
public void testGetAsString_ifHourType() throws Exception {
    HourType hourType = new HourType();
    setField(hourType, "id", 1L);
    String actual = converter.getAsString(facesContext, component, hourType);
    assertEquals("1", actual);
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) Test(org.junit.Test)

Example 68 with HourType

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

the class HourTypeConverterTest method testGetAsObject_ifFoundInRepository.

@Test
public void testGetAsObject_ifFoundInRepository() throws Exception {
    setField(converter, "hourTypeRepository", hourTypeRepository);
    HourType hourType = new HourType();
    expect(hourTypeRepository.find(1L)).andReturn(hourType);
    replay(hourTypeRepository);
    Object actual = converter.getAsObject(facesContext, component, "1");
    EasyMock.verify(hourTypeRepository);
    assertSame(hourType, actual);
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) Test(org.junit.Test)

Example 69 with HourType

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

the class HoursIndexedBundleTest method testContainsHours_ByEmployee_ifNotContains.

@Test
public void testContainsHours_ByEmployee_ifNotContains() {
    Project project = createProject(1L);
    Employee employee1 = new Employee("employee1");
    Employee employee2 = new Employee("employee2");
    HourType hourType = new HourType();
    Hours hour = new Hours(project, new Date(), employee1, hourType);
    List<Hours> hours = Arrays.asList(hour);
    bundle = createHoursIndexedBundle(hours);
    boolean actual = bundle.containsHours(employee2);
    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 70 with HourType

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

the class HoursIndexedBundleTest method testContainsHours_ByProjectAndEmployee_ifNotContainsProjectAndEmployee.

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

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