use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class UniqueConstraintValidatorTest method testIsValid.
@Test
public void testIsValid() throws Exception {
Project project1 = new Project();
project1.setCode("project1");
entityManager.persist(project1);
entityManager.flush();
entityManager.clear();
setField(uniqueConstraintValidator, "entityManager", entityManager);
setField(uniqueConstraintValidator, "uniqueFields", new String[] { "code", "master" });
Project project2 = new Project();
project1.setCode("project2");
boolean actual = uniqueConstraintValidator.isValid(project2, null);
assertTrue(actual);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class UniqueConstraintValidatorTest method testIsValid_notValidAfterChangeCode.
@Test
public void testIsValid_notValidAfterChangeCode() throws Exception {
Project project1 = new Project();
project1.setCode("project");
Project project2 = new Project();
project2.setCode("project2");
entityManager.persist(project1);
entityManager.persist(project2);
entityManager.flush();
entityManager.clear();
setField(uniqueConstraintValidator, "entityManager", entityManager);
setField(uniqueConstraintValidator, "uniqueFields", new String[] { "code", "master" });
project2.setCode("project");
boolean actual = uniqueConstraintValidator.isValid(project2, null);
assertFalse(actual);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class FilterBeanTest method testSetSelectedProjects_FilterHasFilledProjectList_EmployeeIsPM.
@Test
public void testSetSelectedProjects_FilterHasFilledProjectList_EmployeeIsPM() throws NoSuchFieldException {
Project project1 = createProject(1L, null, "project1");
Project project11 = createProject(2L, project1, "project11");
Project project12 = createProject(3L, project1, "project12");
Project project2 = createProject(5L, null, "project2");
List<Project> projects = Arrays.asList(project11, project12, project2);
Filter filter = new Filter();
setField(filterBean, "currentFilter", filter);
expect(externalContext.isUserInRole("exec")).andReturn(false);
expect(projectService.getSubprojectsByProjects(projects)).andReturn(projects);
replay(externalContext, projectService);
filterBean.setSelectedProjects(projects);
verify(externalContext, projectService);
assertSame(projects, filter.getProjects());
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class FilterBeanTest method testGetCurrentFilter_CurrentFilterIsNull.
@Test
public final void testGetCurrentFilter_CurrentFilterIsNull() throws NoSuchFieldException {
setField(filterBean, "currentFilter", null);
Filter expected = new Filter();
List<Project> projects = Collections.emptyList();
expected.setProjects(projects);
expect(filterService.getActiveProjectsFilter(loggedEmployee)).andReturn(expected);
expect(filterRepository.fetchDetails(expected)).andReturn(expected);
expect(projectService.getSubprojectsByProjects(projects)).andReturn(projects).anyTimes();
replay(filterService, filterRepository, externalContext, projectService);
Filter actual = filterBean.getCurrentFilter();
verify(filterService, filterRepository, externalContext, projectService);
assertSame(expected, actual);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class FilterBeanTest method testGetAvailableProjects.
@Test
public final void testGetAvailableProjects() throws NoSuchFieldException {
Project project1 = createProject(1L, null, "project1");
project1.setStatus(FROZEN);
Project project11 = createProject(2L, project1, "project11");
Project project12 = createProject(3L, project1, "project12");
Project project111 = createProject(4L, project11, "project111");
Project project2 = createProject(5L, null, "project2");
Project project21 = createProject(6L, project2, "project21");
Project project3 = createProject(7L, null, "project3");
List<Project> projects = Arrays.asList(project1, project11, project12, project111, project2, project21, project3);
List<Project> onlyActiveProjects = projects.subList(1, projects.size() - 1);
List<Project> expected = Arrays.asList(project1, project2, project3);
expect(projectService.getAvailableProjects(anyObject())).andReturn(projects);
expect(projectService.getActiveOnly(projects)).andReturn(onlyActiveProjects);
expect(projectService.getHighlevelOnly(onlyActiveProjects)).andReturn(expected);
replay(projectService);
List<Project> actual = filterBean.getAvailableProjects();
verify(projectService);
ListAssert.assertEquals(expected, actual);
}
Aggregations