Search in sources :

Example 1 with Period

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

the class CalendarPeriodSelectorTest method testSetWeekPeriod.

@Test
public void testSetWeekPeriod() throws ParseException, NoSuchFieldException {
    Period period = new Period(sdf.parse("1-05-2014"), sdf.parse("3-05-2014"));
    setField(rangePeriodSelector, "period", period);
    setField(rangePeriodSelector, "range", Range.CUSTOM);
    Period expectedPeriod = new Period(sdf.parse("27-04-2014"), sdf.parse("3-05-2014"));
    PowerMock.mockStatic(Locale.class);
    expect(Locale.getDefault()).andReturn(Locale.US);
    rangePeriodSelector.setWeekPeriod();
    Range actualRange = (Range) getField(rangePeriodSelector, "range");
    Period actualPeriod = (Period) getField(rangePeriodSelector, "period");
    assertEquals(Range.WEEK, actualRange);
    assertEquals(expectedPeriod, actualPeriod);
}
Also used : Period(com.artezio.arttime.datamodel.Period) Range(com.artezio.arttime.web.criteria.RangePeriodSelector.Range) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with Period

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

the class FilterServiceTest method testCreatePersonalTimesheetFilter.

@Test
public void testCreatePersonalTimesheetFilter() throws NoSuchFieldException {
    setField(filterService, "hourTypeRepository", hourTypeRepository);
    setField(filterService, "projectRepository", projectRepository);
    setField(filterService, "departmentRepository", departmentRepository);
    Filter currentFilter = new Filter();
    RangePeriodSelector currentPeriodSelector = new RangePeriodSelector(new Period(new Date(1), new Date(2)));
    currentFilter.setRangePeriodSelector(currentPeriodSelector);
    Employee employee = new Employee("user");
    expect(departmentRepository.getDepartments()).andReturn(Collections.emptyList());
    expect(hourTypeRepository.getAll()).andReturn(Collections.emptyList());
    expect(projectRepository.getActiveAndReportedProjects(employee, currentFilter.getPeriod())).andReturn(Collections.emptyList());
    replay(departmentRepository, hourTypeRepository, projectRepository);
    Filter actual = filterService.createPersonalTimesheetFilter(currentFilter, employee);
    verify(departmentRepository, hourTypeRepository, projectRepository);
    assertEquals(currentFilter.getPeriod(), actual.getPeriod());
    assertEquals(1, actual.getEmployees().size());
    assertEquals(employee, actual.getEmployees().get(0));
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) RangePeriodSelector(com.artezio.arttime.web.criteria.RangePeriodSelector) Period(com.artezio.arttime.datamodel.Period) Test(org.junit.Test)

Example 3 with Period

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

the class NotificationManagerTest method testNotificatePmAboutTimeProblems.

@Test
public void testNotificatePmAboutTimeProblems() throws MessagingException, NoSuchFieldException {
    notificationManager = createMockBuilder(NotificationManager.class).addMockedMethod("getProjects", List.class).addMockedMethod("getProjectManagers", Collection.class).createMock();
    setMockServices(notificationManager);
    Employee employee = new Employee("iivanov");
    Employee pm = new Employee("ppetrov");
    pm.setEmail("ppetrov@mail.com");
    Project project = createProject(1L, employee);
    List<Employee> employees = Arrays.asList(employee);
    List<Project> projects = Arrays.asList(project);
    Map<Employee, Map<Date, BigDecimal>> timeProblems = new HashMap<Employee, Map<Date, BigDecimal>>();
    timeProblems.put(employee, new HashMap<Date, BigDecimal>());
    Period period = new Period();
    String comment = "comment";
    String subject = "subject";
    String body = "body";
    expect(notificationManager.getProjects(employees)).andReturn(projects);
    expect(notificationManager.getProjectManagers(projects)).andReturn(Sets.newHashSet(pm));
    expect(hourTypeRepository.findActual()).andReturn(new HourType());
    expect(workTimeService.getApprovedWorkTimeProblems(period, employees)).andReturn(timeProblems);
    expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_BODY_FOR_PM.getFileName()), anyObject(Map.class))).andReturn(body);
    expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_SUBJECT.getFileName()), anyObject(Map.class))).andReturn(subject);
    mailingEngine.sendAsync("ppetrov@mail.com", new Mail(subject, body));
    replay(notificationManager, hourTypeRepository, workTimeService, mailTemplateManager, mailingEngine);
    notificationManager.notificatePmAboutTimeProblems(employees, period, comment);
    verify(notificationManager, hourTypeRepository, workTimeService, mailTemplateManager, mailingEngine);
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) HashMap(java.util.HashMap) Period(com.artezio.arttime.datamodel.Period) Date(java.util.Date) BigDecimal(java.math.BigDecimal) Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Mail(com.artezio.arttime.services.mailing.Mail) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 4 with Period

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

the class NotificationManagerTest method testNotificateAboutOwnTimeProblems.

@Test
public void testNotificateAboutOwnTimeProblems() throws MessagingException, NoSuchFieldException {
    setMockServices(notificationManager);
    Employee employee = new Employee("iivanov");
    employee.setEmail("iivanov@mail.com");
    List<Employee> employees = Arrays.asList(employee);
    Map<Employee, Map<Date, BigDecimal>> timeProblems = new HashMap<Employee, Map<Date, BigDecimal>>();
    timeProblems.put(employee, new HashMap<Date, BigDecimal>());
    Period period = new Period();
    String comment = "comment";
    String subject = "subject";
    String body = "body";
    expect(hourTypeRepository.findActual()).andReturn(new HourType());
    expect(workTimeService.getApprovedWorkTimeProblems(period, employees)).andReturn(timeProblems);
    expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_BODY.getFileName()), anyObject(Map.class))).andReturn(body);
    expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_SUBJECT.getFileName()), anyObject(Map.class))).andReturn(subject);
    mailingEngine.sendAsync("iivanov@mail.com", new Mail(subject, body));
    replay(hourTypeRepository, workTimeService, mailTemplateManager, mailingEngine);
    notificationManager.notificateAboutOwnTimeProblems(employees, period, comment);
    verify(hourTypeRepository, workTimeService, mailTemplateManager, mailingEngine);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Mail(com.artezio.arttime.services.mailing.Mail) HashMap(java.util.HashMap) Period(com.artezio.arttime.datamodel.Period) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap) TreeMap(java.util.TreeMap) Date(java.util.Date) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 5 with Period

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

the class HoursRepositoryTest method testGetApprovedActualHours_ifEmployeesIsEmpty.

@Test
public void testGetApprovedActualHours_ifEmployeesIsEmpty() {
    Period period = new Period();
    List<Employee> employees = new ArrayList<>();
    List<Hours> actual = hoursRepository.getApprovedActualHours(employees, period);
    assertTrue(actual.isEmpty());
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Hours(com.artezio.arttime.datamodel.Hours) ArrayList(java.util.ArrayList) Period(com.artezio.arttime.datamodel.Period) CalendarUtils.createPeriod(com.artezio.arttime.test.utils.CalendarUtils.createPeriod) 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