use of com.artezio.arttime.services.repositories.ProjectRepository in project ART-TIME by Artezio.
the class FilterRepositoryTest method testFetchDetails_ifFilterNoPersisted.
@Test
public void testFetchDetails_ifFilterNoPersisted() throws NoSuchMethodException, SecurityException, NoSuchFieldException {
Filter filter = new Filter();
Project project = new Project();
List<Project> projects = Arrays.asList(project);
filter.setProjects(projects);
Project projectLoaded = new Project();
List<Project> projectsLoaded = Arrays.asList(projectLoaded);
entityManager.persist(project);
entityManager.persist(projectLoaded);
Method fetchCompleteMethod = ProjectRepository.class.getMethod("fetchComplete", List.class);
projectRepository = EasyMock.createMockBuilder(ProjectRepository.class).addMockedMethod(fetchCompleteMethod).createMock();
setField(filterRepository, "projectRepository", projectRepository);
EasyMock.expect(projectRepository.fetchComplete(projects)).andReturn(projectsLoaded);
EasyMock.replay(projectRepository);
filterRepository.fetchDetails(filter);
EasyMock.verify(projectRepository);
assertSame(projectLoaded, filter.getProjects().get(0));
}
use of com.artezio.arttime.services.repositories.ProjectRepository in project ART-TIME by Artezio.
the class FilterRepositoryTest method setUp.
@Before
public void setUp() throws Exception {
filterRepository = new FilterRepository();
projectRepository = EasyMock.createMock(ProjectRepository.class);
setField(filterRepository, "projectRepository", projectRepository);
Map<String, String> properties = new HashMap<String, String>();
properties.put("javax.persistence.validation.mode", "none");
entityManagerFactory = Persistence.createEntityManagerFactory("test", properties);
entityManager = entityManagerFactory.createEntityManager();
setField(filterRepository, "entityManager", entityManager);
entityManager.getTransaction().begin();
}
use of com.artezio.arttime.services.repositories.ProjectRepository in project ART-TIME by Artezio.
the class ActiveDirectoryRealmTest method testGetProjectRepository_ifNotNull.
@Test
public void testGetProjectRepository_ifNotNull() throws NoSuchFieldException {
setField(activeDirectoryRealm, "projectRepository", projectRepository);
ProjectRepository actual = activeDirectoryRealm.getProjectRepository();
assertSame(projectRepository, actual);
}
use of com.artezio.arttime.services.repositories.ProjectRepository in project ART-TIME by Artezio.
the class ActiveDirectoryRealmTest method testGetProjectRepository_ifNull.
@Test
public void testGetProjectRepository_ifNull() throws NoSuchFieldException {
setField(activeDirectoryRealm, "projectRepository", null);
PowerMock.mockStatic(CDIUtils.class);
expect(CDIUtils.getBean(ProjectRepository.class)).andReturn(projectRepository);
PowerMock.replayAll();
ProjectRepository actual = activeDirectoryRealm.getProjectRepository();
PowerMock.verifyAll();
assertSame(projectRepository, actual);
}
use of com.artezio.arttime.services.repositories.ProjectRepository in project ART-TIME by Artezio.
the class ProjectServiceTest method testGetAvailableProjects_userIsEmployee_hasNoProjects_expectMemberProjects.
@Test
public void testGetAvailableProjects_userIsEmployee_hasNoProjects_expectMemberProjects() throws NoSuchFieldException {
Employee currentEmployee = new Employee("curr", "fn", "ln", "mail");
Subject subject = createMock(Subject.class);
PowerMock.mockStatic(SecurityUtils.class);
projectRepository = createMock(ProjectRepository.class);
setField(projectService, "projectRepository", projectRepository);
expect(SecurityUtils.getSubject()).andReturn(subject);
expect(subject.hasRole(UserRoles.EXEC_ROLE)).andReturn(false);
expect(subject.hasRole(UserRoles.PM_ROLE)).andReturn(false);
expect(projectRepository.getActiveProjects(currentEmployee)).andReturn(Collections.emptyList());
List<Project> expected = Arrays.asList();
PowerMock.replayAll(projectRepository, subject, SecurityUtils.class);
List<Project> actual = projectService.getAvailableProjects(currentEmployee);
PowerMock.verifyAll();
ListAssert.assertEquals(expected, actual);
}
Aggregations