Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- public void createHalfAllocatedTest() {
- Calendar calendar = TestFactoryMainData.createCalendar(TestConstants.GENERATING_DATE, false, false);
- Employee employee = TestFactoryMainData.createEmployee(TestConstants.NAME, TestConstants.NAME, TestConstants.LDAP_ACCOUNT,
- true, TestConstants.EXPERIENCE_MONTHS_SEVEN, true, TestConstants.EMPLOYEE_BEGIN_DATE, null,
- false, true, TestConstants.UX_EMPLOYEE_POSITION, true, TestConstants.EMPLOYEE_BEGIN_DATE);
- Project project = TestFactoryMainData.createProject(TestConstants.NAME, TestConstants.NAME, true);
- AllocatedResource allocatedResource = TestFactoryMainData.createAllocatedResource(employee, true, Percentage.FIFTY);
- Set<AllocatedResource> employeeAllocatedResources = new HashSet<>();
- employeeAllocatedResources.add(allocatedResource);
- employee.setAllocatedResources(employeeAllocatedResources);
- AllocatedResource returnedAllocatedResource = TestFactoryMainData.createAllocatedResource(employee, true, Percentage.FIFTY);
- List<AllocatedResource> returnedAllocatedResources = new LinkedList<>();
- returnedAllocatedResources.add(returnedAllocatedResource);
- //check allocated resource
- Mockito.when(allocatedResourcesService.getCurrentAllocatedResource(employeeAllocatedResources, calendar.getDate())).thenReturn(returnedAllocatedResources);
- List<EmployeePosition> employeePositions = new LinkedList<>();
- EmployeePosition employeePosition = TestFactoryMainData.createEmployeePosition(TestConstants.UX_EMPLOYEE_POSITION, true, TestConstants.EMPLOYEE_BEGIN_DATE);
- employeePositions.add(employeePosition);
- employee.setEmployeePositions(employeePositions);
- //check employee position
- Mockito.when(employeePositionRepository.findByEmployeeAndStartDateOrderByStartDateDesc(employee, calendar.getDate())).thenReturn(employeePositions);
- //check dailyData
- List<DailyEmployeeData> expectedDailyEmployeeDataList = new LinkedList<>();
- DailyEmployeeData dailyEmployeeData = TestFactoryMainData.createDailyEmployeeData(calendar, employee, null,
- DailyEmployeeStatusEnum.WORKING, LocationStatusEnum.HALFOFFICE, null, null, null,
- Percentage.FIFTY, new BigDecimal("0"), 0, false, TestConstants.UX_EMPLOYEE_POSITION);
- expectedDailyEmployeeDataList.add(dailyEmployeeData);
- DailyEmployeeData dailyEmployeeData2 = TestFactoryMainData.createDailyEmployeeData(calendar, employee, project, DailyEmployeeStatusEnum.WORKING,
- LocationStatusEnum.OFFICE, FinancialProjectTypeEnum.TIME_AND_MATERIAL, MainProjectTypeEnum.EXTERNAL, StatementOfWorkStatusEnum.FINISHED, Percentage.FIFTY,
- new BigDecimal("625"), 0, true, TestConstants.UX_EMPLOYEE_POSITION);
- expectedDailyEmployeeDataList.add(dailyEmployeeData2);
- Mockito.when(plannedResourceService.createOnSiteReport(allocatedResource.getPlanned(), calendar)).thenReturn(null);
- Mockito.when(plannedResourceService.getPricingSplit(allocatedResource.getPlanned())).thenReturn(allocatedResource.getPlanned().getPricingSplit());
- Mockito.when(plannedResourceService.getLastBillablePeriod(allocatedResource.getPlanned(), calendar)).thenReturn(null);
- Mockito.when(plannedResourceService.getLastNonbillablePeriod(allocatedResource.getPlanned(), calendar)).thenReturn(null);
- Mockito.when(plannedResourceService.isBillable(allocatedResource.getPlanned(), null, null, null)).thenReturn(true);
- List<DailyEmployeeData> actual = dailyEmployeeDataService.generateDailyEmployeeDataList(calendar, employee);
- Assert.assertEquals(actual.size(), 2);
- assertDailyEmployeeData(expectedDailyEmployeeDataList.get(0), actual.get(0));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement