Search in sources :

Example 11 with Employee

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

the class ProjectEffortsSpreadSheetTest method testHasTeam_EmployeeNotInFilter.

@Test
public void testHasTeam_EmployeeNotInFilter() throws NoSuchFieldException {
    Employee employee = new Employee("employee");
    spreadSheet.getFilter().setEmployees(emptyList());
    Project master = createProject("master", emptyList(), asList(employee));
    Project subproject = createProject("subproject", emptyList(), asList(employee));
    setField(subproject, "master", master);
    assertFalse(spreadSheet.hasTeam(master, asList(subproject)));
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 12 with Employee

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

the class LoginBeanTest method testGetLoggedEmployee_ifNull_AndExternalContextIsNull.

@Test
public void testGetLoggedEmployee_ifNull_AndExternalContextIsNull() throws Exception {
    setField(loginBean, "loggedEmployee", null);
    setField(loginBean, "externalContext", null);
    Employee actual = loginBean.getLoggedEmployee();
    assertNull(actual);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with Employee

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

the class LoginBeanTest method testGetLoggedEmployee_ifNull.

@Test
public void testGetLoggedEmployee_ifNull() throws Exception {
    setField(loginBean, "loggedEmployee", null);
    setField(loginBean, "externalContext", externalContext);
    setField(loginBean, "employeeRepository", employeeRepository);
    Employee employee = new Employee();
    Principal principal = createMock(Principal.class);
    expect(externalContext.getUserPrincipal()).andReturn(principal);
    expect(principal.getName()).andReturn("iivanov");
    expect(employeeRepository.find("iivanov")).andReturn(employee);
    replay(externalContext, employeeRepository, principal);
    Employee actual = loginBean.getLoggedEmployee();
    verify(externalContext, employeeRepository, principal);
    assertNotNull(actual);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Principal(java.security.Principal) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 14 with Employee

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

the class LoginBeanTest method testGetLoggedEmployee_ifNullAndNotFoundInRepository.

@Test
public void testGetLoggedEmployee_ifNullAndNotFoundInRepository() throws Exception {
    setField(loginBean, "loggedEmployee", null);
    setField(loginBean, "externalContext", externalContext);
    setField(loginBean, "employeeRepository", employeeRepository);
    Principal principal = createMock(Principal.class);
    expect(externalContext.getUserPrincipal()).andReturn(principal);
    expect(principal.getName()).andReturn("iivanov");
    expect(employeeRepository.find("iivanov")).andReturn(null);
    replay(externalContext, employeeRepository, principal);
    Employee actual = loginBean.getLoggedEmployee();
    verify(externalContext, employeeRepository, principal);
    assertNotNull(actual);
    assertEquals("iivanov", actual.getUserName());
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Principal(java.security.Principal) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 15 with Employee

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

the class ProjectBeanTest method testChangeRecordWithArrayValueToListValueInParticipations_allRemoved_expectClear.

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