Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.63 KB | None | 0 0
  1. @Test
  2.   public void createHalfAllocatedTest() {
  3.     Calendar calendar = TestFactoryMainData.createCalendar(TestConstants.GENERATING_DATE, false, false);
  4.     Employee employee = TestFactoryMainData.createEmployee(TestConstants.NAME, TestConstants.NAME, TestConstants.LDAP_ACCOUNT,
  5.         true, TestConstants.EXPERIENCE_MONTHS_SEVEN, true, TestConstants.EMPLOYEE_BEGIN_DATE, null,
  6.         false, true, TestConstants.UX_EMPLOYEE_POSITION, true, TestConstants.EMPLOYEE_BEGIN_DATE);
  7.  
  8.     Project project = TestFactoryMainData.createProject(TestConstants.NAME, TestConstants.NAME, true);
  9.  
  10.     AllocatedResource allocatedResource = TestFactoryMainData.createAllocatedResource(employee, true, Percentage.FIFTY);
  11.     Set<AllocatedResource> employeeAllocatedResources = new HashSet<>();
  12.     employeeAllocatedResources.add(allocatedResource);
  13.     employee.setAllocatedResources(employeeAllocatedResources);
  14.  
  15.     AllocatedResource returnedAllocatedResource = TestFactoryMainData.createAllocatedResource(employee, true, Percentage.FIFTY);
  16.     List<AllocatedResource> returnedAllocatedResources = new LinkedList<>();
  17.     returnedAllocatedResources.add(returnedAllocatedResource);
  18.  
  19.     //check allocated resource
  20.     Mockito.when(allocatedResourcesService.getCurrentAllocatedResource(employeeAllocatedResources, calendar.getDate())).thenReturn(returnedAllocatedResources);
  21.  
  22.     List<EmployeePosition> employeePositions = new LinkedList<>();
  23.     EmployeePosition employeePosition = TestFactoryMainData.createEmployeePosition(TestConstants.UX_EMPLOYEE_POSITION, true, TestConstants.EMPLOYEE_BEGIN_DATE);
  24.     employeePositions.add(employeePosition);
  25.     employee.setEmployeePositions(employeePositions);
  26.  
  27.     //check employee position
  28.     Mockito.when(employeePositionRepository.findByEmployeeAndStartDateOrderByStartDateDesc(employee, calendar.getDate())).thenReturn(employeePositions);
  29.  
  30.     //check dailyData
  31.     List<DailyEmployeeData> expectedDailyEmployeeDataList = new LinkedList<>();
  32.     DailyEmployeeData dailyEmployeeData = TestFactoryMainData.createDailyEmployeeData(calendar, employee, null,
  33.         DailyEmployeeStatusEnum.WORKING, LocationStatusEnum.HALFOFFICE, null, null, null,
  34.         Percentage.FIFTY, new BigDecimal("0"), 0, false, TestConstants.UX_EMPLOYEE_POSITION);
  35.     expectedDailyEmployeeDataList.add(dailyEmployeeData);
  36.  
  37.     DailyEmployeeData dailyEmployeeData2 = TestFactoryMainData.createDailyEmployeeData(calendar, employee, project, DailyEmployeeStatusEnum.WORKING,
  38.         LocationStatusEnum.OFFICE, FinancialProjectTypeEnum.TIME_AND_MATERIAL, MainProjectTypeEnum.EXTERNAL, StatementOfWorkStatusEnum.FINISHED, Percentage.FIFTY,
  39.         new BigDecimal("625"), 0, true, TestConstants.UX_EMPLOYEE_POSITION);
  40.     expectedDailyEmployeeDataList.add(dailyEmployeeData2);
  41.  
  42.     Mockito.when(plannedResourceService.createOnSiteReport(allocatedResource.getPlanned(), calendar)).thenReturn(null);
  43.     Mockito.when(plannedResourceService.getPricingSplit(allocatedResource.getPlanned())).thenReturn(allocatedResource.getPlanned().getPricingSplit());
  44.     Mockito.when(plannedResourceService.getLastBillablePeriod(allocatedResource.getPlanned(), calendar)).thenReturn(null);
  45.     Mockito.when(plannedResourceService.getLastNonbillablePeriod(allocatedResource.getPlanned(), calendar)).thenReturn(null);
  46.     Mockito.when(plannedResourceService.isBillable(allocatedResource.getPlanned(), null, null, null)).thenReturn(true);
  47.  
  48.     List<DailyEmployeeData> actual = dailyEmployeeDataService.generateDailyEmployeeDataList(calendar, employee);
  49.  
  50.     Assert.assertEquals(actual.size(), 2);
  51.     assertDailyEmployeeData(expectedDailyEmployeeDataList.get(0), actual.get(0));
  52.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement