use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class FilterBeanTest method testSetSelectedProjects_FilterHasEmptyProjectList.
@Test
public void testSetSelectedProjects_FilterHasEmptyProjectList() throws NoSuchFieldException {
List<Project> emptyProjectList = Collections.emptyList();
Filter filter = new Filter();
setField(filterBean, "currentFilter", filter);
expect(projectService.getSubprojectsByProjects(emptyProjectList)).andReturn(Collections.emptyList()).anyTimes();
replay(externalContext, projectService);
filterBean.setSelectedProjects(emptyProjectList);
verify(externalContext, projectService);
ListAssert.assertEquals(emptyProjectList, filter.getProjects());
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class ProjectBeanTest method testChangeRecordWithArrayValueToListValueInParticipations_allRemoved_expectClear.
@Test
public void testChangeRecordWithArrayValueToListValueInParticipations_allRemoved_expectClear() throws NoSuchFieldException {
Map<Employee, Project[]> participations = new HashMap<>();
Employee employee = new Employee("empl");
Project oldProject = new Project();
setField(oldProject, "id", 33L);
oldProject.addTeamMember(employee);
Project oldProject2 = new Project();
oldProject2.addTeamMember(employee);
setField(oldProject2, "id", 44L);
participations.put(employee, new Project[] {});
setField(bean, "participations", participations);
setField(bean, "projects", Arrays.asList(oldProject, oldProject2));
List<Project> newParticipations = Collections.emptyList();
bean.changeRecordWithArrayValueToListValueInParticipations(employee, newParticipations);
assertTrue(bean.getParticipations().containsKey(employee));
List<Project> actualParticipations = bean.getParticipations().get(employee);
assertFalse(actualParticipations.contains(oldProject2));
assertFalse(actualParticipations.contains(oldProject));
assertFalse(oldProject.isTeamMember(employee));
assertFalse(oldProject2.isTeamMember(employee));
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class ProjectBeanTest method testChangeRecordWithArrayValueToListValueInParticipations_allNew_expectAddAll.
@Test
public void testChangeRecordWithArrayValueToListValueInParticipations_allNew_expectAddAll() throws NoSuchFieldException {
Map<Employee, List<Project>> participations = new HashMap<>();
Employee employee = new Employee();
Project newProject = new Project();
setField(bean, "participations", participations);
setField(bean, "projects", Arrays.asList(newProject));
List<Project> expectedParticipations = Arrays.asList(newProject);
bean.changeRecordWithArrayValueToListValueInParticipations(employee, expectedParticipations);
assertTrue(bean.getParticipations().containsKey(employee));
List<Project> actualParticipations = bean.getParticipations().get(employee);
assertTrue(actualParticipations.contains(newProject));
assertTrue(newProject.isTeamMember(employee));
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class ProjectBeanTest method testChangeRecordWithArrayValueToListValueInParticipations_someNew_someRemoved_expectAddAndRemove.
@Test
public void testChangeRecordWithArrayValueToListValueInParticipations_someNew_someRemoved_expectAddAndRemove() throws NoSuchFieldException {
Map<Employee, Project[]> participations = new HashMap<>();
Employee employee = new Employee("empl");
Project newProject = new Project();
setField(newProject, "id", 22L);
Project oldProject = new Project();
oldProject.addTeamMember(employee);
setField(oldProject, "id", 33L);
Project oldProject2 = new Project();
oldProject2.addTeamMember(employee);
setField(oldProject2, "id", 44L);
participations.put(employee, new Project[] { newProject, oldProject2 });
setField(bean, "participations", participations);
setField(bean, "projects", Arrays.asList(newProject, oldProject, oldProject2));
List<Project> newParticipations = Arrays.asList(newProject, oldProject2);
bean.changeRecordWithArrayValueToListValueInParticipations(employee, newParticipations);
assertTrue(bean.getParticipations().containsKey(employee));
List<Project> actualParticipations = bean.getParticipations().get(employee);
assertTrue(actualParticipations.contains(newProject));
assertTrue(actualParticipations.contains(oldProject2));
assertFalse(actualParticipations.contains(oldProject));
assertTrue(newProject.isTeamMember(employee));
assertTrue(oldProject2.isTeamMember(employee));
assertFalse(oldProject.isTeamMember(employee));
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class ProjectsBeanTest method testGetProjects_ifProjectsNull_andUserInRolePM.
@Test
public void testGetProjects_ifProjectsNull_andUserInRolePM() throws NoSuchFieldException {
List<Project> expected = new ArrayList<Project>();
Employee loggedEmployee = new Employee();
setField(projectBean, "projects", null);
setField(projectBean, "loggedEmployee", loggedEmployee);
setField(projectBean, "externalContext", externalContext);
setField(projectBean, "projectRepository", projectRepository);
expect(externalContext.isUserInRole("exec")).andReturn(false);
expect(projectRepository.getManagedProjects(loggedEmployee)).andReturn(expected);
replay(externalContext, projectRepository);
List<Project> actual = projectBean.getProjects();
verify(externalContext, projectRepository);
assertSame(expected, actual);
}
Aggregations