use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class NotificationScheduler method notifyAboutIncorrectTimesheet.
@Schedule(dayOfMonth = "1", persistent = false, info = NOTIFY_ABOUT_INCORRECT_TIMESHEET_INFO)
public void notifyAboutIncorrectTimesheet() {
if (settingsService.getSettings().isIncorrectTimesheetNotificationEnabled()) {
List<Employee> employees = employeeService.getCurrent();
Period period = getPeriodForPreviousMonth();
notificationManager.notifyAboutIncorrectTimesheet(employees, period);
}
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursServiceTest method testManageHours_HoursExistWhenSaving.
@Test
public void testManageHours_HoursExistWhenSaving() 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);
Hours persistedHours = createHours(2L, project, date, employee, hourType, true);
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);
EasyMock.expect(hoursRepository.update(hours)).andReturn(hours);
EasyMock.replay(sessionContext, hoursRepository);
hoursService.manageHours(asList(hours));
EasyMock.verify(sessionContext, hoursRepository);
assertEquals(persistedHours, hours);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursServiceTest method testReportHours_HoursExistWhenSaving.
@Test(expected = SaveApprovedHoursException.class)
public void testReportHours_HoursExistWhenSaving() 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);
Hours persistedHours = createHours(2L, project, date, employee, hourType, true);
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);
EasyMock.expect(hoursRepository.create(hours)).andReturn(hours);
EasyMock.replay(sessionContext, hoursRepository);
hoursService.reportHours(asList(hours));
EasyMock.verifyUnexpectedCalls(sessionContext, hoursRepository);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursServiceTest method testReportHours_HoursWithoutAnyValues_ApprovedHoursExist.
@Test(expected = SaveApprovedHoursException.class)
public void testReportHours_HoursWithoutAnyValues_ApprovedHoursExist() 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);
EasyMock.replay(hoursRepository);
hoursService.reportHours(hoursList);
EasyMock.verifyUnexpectedCalls(hoursRepository);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursServiceTest method testReportHours_HoursWithoutAnyValues_ApprovedHoursNotExist.
@Test
public void testReportHours_HoursWithoutAnyValues_ApprovedHoursNotExist() throws Exception {
Employee employee = new Employee();
Project project = new Project();
HourType hourType = new HourType();
Date date = new Date();
Period period = new Period(date, date);
Hours hours = createHours(1L, project, date, employee, hourType, false);
List<Hours> hoursList = asList(hours);
Set<Project> projects = singleton(project);
Set<Employee> employees = singleton(employee);
HoursRepository.HoursQuery query = Mockito.mock(HoursRepository.HoursQuery.class, Mockito.RETURNS_DEEP_STUBS);
EasyMock.expect(hoursRepository.query()).andReturn(query).anyTimes();
Mockito.when(query.projects(projects).period(period).employees(employees).uncached().list()).thenReturn(emptyList());
hoursRepository.lock(employee);
hoursRepository.remove(hours);
EasyMock.replay(hoursRepository);
hoursService.reportHours(hoursList);
EasyMock.verifyUnexpectedCalls(hoursRepository);
Mockito.verify(query.projects(projects).period(period).employees(employees).uncached()).list();
}
Aggregations