Search in sources :

Example 46 with Project

use of com.artezio.arttime.datamodel.Project 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 47 with Project

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

the class TeamSynchronizerTest method createProject.

private Project createProject(Long id, Project master, FilterType filterType) throws NoSuchFieldException {
    Project project = new Project(master);
    setField(project, "id", id);
    TeamFilter teamFilter = new TeamFilter(filterType);
    project.setTeamFilter(teamFilter);
    return project;
}
Also used : Project(com.artezio.arttime.datamodel.Project) TeamFilter(com.artezio.arttime.datamodel.TeamFilter)

Example 48 with Project

use of com.artezio.arttime.datamodel.Project 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 49 with Project

use of com.artezio.arttime.datamodel.Project 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 50 with Project

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

the class LdapAdapterTest method testGetTeam.

@Test
public void testGetTeam() 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");
    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

Project (com.artezio.arttime.datamodel.Project)310 Test (org.junit.Test)278 Employee (com.artezio.arttime.datamodel.Employee)195 HourType (com.artezio.arttime.datamodel.HourType)119 Hours (com.artezio.arttime.datamodel.Hours)108 Date (java.util.Date)61 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)56 Period (com.artezio.arttime.datamodel.Period)43 BigDecimal (java.math.BigDecimal)39 Filter (com.artezio.arttime.filter.Filter)33 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)21 ArrayList (java.util.ArrayList)18 Arrays.asList (java.util.Arrays.asList)18 ProjectRepository (com.artezio.arttime.repositories.ProjectRepository)17 List (java.util.List)17 HoursRepository (com.artezio.arttime.repositories.HoursRepository)13 HashMap (java.util.HashMap)13 Map (java.util.Map)11