Search in sources :

Example 51 with Employee

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

the class DepartmentServiceTest method getEmployeesInTrackingSystem.

private List<Employee> getEmployeesInTrackingSystem() {
    Employee employee1 = new Employee();
    Employee employee2 = new Employee();
    Employee employee3 = new Employee();
    employee1.setDepartment("Minsk");
    employee2.setDepartment("Minsk");
    employee3.setDepartment("Moscow");
    return Arrays.asList(employee1, employee2, employee3);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee)

Example 52 with Employee

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

the class EmployeeSynchronizerTest method testSynchronizeEmployees_externalEmployeeNotFound.

@Test
public void testSynchronizeEmployees_externalEmployeeNotFound() throws Exception {
    String userName = "ssmirnoff";
    Employee externalEmployee = null;
    Employee internalEmployee = new Employee(userName, "Oldfirst", "Oldlast", "Oldmail");
    List<Employee> internalEmployeeList = Arrays.asList(internalEmployee);
    expect(employeeRepository.getAll()).andReturn(internalEmployeeList);
    expect(employeeService.findEmployee(userName)).andReturn(externalEmployee);
    expect(employeeRepository.update(internalEmployee)).andReturn(internalEmployee);
    replay(employeeRepository, employeeService);
    employeeSynchronizer.synchronizeEmployees();
    verify(employeeRepository, employeeService);
    assertTrue(internalEmployee.isFormer());
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 53 with Employee

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

the class NotificationManagerTest method testRequestReport.

@Test
public void testRequestReport() throws Exception {
    setMockServices(notificationManager);
    expect(mailTemplateManager.getTemplateText(eq(MailTemplate.REQUEST_REPORT_BODY.getFileName()), anyObject(Map.class))).andReturn("body");
    expect(mailTemplateManager.getTemplateText(eq(MailTemplate.REQUEST_REPORT_SUBJECT.getFileName()), anyObject(Map.class))).andReturn("subject");
    Period period = new Period();
    Employee pm = new Employee("ppetrov");
    pm.setEmail("ppetrov@mail.com");
    mailingEngine.send("ppetrov@mail.com", "iivanov@mail.com", new Mail("subject", "body"));
    replay(mailTemplateManager, mailingEngine);
    notificationManager.requestReport(pm, "iivanov@mail.com", period);
    verify(mailTemplateManager, mailingEngine);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Mail(com.artezio.arttime.services.mailing.Mail) Period(com.artezio.arttime.datamodel.Period) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 54 with Employee

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

the class NotificationManagerTest method testSubordinateGetDeviationDetails.

@Test
public void testSubordinateGetDeviationDetails() throws Exception {
    Employee employee = createEmployee("iivanov", "Ivan", "Ivanov");
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
    Map<Date, BigDecimal> approvedWorkTimeProblems = new TreeMap<Date, BigDecimal>();
    approvedWorkTimeProblems.put(sdf.parse("1-01-2015"), BigDecimal.ONE);
    approvedWorkTimeProblems.put(sdf.parse("2-01-2015"), BigDecimal.TEN);
    approvedWorkTimeProblems.put(sdf.parse("3-01-2015"), BigDecimal.ZERO);
    SubordinateProblem subordinateProblem = notificationManager.new SubordinateProblem(employee, approvedWorkTimeProblems);
    Object[] expected = new Object[] { new AbstractMap.SimpleEntry<Date, BigDecimal>(sdf.parse("1-01-2015"), BigDecimal.ONE), new AbstractMap.SimpleEntry<Date, BigDecimal>(sdf.parse("2-01-2015"), BigDecimal.TEN), new AbstractMap.SimpleEntry<Date, BigDecimal>(sdf.parse("3-01-2015"), BigDecimal.ZERO) };
    Object[] actual = subordinateProblem.getDeviationDetails();
    assertEquals(expected, actual);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) EasyMock.anyObject(org.easymock.EasyMock.anyObject) TreeMap(java.util.TreeMap) SimpleDateFormat(com.ibm.icu.text.SimpleDateFormat) SubordinateProblem(com.artezio.arttime.services.NotificationManager.SubordinateProblem) Date(java.util.Date) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 55 with Employee

use of com.artezio.arttime.datamodel.Employee 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)

Aggregations

Employee (com.artezio.arttime.datamodel.Employee)201 Test (org.junit.Test)173 Project (com.artezio.arttime.datamodel.Project)121 HourType (com.artezio.arttime.datamodel.HourType)74 Hours (com.artezio.arttime.datamodel.Hours)65 Date (java.util.Date)39 BigDecimal (java.math.BigDecimal)33 Period (com.artezio.arttime.datamodel.Period)28 Filter (com.artezio.arttime.filter.Filter)23 ArrayList (java.util.ArrayList)20 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)19 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)18 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)15 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)13 HashMap (java.util.HashMap)12 WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)7 Mail (com.artezio.arttime.services.mailing.Mail)7 ProjectRepository (com.artezio.arttime.services.repositories.ProjectRepository)7 List (java.util.List)7 Map (java.util.Map)7