use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class ProjectRepositoryTest method testCreateProject.
@Test
public void testCreateProject() throws NoSuchFieldException {
HourType hourType = new HourType("type");
WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
entityManager.persist(hourType);
entityManager.persist(calendar);
entityManager.flush();
entityManager.clear();
Employee manager = new Employee("manager");
Employee resource = new Employee("slave");
resource.setCalendar(calendar);
Project project = new Project();
project.addManager(manager);
project.getAccountableHours().add(hourType);
project.addTeamMember(resource);
assertNull(project.getId());
setField(projectRepository, "employeeRepository", employeeRepository);
expect(employeeRepository.create(resource)).andReturn(getPersisted(resource));
expect(employeeRepository.create(manager)).andReturn(getPersisted(manager));
replay(employeeRepository);
Project actual = projectRepository.create(project);
entityManager.flush();
verify(employeeRepository);
assertNotNull(actual.getId());
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HourTypeConverterTest method testGetAsString_ifHourType.
@Test
public void testGetAsString_ifHourType() throws Exception {
HourType hourType = new HourType();
setField(hourType, "id", 1L);
String actual = converter.getAsString(facesContext, component, hourType);
assertEquals("1", actual);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HourTypeConverterTest method testGetAsObject_ifFoundInRepository.
@Test
public void testGetAsObject_ifFoundInRepository() throws Exception {
setField(converter, "hourTypeRepository", hourTypeRepository);
HourType hourType = new HourType();
expect(hourTypeRepository.find(1L)).andReturn(hourType);
replay(hourTypeRepository);
Object actual = converter.getAsObject(facesContext, component, "1");
EasyMock.verify(hourTypeRepository);
assertSame(hourType, actual);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursIndexedBundleTest method testContainsHours_ByEmployee_ifNotContains.
@Test
public void testContainsHours_ByEmployee_ifNotContains() {
Project project = createProject(1L);
Employee employee1 = new Employee("employee1");
Employee employee2 = new Employee("employee2");
HourType hourType = new HourType();
Hours hour = new Hours(project, new Date(), employee1, hourType);
List<Hours> hours = Arrays.asList(hour);
bundle = createHoursIndexedBundle(hours);
boolean actual = bundle.containsHours(employee2);
assertFalse(actual);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursIndexedBundleTest method testContainsHours_ByProjectAndEmployee_ifNotContainsProjectAndEmployee.
@Test
public void testContainsHours_ByProjectAndEmployee_ifNotContainsProjectAndEmployee() {
Project project1 = createProject(1L);
Project project2 = createProject(2L);
Employee employee1 = new Employee("employee1");
Employee employee2 = new Employee("employee2");
HourType hourType = new HourType();
Hours hour = new Hours(project1, new Date(), employee1, hourType);
List<Hours> hours = Arrays.asList(hour);
bundle = createHoursIndexedBundle(hours);
boolean actual = bundle.containsHours(project2, employee2);
assertFalse(actual);
}
Aggregations