Search in sources :

Example 41 with Employee

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

the class TeamSynchronizerTest method testImportTeamByProject.

@Test
public void testImportTeamByProject() throws MessagingException {
    Project project = new Project();
    project.setTeamFilter(new TeamFilter(FilterType.PROJECT_CODES, "foreign code"));
    Employee employee = new Employee("employee");
    List<Employee> projectTeam = Arrays.asList(employee);
    expect(projectRepository.fetchComplete(project)).andReturn(project);
    expect(projectService.getSubprojectsByProject(project)).andReturn(new ArrayList<>());
    expect(teamTrackingSystem.getTeam(project)).andReturn(projectTeam);
    expect(projectService.addTeamMembers(project, projectTeam)).andReturn(projectTeam);
    expect(projectRepository.update(project)).andReturn(project);
    expect(mailTemplateManager.getTemplateText(anyString(), anyObject(Map.class))).andReturn("").anyTimes();
    replay(teamTrackingSystem, projectRepository, projectService, mailTemplateManager);
    teamSynchronizer.importTeam(project);
    verify(teamTrackingSystem, projectRepository, projectService, mailTemplateManager);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) TeamFilter(com.artezio.arttime.datamodel.TeamFilter) Test(org.junit.Test)

Example 42 with Employee

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

the class TeamSynchronizerTest method testImportTeam_ShouldNotSendEmptyNotification.

@Test
public void testImportTeam_ShouldNotSendEmptyNotification() throws MessagingException {
    Project project = new Project();
    List<Employee> newMembers = Collections.emptyList();
    List<Employee> newTeamMembers = Collections.emptyList();
    expect(projectRepository.fetchComplete(project)).andReturn(project);
    expect(projectService.getSubprojectsByProject(project)).andReturn(new ArrayList<>());
    expect(teamTrackingSystem.getTeam(project)).andReturn(newMembers);
    expect(projectService.addTeamMembers(project, newMembers)).andReturn(newTeamMembers);
    replay(projectRepository, projectService, teamTrackingSystem, mailingEngine, mailTemplateManager);
    teamSynchronizer.importTeam(project);
    verify(projectRepository, projectService, teamTrackingSystem, mailingEngine, mailTemplateManager);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 43 with Employee

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

the class LdapAdapterTest method testFindEmployeesByFullName.

@Test
public void testFindEmployeesByFullName() {
    Employee employee1 = new Employee("jsmith", "John", "Smith", "j_smith@mail.com");
    Employee employee2 = new Employee("bgray", "Bob", "Gray", "b_gray@mail.com");
    List<Employee> employees = new ArrayList<Employee>(Arrays.asList(employee1, employee2));
    ldapImpl = EasyMock.createMockBuilder(LdapAdapter.class).addMockedMethod("getEmployees").createMock();
    EasyMock.expect(ldapImpl.getEmployees()).andReturn(employees);
    EasyMock.replay(ldapImpl);
    List<Employee> actual = ldapImpl.findEmployeesByFullName("smi");
    assertEquals(1, actual.size());
    assertEquals(employee1, actual.get(0));
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 44 with Employee

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

the class LdapAdapterTest method testFindEmployeesByFullName_SearchNameIsEmpty.

@Test
public void testFindEmployeesByFullName_SearchNameIsEmpty() {
    Employee employee1 = new Employee("jsmith", "John", "Smith", "j_smith@mail.com");
    Employee employee2 = new Employee("bgray", "Bob", "Gray", "b_gray@mail.com");
    List<Employee> expected = new ArrayList<Employee>(Arrays.asList(employee1, employee2));
    ldapImpl = EasyMock.createMockBuilder(LdapAdapter.class).addMockedMethod("getEmployees").createMock();
    EasyMock.expect(ldapImpl.getEmployees()).andReturn(expected);
    EasyMock.replay(ldapImpl);
    List<Employee> actual = ldapImpl.findEmployeesByFullName("");
    assertThat(actual, is(expected));
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 45 with Employee

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

the class LdapAdapterTest method testGetTeam_TwoTeamCodes.

@Test
public void testGetTeam_TwoTeamCodes() throws Exception {
    Logger log = createMock(Logger.class);
    setField(ldapImpl, "log", log);
    Project project = new Project();
    TeamFilter teamFilter = new TeamFilter(FilterType.PROJECT_CODES, "_ART-PRJ-ART-TIME-PG,_ART-PRJ-ART-TIME-PM");
    project.setTeamFilter(teamFilter);
    setField(ldapImpl, "workdaysCalendarRepository", workdaysCalendarRepository);
    expect(workdaysCalendarRepository.findDefaultCalendar(anyObject(Employee.class))).andReturn(null).anyTimes();
    replay(workdaysCalendarRepository);
    List<Employee> team = ldapImpl.getTeam(project);
    verify(workdaysCalendarRepository);
    assertTrue(team.size() > 0);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) TeamFilter(com.artezio.arttime.datamodel.TeamFilter) Logger(java.util.logging.Logger) Test(org.junit.Test)

Aggregations

Employee (com.artezio.arttime.datamodel.Employee)339 Test (org.junit.Test)300 Project (com.artezio.arttime.datamodel.Project)196 HourType (com.artezio.arttime.datamodel.HourType)115 Hours (com.artezio.arttime.datamodel.Hours)101 Date (java.util.Date)67 Period (com.artezio.arttime.datamodel.Period)61 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)52 BigDecimal (java.math.BigDecimal)45 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)27 Filter (com.artezio.arttime.filter.Filter)26 ArrayList (java.util.ArrayList)24 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)22 HashMap (java.util.HashMap)21 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)21 WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)16 Arrays.asList (java.util.Arrays.asList)15 List (java.util.List)15 Map (java.util.Map)15 HoursRepository (com.artezio.arttime.repositories.HoursRepository)13