Search in sources :

Example 81 with Period

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);
    }
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Period(com.artezio.arttime.datamodel.Period) Schedule(javax.ejb.Schedule)

Example 82 with 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);
}
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) Period(com.artezio.arttime.datamodel.Period) CalendarUtils.createPeriod(com.artezio.arttime.test.utils.CalendarUtils.createPeriod) HoursRepository(com.artezio.arttime.repositories.HoursRepository) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 83 with Period

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);
}
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) Period(com.artezio.arttime.datamodel.Period) CalendarUtils.createPeriod(com.artezio.arttime.test.utils.CalendarUtils.createPeriod) HoursRepository(com.artezio.arttime.repositories.HoursRepository) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 84 with Period

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);
}
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) Period(com.artezio.arttime.datamodel.Period) CalendarUtils.createPeriod(com.artezio.arttime.test.utils.CalendarUtils.createPeriod) HoursRepository(com.artezio.arttime.repositories.HoursRepository) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 85 with Period

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();
}
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) Period(com.artezio.arttime.datamodel.Period) CalendarUtils.createPeriod(com.artezio.arttime.test.utils.CalendarUtils.createPeriod) HoursRepository(com.artezio.arttime.repositories.HoursRepository) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Aggregations

Period (com.artezio.arttime.datamodel.Period)93 Test (org.junit.Test)87 Employee (com.artezio.arttime.datamodel.Employee)59 Date (java.util.Date)56 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)44 HourType (com.artezio.arttime.datamodel.HourType)43 Project (com.artezio.arttime.datamodel.Project)42 Hours (com.artezio.arttime.datamodel.Hours)40 BigDecimal (java.math.BigDecimal)34 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)22 Day (com.artezio.arttime.datamodel.Day)17 HashMap (java.util.HashMap)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)13 List (java.util.List)13 Map (java.util.Map)11 ArrayList (java.util.ArrayList)8 GregorianCalendar (java.util.GregorianCalendar)8 HoursRepository (com.artezio.arttime.repositories.HoursRepository)7 Mail (com.artezio.arttime.services.mailing.Mail)7