Search in sources :

Example 91 with Project

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

the class HoursRepositoryTest method testGetActualTimeByEmployeeAndApproval_ifNotActualTime.

@Test
public void testGetActualTimeByEmployeeAndApproval_ifNotActualTime() {
    Date start = new Date();
    Date finish = getOffsetDate(3);
    Period period = new Period(start, finish);
    Project project = new Project();
    Employee employee = new Employee("employee");
    HourType actualType = new HourType("actual type");
    actualType.setActualTime(true);
    HourType notActualType = new HourType("not actual type");
    Hours hours1 = createHours(project, employee, getOffsetDate(2), notActualType, new BigDecimal(7));
    Hours hours2 = createHours(project, employee, getOffsetDate(2), actualType, new BigDecimal(8));
    entityManager.persist(employee);
    entityManager.persist(project);
    entityManager.persist(actualType);
    entityManager.persist(notActualType);
    entityManager.persist(hours1);
    entityManager.persist(hours2);
    Map<Employee, Map<Boolean, BigDecimal>> actual = hoursRepository.getActualTimeByEmployeeAndApproval(Arrays.asList(employee), period);
    assertEquals(8.0, actual.get(employee).get(false).doubleValue(), 0.0);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Period(com.artezio.arttime.datamodel.Period) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 92 with Project

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

the class HoursRepositoryTest method testGetManagersForApproveByEmployee_byEmployee.

@Test
public void testGetManagersForApproveByEmployee_byEmployee() {
    Date start = new Date();
    Date finish = getOffsetDate(3);
    Period period = new Period(start, finish);
    Employee manager1 = new Employee("manager1");
    Employee manager2 = new Employee("manager2");
    Project project1 = new Project();
    project1.setManagers(Arrays.asList(manager1));
    Project project2 = new Project();
    project2.setManagers(Arrays.asList(manager2));
    Employee employee1 = new Employee("employee1");
    Employee employee2 = new Employee("employee2");
    HourType actualType = new HourType("actual type");
    actualType.setActualTime(true);
    Hours hours1 = createHours(project1, employee1, getOffsetDate(2), actualType, new BigDecimal(8));
    Hours hours2 = createHours(project2, employee2, getOffsetDate(2), actualType, new BigDecimal(8));
    entityManager.persist(manager1);
    entityManager.persist(manager2);
    entityManager.persist(actualType);
    entityManager.persist(employee1);
    entityManager.persist(employee2);
    entityManager.persist(project1);
    entityManager.persist(project2);
    entityManager.persist(hours1);
    entityManager.persist(hours2);
    Map<Employee, List<Employee>> actual = hoursRepository.getManagersForApproveByEmployee(Arrays.asList(employee1), period);
    ListAssert.assertEquals(Arrays.asList(manager1), actual.get(employee1));
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Period(com.artezio.arttime.datamodel.Period) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 93 with Project

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

the class ProjectRepositoryIntegrationTest method testCreateProjectWithSubprojects.

@Test
@Ignore
public // TODO correct
void testCreateProjectWithSubprojects() {
    Project project = createTestProject("Test", false, null);
    Project subProject1 = createTestProject("TestSubPrj1", false, null);
    Project subProject2 = createTestProject("TestSubPrj2", false, null);
    List<Project> expected = Arrays.asList(subProject1, subProject2);
    Long projectId = projectRepository.create(project).getId();
// List<Project> actual = projectRepository.findProject(projectId);
// actual.forEach(subproject -> assertEquals(project, subproject.getMaster()));
}
Also used : Project(com.artezio.arttime.datamodel.Project) Ignore(org.junit.Ignore) Test(org.junit.Test) IntegrationTest(com.artezio.arttime.markers.IntegrationTest)

Example 94 with Project

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

the class ProjectRepositoryIntegrationTest method createTestProject.

private Project createTestProject(String code, boolean isSubproject, Project master) {
    Project project = new Project();
    project.setCode(code);
    project.setStatus(ACTIVE);
    project.setAccountableHours(Arrays.asList(testHourType));
    project.setManagers(Arrays.asList(testEmployee));
    project.setAllowEmployeeReportTime(true);
    TeamFilter teamFilter;
    if (isSubproject) {
        project.setMaster(master);
        teamFilter = new TeamFilter(TeamFilter.Type.BASED_ON_MASTER);
    } else {
        teamFilter = new TeamFilter(TeamFilter.Type.DISABLED);
    }
    project.setTeamFilter(teamFilter);
    return project;
}
Also used : Project(com.artezio.arttime.datamodel.Project) TeamFilter(com.artezio.arttime.datamodel.TeamFilter)

Example 95 with Project

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

the class FilterServiceTest method testGetActiveProjectsFilter.

@Test
public void testGetActiveProjectsFilter() {
    String loggedUserName = "username";
    Project activeProject = new Project();
    activeProject.setStatus(Project.Status.ACTIVE);
    Project closedProject = new Project();
    closedProject.setStatus(Project.Status.CLOSED);
    List<Project> projects = asList(activeProject, closedProject);
    ProjectRepository.ProjectQuery projectQuery = Mockito.mock(ProjectRepository.ProjectQuery.class, RETURNS_DEEP_STUBS);
    EasyMock.expect(principal.getName()).andReturn(loggedUserName).anyTimes();
    EasyMock.expect(projectRepository.query()).andReturn(projectQuery);
    Mockito.when(projectQuery.managedBy(loggedUserName).status(ACTIVE).list()).thenReturn(projects);
    EasyMock.replay(projectRepository, principal);
    Filter expected = new Filter(MY_ACTIVE_PROJECTS_FILTER_NAME, loggedUserName, true, projects);
    Filter actual = filterService.getActiveProjectsFilter();
    EasyMock.verify(projectRepository, principal);
    Mockito.verify(projectQuery.managedBy(loggedUserName).status(ACTIVE)).list();
    assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Filter(com.artezio.arttime.filter.Filter) 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