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);
}
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);
}
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);
}
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);
}
Aggregations