use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursServiceTest method testReportHours_HoursNotExistWhenSaving.
@Test
public void testReportHours_HoursNotExistWhenSaving() throws Exception {
Employee employee = new Employee();
Project project = new Project();
HourType hourType = new HourType();
Date date = new Date();
Hours hours = createHours(1L, project, date, employee, hourType, true);
List<Hours> persistedHours = emptyList();
HoursRepository.HoursQuery query = Mockito.mock(HoursRepository.HoursQuery.class, Mockito.RETURNS_DEEP_STUBS);
EasyMock.expect(hoursRepository.query()).andReturn(query).anyTimes();
Mockito.when(query.projects(singleton(project)).period(new Period(date, date)).employees(singleton(employee)).uncached().list()).thenReturn(persistedHours);
hoursRepository.lock(employee);
EasyMock.expectLastCall();
EasyMock.expect(hoursRepository.create(hours)).andReturn(hours);
EasyMock.replay(sessionContext, hoursRepository);
hoursService.reportHours(asList(hours));
EasyMock.verify(sessionContext, hoursRepository);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursServiceTest method testManageHours_HoursWithoutAnyValues.
@Test
public void testManageHours_HoursWithoutAnyValues() throws Exception {
Employee employee = new Employee();
Project project = new Project();
HourType hourType = new HourType();
Date date = new Date();
Hours hours = createHours(1L, project, date, employee, hourType, false);
Hours persistedHours = createHours(2L, project, date, employee, hourType, true);
List<Hours> hoursList = asList(hours);
List<Hours> persistedHoursList = asList(persistedHours);
HoursRepository.HoursQuery query = Mockito.mock(HoursRepository.HoursQuery.class, Mockito.RETURNS_DEEP_STUBS);
EasyMock.expect(hoursRepository.query()).andReturn(query).anyTimes();
Mockito.when(query.projects(singleton(project)).period(new Period(date, date)).employees(singleton(employee)).uncached().list()).thenReturn(persistedHoursList);
hoursRepository.lock(employee);
hoursRepository.remove(hours);
EasyMock.replay(hoursRepository);
hoursService.manageHours(hoursList);
EasyMock.verifyUnexpectedCalls(hoursRepository);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursServiceTest method testExistApprovedHours_DifferentDates.
@Test
public void testExistApprovedHours_DifferentDates() throws NoSuchFieldException {
Employee employee = new Employee("employee");
Project project = new Project();
setField(project, "id", 1L);
HourType hourType = new HourType("regular");
Hours persisted = new Hours(project, getOffsetDate(0), employee, hourType);
persisted.setApproved(true);
Hours newHour1 = new Hours(project, getOffsetDate(-1), employee, hourType);
Hours newHour2 = new Hours(project, getOffsetDate(1), employee, hourType);
hoursService = new HoursService();
boolean actual = hoursService.existApprovedHours(asList(newHour1, newHour2), asList(persisted));
assertFalse(actual);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursServiceTest method testManageHours_HoursNotExistWhenSaving.
@Test
public void testManageHours_HoursNotExistWhenSaving() throws Exception {
Employee employee = new Employee();
Project project = new Project();
HourType hourType = new HourType();
Date date = new Date();
Hours hours = createHours(1L, project, date, employee, hourType, true);
List<Hours> persistedHours = emptyList();
HoursRepository.HoursQuery query = Mockito.mock(HoursRepository.HoursQuery.class, Mockito.RETURNS_DEEP_STUBS);
EasyMock.expect(hoursRepository.query()).andReturn(query).anyTimes();
Mockito.when(query.projects(singleton(project)).period(new Period(date, date)).employees(singleton(employee)).uncached().list()).thenReturn(persistedHours);
hoursRepository.lock(employee);
EasyMock.expectLastCall();
EasyMock.expect(hoursRepository.create(hours)).andReturn(hours);
EasyMock.replay(hoursRepository);
hoursService.manageHours(asList(hours));
EasyMock.verify(hoursRepository);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursServiceTest method testExistApprovedHours_DifferentIds.
@Test
public void testExistApprovedHours_DifferentIds() throws NoSuchFieldException {
Employee employee = new Employee("employee");
Project project = new Project();
setField(project, "id", 1L);
HourType hourType = new HourType("regular");
Date date = new Date();
Hours persisted = new Hours(project, date, employee, hourType);
persisted.setApproved(true);
setField(persisted, "id", 1L);
Hours newHour = new Hours(project, date, employee, hourType);
setField(newHour, "id", 2L);
hoursService = new HoursService();
boolean actual = hoursService.existApprovedHours(asList(newHour), asList(persisted));
assertTrue(actual);
}
Aggregations