Search in sources :

Example 76 with Employee

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

the class EmployeeRepositoryTest method testGetEmployeesByDepartments_ifEmployeesDepartmentsAreEmpty.

@Test
public void testGetEmployeesByDepartments_ifEmployeesDepartmentsAreEmpty() {
    Employee employee1 = new Employee("employee1");
    employee1.setDepartment("department1");
    Employee employee2 = new Employee("employee2");
    employee2.setDepartment("department2");
    Employee employee3 = new Employee("employee3");
    employee3.setDepartment("department3");
    Project project1 = new Project();
    project1.addTeamMember(employee1);
    project1.addTeamMember(employee2);
    Project project2 = new Project();
    project2.addTeamMember(employee1);
    project2.addTeamMember(employee3);
    Filter filter = new Filter();
    filter.setEmployees(Collections.emptyList());
    filter.setDepartments(Collections.emptyList());
    entityManager.persist(project1);
    entityManager.persist(project2);
    entityManager.persist(employee1);
    entityManager.persist(employee2);
    entityManager.persist(employee3);
    entityManager.flush();
    List<Employee> expected = Arrays.asList(employee1, employee2, employee3);
    List<Employee> actual = employeeRepository.getEmployeesByDepartments(filter);
    ListAssert.assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 77 with Employee

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

the class EmployeeRepositoryTest method testGetAll.

@Test
public void testGetAll() {
    Employee employee1 = new Employee("employee1");
    Employee employee2 = new Employee("employee2");
    entityManager.persist(employee1);
    entityManager.persist(employee2);
    List<Employee> expected = Arrays.asList(employee1, employee2);
    List<Employee> actual = employeeRepository.getAll();
    ListAssert.assertEquals(expected, actual);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 78 with Employee

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

the class EmployeeRepositoryTest method testGetEmployeesByDepartments_ifEmployeesAreEmpty_FilterHasNotAllDepartments.

@Test
public void testGetEmployeesByDepartments_ifEmployeesAreEmpty_FilterHasNotAllDepartments() {
    Employee employee1 = new Employee("employee1");
    employee1.setDepartment("dep1");
    Employee employee2 = new Employee("employee2");
    employee2.setDepartment("dep2");
    Employee employee3 = new Employee("employee3");
    employee3.setDepartment("dep3");
    Filter filter = new Filter();
    filter.setEmployees(Arrays.asList(employee1, employee2));
    filter.setDepartments(Arrays.asList("dep1", "dep2"));
    entityManager.persist(employee1);
    entityManager.persist(employee2);
    entityManager.persist(employee3);
    List<Employee> expected = filter.getEmployees();
    List<Employee> actual = employeeRepository.getEmployeesByDepartments(filter);
    ListAssert.assertEquals(expected, actual);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 79 with Employee

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

the class EmployeeRepositoryTest method testFind_ByUsername_EmployeeNotExist.

@Test
public void testFind_ByUsername_EmployeeNotExist() {
    Employee unexpectedEmployee = new Employee("unexpected employee");
    entityManager.persist(unexpectedEmployee);
    Employee actual = employeeRepository.find("expected employee");
    assertNull(actual);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 80 with Employee

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

the class EmployeeRepositoryTest method testPersisted.

@Test
public void testPersisted() {
    Employee employee1 = new Employee("employee1");
    Employee employee2 = new Employee("employee2");
    entityManager.persist(employee1);
    assertTrue(employeeRepository.persisted(employee1));
    assertFalse(employeeRepository.persisted(employee2));
}
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