use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class HoursServiceTest method testExistApprovedHours.
@Test
public void testExistApprovedHours() throws NoSuchFieldException {
Employee employee = new Employee("employee");
Project project = new Project();
setField(project, "id", 1L);
HourType hourType = new HourType("regular");
Hours hour1 = new Hours(project, getOffsetDate(-1), employee, hourType);
Hours hour2 = new Hours(project, getOffsetDate(1), employee, hourType);
hour2.setApproved(true);
List<Hours> persisted = asList(hour1, hour2);
Hours hour3 = new Hours(project, getOffsetDate(1), employee, hourType);
hoursService = new HoursService();
boolean actual = hoursService.existApprovedHours(asList(hour3), persisted);
assertTrue(actual);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotifyPmAboutTimeProblems.
@Test
public void testNotifyPmAboutTimeProblems() throws NoSuchFieldException {
notificationManager = createMockBuilder(NotificationManager.class).addMockedMethod("getProjects", List.class).addMockedMethod("getProjectManagers", Collection.class).createMock();
setMockServices(notificationManager);
Employee sender = new Employee("sender", "sender", "sender", "sender");
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<>();
timeProblems.put(employee, new HashMap<>());
Period period = new Period();
String comment = "comment";
String subject = "subject";
String body = "body";
EasyMock.expect(notificationManager.getProjects(employees)).andReturn(projects);
EasyMock.expect(notificationManager.getProjectManagers(projects)).andReturn(Lists.newArrayList(pm));
EasyMock.expect(hourTypeService.findActualTime()).andReturn(new HourType());
EasyMock.expect(workTimeService.getWorkTimeDeviations(period, employees)).andReturn(timeProblems);
EasyMock.expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_BODY_FOR_PM.getFileName()), anyObject(Map.class))).andReturn(body);
EasyMock.expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_SUBJECT.getFileName()), anyObject(Map.class))).andReturn(subject);
EasyMock.expect(settings.getSmtpUsername()).andReturn("testSmtpUsername");
EasyMock.expect(settings.getSmtpSender()).andReturn("sender");
EasyMock.expect(settings.getApplicationBaseUrl()).andReturn("appHost");
mailingEngine.send(new Mail(subject, body, sender.getEmail(), pm.getEmail()));
EasyMock.replay(notificationManager, hourTypeService, workTimeService, mailTemplateManager, mailingEngine, settings);
notificationManager.notifyProjectManagers(employees, period, comment);
EasyMock.verify(notificationManager, hourTypeService, workTimeService, mailTemplateManager, mailingEngine);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class NotificationManagerTest method testGetSubordinateProblems.
@Test
public void testGetSubordinateProblems() throws Exception {
Employee employee1 = createEmployee("iivanov", "Ivan", "Ivanov");
Employee employee2 = createEmployee("ppetrov", "Petr", "Petrov");
Employee employee3 = createEmployee("asidorov", "Andrey", "Sidorov");
Project project1 = createProject(1L, employee2);
Project project2 = createProject(2L, employee3, employee1);
project1.addManager(employee1);
project2.addManager(employee2);
List<Project> projects = Arrays.asList(project1, project2);
Map<Employee, Map<Date, BigDecimal>> timeProblems = new HashMap<>();
timeProblems.put(employee1, new HashMap<>());
timeProblems.put(employee2, new HashMap<>());
timeProblems.put(employee3, new HashMap<>());
Set<WorkTimeProblems> actual = notificationManager.getEmployeeWorktimeProblems(employee1, projects, timeProblems);
assertEquals(1, actual.size());
assertEquals(employee2, actual.iterator().next().getEmployee());
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class NotificationManagerTest method testGetProjects.
@Test
public void testGetProjects() throws NoSuchFieldException {
setMockServices(notificationManager);
Employee employee1 = createEmployee("iivanov", "Ivan", "Ivanov");
Employee employee2 = createEmployee("ppetrov", "Petr", "Petrov");
Employee employee3 = createEmployee("asidorov", "Andrey", "Sidorov");
Employee employee4 = createEmployee("afedorov", "Andrey", "Fedorov");
Project project1 = createProject(1L, employee1);
Project project2 = createProject(2L, employee1, employee2, employee3);
List<Employee> employees = Arrays.asList(employee1, employee2, employee4);
ProjectRepository.ProjectQuery projectQuery = Mockito.mock(ProjectRepository.ProjectQuery.class, Mockito.RETURNS_DEEP_STUBS);
List<Project> expected = Arrays.asList(project1, project2);
EasyMock.expect(projectRepository.query()).andReturn(projectQuery);
Mockito.when(projectQuery.status(ACTIVE).teamMembers(employees).fetchManagers().fetchTeam().list()).thenReturn(expected);
EasyMock.replay(projectRepository);
List<Project> actual = notificationManager.getProjects(employees);
assertEquals(expected, actual);
EasyMock.verify(projectRepository);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class ProjectServiceTest method testGetProjectHierarchy_ProjectHasNoSubprojects.
@Test
public void testGetProjectHierarchy_ProjectHasNoSubprojects() {
Project master = createProject(1L, null);
List<Project> expected = asList(master);
ProjectRepository.ProjectQuery projectQuery = Mockito.mock(ProjectRepository.ProjectQuery.class, Mockito.RETURNS_DEEP_STUBS);
EasyMock.expect(projectRepository.query()).andReturn(projectQuery).once();
Mockito.when(projectQuery.masters(asList(master)).status(ACTIVE).distinct().list()).thenReturn(emptyList());
replay(projectRepository);
List<Project> actual = projectService.getProjectHierarchy(master);
EasyMock.verify(projectRepository);
ListAssert.assertEquals(expected, actual);
}
Aggregations