Search in sources :

Example 16 with Employee

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

the class ProjectBeanTest method testChangeRecordWithArrayValueToListValueInParticipations_allNew_expectAddAll.

@Test
public void testChangeRecordWithArrayValueToListValueInParticipations_allNew_expectAddAll() throws NoSuchFieldException {
    Map<Employee, List<Project>> participations = new HashMap<>();
    Employee employee = new Employee();
    Project newProject = new Project();
    setField(bean, "participations", participations);
    setField(bean, "projects", Arrays.asList(newProject));
    List<Project> expectedParticipations = Arrays.asList(newProject);
    bean.changeRecordWithArrayValueToListValueInParticipations(employee, expectedParticipations);
    assertTrue(bean.getParticipations().containsKey(employee));
    List<Project> actualParticipations = bean.getParticipations().get(employee);
    assertTrue(actualParticipations.contains(newProject));
    assertTrue(newProject.isTeamMember(employee));
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 17 with Employee

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

the class ProjectBeanTest method testChangeRecordWithArrayValueToListValueInParticipations_someNew_someRemoved_expectAddAndRemove.

@Test
public void testChangeRecordWithArrayValueToListValueInParticipations_someNew_someRemoved_expectAddAndRemove() throws NoSuchFieldException {
    Map<Employee, Project[]> participations = new HashMap<>();
    Employee employee = new Employee("empl");
    Project newProject = new Project();
    setField(newProject, "id", 22L);
    Project oldProject = new Project();
    oldProject.addTeamMember(employee);
    setField(oldProject, "id", 33L);
    Project oldProject2 = new Project();
    oldProject2.addTeamMember(employee);
    setField(oldProject2, "id", 44L);
    participations.put(employee, new Project[] { newProject, oldProject2 });
    setField(bean, "participations", participations);
    setField(bean, "projects", Arrays.asList(newProject, oldProject, oldProject2));
    List<Project> newParticipations = Arrays.asList(newProject, oldProject2);
    bean.changeRecordWithArrayValueToListValueInParticipations(employee, newParticipations);
    assertTrue(bean.getParticipations().containsKey(employee));
    List<Project> actualParticipations = bean.getParticipations().get(employee);
    assertTrue(actualParticipations.contains(newProject));
    assertTrue(actualParticipations.contains(oldProject2));
    assertFalse(actualParticipations.contains(oldProject));
    assertTrue(newProject.isTeamMember(employee));
    assertTrue(oldProject2.isTeamMember(employee));
    assertFalse(oldProject.isTeamMember(employee));
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 18 with Employee

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

the class ProjectsBeanTest method testGetProjects_ifProjectsNull_andUserInRolePM.

@Test
public void testGetProjects_ifProjectsNull_andUserInRolePM() throws NoSuchFieldException {
    List<Project> expected = new ArrayList<Project>();
    Employee loggedEmployee = new Employee();
    setField(projectBean, "projects", null);
    setField(projectBean, "loggedEmployee", loggedEmployee);
    setField(projectBean, "externalContext", externalContext);
    setField(projectBean, "projectRepository", projectRepository);
    expect(externalContext.isUserInRole("exec")).andReturn(false);
    expect(projectRepository.getManagedProjects(loggedEmployee)).andReturn(expected);
    replay(externalContext, projectRepository);
    List<Project> actual = projectBean.getProjects();
    verify(externalContext, projectRepository);
    assertSame(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 19 with Employee

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

the class TimeProblemsNotificationBeanTest method testGetProblematicEmployees_ifNotNull.

@Test
public void testGetProblematicEmployees_ifNotNull() throws Exception {
    Employee employee1 = new Employee("employee1");
    Employee employee2 = new Employee("employee2");
    List<WorkTimeService.Efforts> employeesProblemTime = new ArrayList<>();
    employeesProblemTime.add(new WorkTimeService.Efforts(employee1));
    employeesProblemTime.add(new WorkTimeService.Efforts(employee2));
    bean.setEmployeesProblemTime(employeesProblemTime);
    List<WorkTimeService.Efforts> actual = bean.getProblematicEmployees();
    assertSame(employeesProblemTime, actual);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) WorkTimeService(com.artezio.arttime.services.WorkTimeService) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 20 with Employee

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

the class ProjectEffortsSpreadSheetTest method createSubprojects.

private Map<Project, List<Project>> createSubprojects() throws NoSuchFieldException {
    HourType hourType = filter.getHourTypes().get(0);
    Employee employee = filter.getEmployees().get(0);
    Project master = filter.getProjects().get(0);
    Project subproject = createProject("subproject", asList(hourType), asList(employee));
    setField(subproject, "id", 3L);
    setField(subproject, "master", master);
    Map<Project, List<Project>> result = filter.getProjects().stream().collect(Collectors.toMap(p -> p, p -> new ArrayList<Project>()));
    result.get(master).add(subproject);
    return result;
}
Also used : java.util(java.util) Filter(com.artezio.arttime.filter.Filter) Period(com.artezio.arttime.datamodel.Period) Mock(org.easymock.Mock) RunWith(org.junit.runner.RunWith) PrivateAccessor.setField(junitx.util.PrivateAccessor.setField) SimpleDateFormat(java.text.SimpleDateFormat) Employee(com.artezio.arttime.datamodel.Employee) BigDecimal(java.math.BigDecimal) Arrays.asList(java.util.Arrays.asList) EasyMockRunner(org.easymock.EasyMockRunner) ParseException(java.text.ParseException) ProjectService(com.artezio.arttime.services.ProjectService) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) Collections.emptyList(java.util.Collections.emptyList) HourTypeRepository(com.artezio.arttime.services.repositories.HourTypeRepository) ProjectRepository(com.artezio.arttime.services.repositories.ProjectRepository) TestSubject(org.easymock.TestSubject) Test(org.junit.Test) EasyMock(org.easymock.EasyMock) Collectors(java.util.stream.Collectors) ListAssert(junitx.framework.ListAssert) HourType(com.artezio.arttime.datamodel.HourType) Project(com.artezio.arttime.datamodel.Project) EmployeeRepository(com.artezio.arttime.services.repositories.EmployeeRepository) WorkTimeService(com.artezio.arttime.services.WorkTimeService) HoursRepository(com.artezio.arttime.services.repositories.HoursRepository) RangePeriodSelector(com.artezio.arttime.web.criteria.RangePeriodSelector) Assert(org.junit.Assert) Hours(com.artezio.arttime.datamodel.Hours) Project(com.artezio.arttime.datamodel.Project) HourType(com.artezio.arttime.datamodel.HourType) Employee(com.artezio.arttime.datamodel.Employee) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList)

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