Search in sources :

Example 16 with WorkdaysCalendar

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

the class ProjectRepositoryTest method testCreateProjectWithSameEmployee.

@Test
public void testCreateProjectWithSameEmployee() throws NoSuchFieldException {
    Employee employee = new Employee("slave");
    WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
    entityManager.merge(employee);
    entityManager.persist(calendar);
    entityManager.flush();
    entityManager.clear();
    Employee manager = new Employee("manager");
    employee.setCalendar(calendar);
    Project project = new Project();
    project.addManager(manager);
    project.addTeamMember(employee);
    setField(projectRepository, "employeeRepository", employeeRepository);
    expect(employeeRepository.create(employee)).andReturn(employee);
    expect(employeeRepository.create(manager)).andReturn(getPersisted(manager));
    replay(employeeRepository);
    projectRepository.create(project);
    verify(employeeRepository);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 17 with WorkdaysCalendar

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

the class WorkdaysCalendarRepositoryTest method testFindByDepartment_notExists.

@Test
public void testFindByDepartment_notExists() {
    WorkdaysCalendar actual = workdaysCalendarRepository.findByDepartment("dep1");
    assertNull(actual);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Test(org.junit.Test)

Example 18 with WorkdaysCalendar

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

the class WorkdaysCalendarRepositoryTest method testCreateOrUpdateDays_Create.

@Test
public void testCreateOrUpdateDays_Create() {
    WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendarTtestCreateOrUpdateDays_Create");
    entityManager.persist(workdaysCalendar);
    Day expected = new Day(new Date(), workdaysCalendar);
    workdaysCalendarRepository.update(Arrays.asList(expected));
    assertNotNull(expected.getId());
    Day actual = entityManager.find(Day.class, expected.getId());
    assertEquals(expected, actual);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Day(com.artezio.arttime.datamodel.Day) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 19 with WorkdaysCalendar

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

the class WorkdaysCalendarRepositoryTest method testCreateWorkdaysCalendar.

@Test
public void testCreateWorkdaysCalendar() throws NoSuchFieldException {
    WorkdaysCalendar expected = new WorkdaysCalendar("expected calendar");
    WorkdaysCalendar actual = workdaysCalendarRepository.create(expected);
    assertSame(expected, actual);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Test(org.junit.Test)

Example 20 with WorkdaysCalendar

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

the class WorkdaysCalendarRepositoryTest method testUpdate.

@Test
public void testUpdate() {
    WorkdaysCalendar calendar = new WorkdaysCalendar("WDCal");
    entityManager.persist(calendar);
    entityManager.flush();
    String newName = "NewName";
    calendar.setName(newName);
    WorkdaysCalendar actual = workdaysCalendarRepository.update(calendar);
    assertEquals(newName, actual.getName());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Test(org.junit.Test)

Aggregations

WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)76 Test (org.junit.Test)65 Day (com.artezio.arttime.datamodel.Day)23 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)17 Employee (com.artezio.arttime.datamodel.Employee)16 Period (com.artezio.arttime.datamodel.Period)11 Date (java.util.Date)10 Project (com.artezio.arttime.datamodel.Project)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 SimpleDateFormat (java.text.SimpleDateFormat)5 DateFormat (java.text.DateFormat)3 Before (org.junit.Before)3 HourType (com.artezio.arttime.datamodel.HourType)2 Hours (com.artezio.arttime.datamodel.Hours)2 EmployeeRepository (com.artezio.arttime.repositories.EmployeeRepository)2 BigDecimal (java.math.BigDecimal)2 GregorianCalendar (java.util.GregorianCalendar)2 HashMap (java.util.HashMap)2 WebCached (com.artezio.arttime.admin_tool.cache.WebCached)1 Scope (com.artezio.arttime.admin_tool.cache.WebCached.Scope)1