Search in sources :

Example 16 with ProjectRepository

use of com.artezio.arttime.repositories.ProjectRepository in project ART-TIME by Artezio.

the class ProjectServiceTest method testGetById_noResult.

@Test(expected = NoResultException.class)
public void testGetById_noResult() {
    Long id = 5L;
    ProjectRepository.ProjectQuery projectQuery = Mockito.mock(ProjectRepository.ProjectQuery.class, Mockito.RETURNS_DEEP_STUBS);
    EasyMock.expect(projectRepository.query()).andReturn(projectQuery);
    Mockito.when(projectQuery.id(id).fetchManagers().fetchTeam().fetchAccountableHours().getSingleResult()).thenThrow(new NoResultException());
    replay(projectRepository);
    projectService.loadProject(5L);
}
Also used : ProjectRepository(com.artezio.arttime.repositories.ProjectRepository) NoResultException(javax.persistence.NoResultException) Test(org.junit.Test)

Example 17 with ProjectRepository

use of com.artezio.arttime.repositories.ProjectRepository in project ART-TIME by Artezio.

the class ProjectServiceTest method testGetById.

@Test
public void testGetById() {
    Long id = 5L;
    ProjectRepository.ProjectQuery projectQuery = Mockito.mock(ProjectRepository.ProjectQuery.class, Mockito.RETURNS_DEEP_STUBS);
    Project project = createProject(id, null);
    EasyMock.expect(projectRepository.query()).andReturn(projectQuery);
    Mockito.when(projectQuery.id(id).fetchManagers().fetchTeam().fetchAccountableHours().getSingleResult()).thenReturn(project);
    replay(projectRepository);
    Project actual = projectService.loadProject(5L);
    assertEquals(actual, project);
}
Also used : Project(com.artezio.arttime.datamodel.Project) ProjectRepository(com.artezio.arttime.repositories.ProjectRepository) Test(org.junit.Test)

Example 18 with ProjectRepository

use of com.artezio.arttime.repositories.ProjectRepository in project ART-TIME by Artezio.

the class ProjectServiceTest method testGetManagedProjectHierarchy_ProjectHasSubprojects_SubprojectsAreActive.

@Test
public void testGetManagedProjectHierarchy_ProjectHasSubprojects_SubprojectsAreActive() {
    Project master = createProject(1L, null);
    Project subproject01 = createProject(2L, master);
    Project subproject02 = createProject(3L, master);
    Project subproject11 = createProject(4L, subproject01);
    List<Project> expected = asList(master, subproject01, subproject11, subproject02);
    ProjectRepository.ProjectQuery projectQuery = Mockito.mock(ProjectRepository.ProjectQuery.class, Mockito.RETURNS_DEEP_STUBS);
    EasyMock.expect(projectRepository.query()).andReturn(projectQuery).times(3);
    Mockito.when(projectQuery.masters(asList(master)).distinct().list()).thenReturn(asList(subproject01, subproject02));
    Mockito.when(projectQuery.masters(asList(subproject01, subproject02)).distinct().list()).thenReturn(asList(subproject11));
    Mockito.when(projectQuery.masters(asList(subproject11)).distinct().list()).thenReturn(emptyList());
    replay(projectRepository);
    List<Project> actual = projectService.getManagedProjectHierarchy(master);
    EasyMock.verify(projectRepository);
    ListAssert.assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) ProjectRepository(com.artezio.arttime.repositories.ProjectRepository) Test(org.junit.Test)

Example 19 with ProjectRepository

use of com.artezio.arttime.repositories.ProjectRepository in project ART-TIME by Artezio.

the class ProjectServiceTest method testGetProjects.

@Test
public void testGetProjects() {
    List<Long> ids = Arrays.asList(1L, 2L);
    List<Project> expected = Arrays.asList(new Project());
    ProjectRepository.ProjectQuery projectQuery = Mockito.mock(ProjectRepository.ProjectQuery.class, Mockito.RETURNS_DEEP_STUBS);
    EasyMock.expect(projectRepository.query()).andReturn(projectQuery);
    Mockito.when(projectQuery.projectIds(ids).list()).thenReturn(expected);
    EasyMock.replay(projectRepository);
    List<Project> actual = projectService.getProjects(ids);
    EasyMock.verify(projectRepository);
    ListAssert.assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) ProjectRepository(com.artezio.arttime.repositories.ProjectRepository) Test(org.junit.Test)

Aggregations

ProjectRepository (com.artezio.arttime.repositories.ProjectRepository)19 Test (org.junit.Test)19 Project (com.artezio.arttime.datamodel.Project)15 Employee (com.artezio.arttime.datamodel.Employee)8 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)6 Date (java.util.Date)4 Filter (com.artezio.arttime.filter.Filter)3 EmployeeRepository (com.artezio.arttime.repositories.EmployeeRepository)3 WorkTime (com.artezio.arttime.services.WorkTimeService.WorkTime)3 Arrays.asList (java.util.Arrays.asList)3 Collections.emptyList (java.util.Collections.emptyList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Tuple (javax.persistence.Tuple)3 BigDecimal (java.math.BigDecimal)2 HourType (com.artezio.arttime.datamodel.HourType)1 Hours (com.artezio.arttime.datamodel.Hours)1 HoursRepository (com.artezio.arttime.repositories.HoursRepository)1 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)1