Search in sources :

Example 66 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 67 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 68 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 69 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)

Example 70 with Employee

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

the class LdapAdapterTest method testFindEmployee_SearchMustBeCaseInsensitive.

@Test
public void testFindEmployee_SearchMustBeCaseInsensitive() throws NoSuchFieldException {
    setField(ldapImpl, "workdaysCalendarRepository", workdaysCalendarRepository);
    expect(workdaysCalendarRepository.findDefaultCalendar(anyObject(Employee.class))).andReturn(null).anyTimes();
    replay(workdaysCalendarRepository);
    Employee employee = ldapImpl.findEmployee("Sdegtyarev");
    verify(workdaysCalendarRepository);
    assertNotNull(employee);
    assertEquals("sdegtyarev", employee.getUserName());
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) 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