use of com.artezio.arttime.datamodel.Period 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.Period 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.Period 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.Period in project ART-TIME by Artezio.
the class NotificationSchedulerTest method testNotifyAboutUnapprovedHours.
@Test
public void testNotifyAboutUnapprovedHours() {
List<Employee> managers = Arrays.asList(new Employee("test_user"));
Date start = new GregorianCalendar(2020, 1, 1).getTime();
Date finish = new GregorianCalendar(2020, 1, 29).getTime();
Period period = new Period(start, finish);
expect(settingsService.getSettings()).andReturn(settings);
expect(settings.isUnapprovedHoursNotificationEnabled()).andReturn(true);
expect(notificationScheduler.getPeriodForPreviousMonth()).andReturn(period);
expect(hoursService.getManagersForUnapprovedHours(period)).andReturn(managers);
notificationManager.notifyAboutUnapprovedHours(managers, period);
expectLastCall().once();
replayAll();
notificationScheduler.notifyAboutUnapprovedHours();
verifyAll();
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class MonthSelectorTest method testInit.
@Test
public void testInit() throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
monthSelector = createMockBuilder(MonthSelector.class).addMockedMethod("getAttributes").createMock();
Period period = new Period(sdf.parse("1-01-2015"), sdf.parse("31-01-2015"));
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put("period", period);
expect(monthSelector.getAttributes()).andReturn(attrs);
replay(monthSelector);
monthSelector.init();
verify(monthSelector);
assertEquals(period, getField(monthSelector, "period"));
}
Aggregations