@Test public void testPopulateDocumentsInRespectiveObjects() { employeeDocumentsService = new EmployeeDocumentsService(); employeeDocumentsService.setEmployeeDocumentsRepository(new EmployeeDocumentsRepository() { public List<EmployeeDocument> findByEmployeeId(Long id, String tenantId) { List<EmployeeDocument> employeeDocuments = new ArrayList<>(); employeeDocuments .add(new EmployeeDocument(0L, 100L, "http: EntityType.EMPLOYEE_HEADER.getValue(), 100L, "1")); employeeDocuments.add( new EmployeeDocument(0L, 100L, "http: EntityType.EMPLOYEE_HEADER.getValue(), 100L, "1")); employeeDocuments.add( new EmployeeDocument(0L, 100L, "http: EntityType.ASSIGNMENT.getValue(), 5L, "1")); employeeDocuments.add( new EmployeeDocument(0L, 100L, "http: EntityType.ASSIGNMENT.getValue(), 5L, "1")); employeeDocuments.add( new EmployeeDocument(0L, 100L, "http: EntityType.ASSIGNMENT.getValue(), 6L, "1")); employeeDocuments.add( new EmployeeDocument(0L, 100L, "http: EntityType.ASSIGNMENT.getValue(), 6L, "1")); employeeDocuments.add(new EmployeeDocument(0L, 100L, "http: EntityType.PROBATION.getValue(), 10L, "1")); employeeDocuments.add(new EmployeeDocument(0L, 100L, "http: EntityType.SERVICE.getValue(), 10L, "1")); employeeDocuments.add(new EmployeeDocument(0L, 100L, "http: EntityType.REGULARISATION.getValue(), 5L, "1")); employeeDocuments.add( new EmployeeDocument(0L, 100L, "http: EntityType.REGULARISATION.getValue(), 5L, "1")); employeeDocuments.add(new EmployeeDocument(0L, 100L, "http: EntityType.TECHNICAL.getValue(), 5000L, "1")); employeeDocuments.add(new EmployeeDocument(0L, 100L, "http: EntityType.EDUCATION.getValue(), 501L, "1")); employeeDocuments.add(new EmployeeDocument(0L, 100L, "http: EntityType.EDUCATION.getValue(), 501L, "1")); employeeDocuments.add(new EmployeeDocument(0L, 100L, "http: EntityType.TEST.getValue(), 1L, "1")); employeeDocuments.add(new EmployeeDocument(0L, 100L, "http: EntityType.TEST.getValue(), 1L, "1")); return employeeDocuments; } }); Employee employee = null; try { employee = getEmployee("org/egov/eis/service/EmployeeDocumentService.populateDocuments.json"); } catch (Exception e) { e.printStackTrace(); fail(); } assertEquals(employee.getDocuments().size(), 0); assertEquals(employee.getAssignments().get(0).getDocuments().size(), 0); assertEquals(employee.getAssignments().get(1).getDocuments().size(), 0); assertEquals(employee.getProbation().get(0).getDocuments().size(), 0); assertEquals(employee.getServiceHistory().get(0).getDocuments().size(), 0); assertEquals(employee.getRegularisation().get(0).getDocuments().size(), 0); assertEquals(employee.getTechnical().get(0).getDocuments().size(), 0); assertEquals(employee.getEducation().get(0).getDocuments().size(), 0); assertEquals(employee.getTest().get(0).getDocuments().size(), 0); employeeDocumentsService.populateDocumentsInRespectiveObjects(employee); assertEquals(employee.getDocuments().size(), 2); assertEquals(employee.getAssignments().get(0).getDocuments().size(), 2); assertEquals(employee.getAssignments().get(1).getDocuments().size(), 2); assertEquals(employee.getProbation().get(0).getDocuments().size(), 1); assertEquals(employee.getServiceHistory().get(0).getDocuments().size(), 1); assertEquals(employee.getRegularisation().get(0).getDocuments().size(), 2); assertEquals(employee.getTechnical().get(0).getDocuments().size(), 1); assertEquals(employee.getEducation().get(0).getDocuments().size(), 2); assertEquals(employee.getTest().get(0).getDocuments().size(), 2); assertTrue(employee.getDocuments().get(0).equals("http: assertTrue( employee.getDocuments().get(1).equals("http: assertTrue(employee.getAssignments().get(0).getDocuments().get(0) .equals("http: assertTrue(employee.getAssignments().get(0).getDocuments().get(1) .equals("http: assertTrue(employee.getAssignments().get(1).getDocuments().get(0) .equals("http: assertTrue(employee.getAssignments().get(1).getDocuments().get(1) .equals("http: assertTrue(employee.getProbation().get(0).getDocuments().get(0) .equals("http: assertTrue(employee.getServiceHistory().get(0).getDocuments().get(0) .equals("http: assertTrue(employee.getRegularisation().get(0).getDocuments().get(0) .equals("http: assertTrue(employee.getRegularisation().get(0).getDocuments().get(1) .equals("http: assertTrue(employee.getTechnical().get(0).getDocuments().get(0) .equals("http: assertTrue(employee.getEducation().get(0).getDocuments().get(0) .equals("http: assertTrue(employee.getEducation().get(0).getDocuments().get(1) .equals("http: assertTrue(employee.getTest().get(0).getDocuments().get(0) .equals("http: assertTrue(employee.getTest().get(0).getDocuments().get(1) .equals("http: }
public void populateDocumentsInRespectiveObjects(Employee employee) { List<EmployeeDocument> documents = employeeDocumentsRepository.findByEmployeeId(employee.getId(), employee.getTenantId()); for (EmployeeDocument document : documents) { EntityType referenceType = EntityType.valueOf(document.getReferenceType()); switch (referenceType) { case EMPLOYEE_HEADER: employee.getDocuments().add(document.getDocument()); break; case ASSIGNMENT: for (Assignment assignment : employee.getAssignments()) if (assignment.getId().equals(document.getReferenceId())) assignment.getDocuments().add(document.getDocument()); break; case SERVICE: for (ServiceHistory serviceHistory : employee.getServiceHistory()) if (serviceHistory.getId().equals(document.getReferenceId())) serviceHistory.getDocuments().add(document.getDocument()); break; case TECHNICAL: for (TechnicalQualification technicalQualification : employee.getTechnical()) if (technicalQualification.getId().equals(document.getReferenceId())) technicalQualification.getDocuments().add(document.getDocument()); break; case EDUCATION: for (EducationalQualification educationalQualification : employee.getEducation()) if (educationalQualification.getId().equals(document.getReferenceId())) educationalQualification.getDocuments().add(document.getDocument()); break; case TEST: for (DepartmentalTest departmentalTest : employee.getTest()) if (departmentalTest.getId().equals(document.getReferenceId())) departmentalTest.getDocuments().add(document.getDocument()); break; case REGULARISATION: for (Regularisation regularisation : employee.getRegularisation()) if (regularisation.getId().equals(document.getReferenceId())) regularisation.getDocuments().add(document.getDocument()); break; case PROBATION: for (Probation probation : employee.getProbation()) if (probation.getId().equals(document.getReferenceId())) probation.getDocuments().add(document.getDocument()); break; case APR_DETAILS: for (APRDetail aprDetail : employee.getAprDetails()) { if (aprDetail.getId().equals(document.getReferenceId())) aprDetail.getDocuments().add(document.getDocument()); } break; default: break; } } }
EmployeeDocumentsService { public void populateDocumentsInRespectiveObjects(Employee employee) { List<EmployeeDocument> documents = employeeDocumentsRepository.findByEmployeeId(employee.getId(), employee.getTenantId()); for (EmployeeDocument document : documents) { EntityType referenceType = EntityType.valueOf(document.getReferenceType()); switch (referenceType) { case EMPLOYEE_HEADER: employee.getDocuments().add(document.getDocument()); break; case ASSIGNMENT: for (Assignment assignment : employee.getAssignments()) if (assignment.getId().equals(document.getReferenceId())) assignment.getDocuments().add(document.getDocument()); break; case SERVICE: for (ServiceHistory serviceHistory : employee.getServiceHistory()) if (serviceHistory.getId().equals(document.getReferenceId())) serviceHistory.getDocuments().add(document.getDocument()); break; case TECHNICAL: for (TechnicalQualification technicalQualification : employee.getTechnical()) if (technicalQualification.getId().equals(document.getReferenceId())) technicalQualification.getDocuments().add(document.getDocument()); break; case EDUCATION: for (EducationalQualification educationalQualification : employee.getEducation()) if (educationalQualification.getId().equals(document.getReferenceId())) educationalQualification.getDocuments().add(document.getDocument()); break; case TEST: for (DepartmentalTest departmentalTest : employee.getTest()) if (departmentalTest.getId().equals(document.getReferenceId())) departmentalTest.getDocuments().add(document.getDocument()); break; case REGULARISATION: for (Regularisation regularisation : employee.getRegularisation()) if (regularisation.getId().equals(document.getReferenceId())) regularisation.getDocuments().add(document.getDocument()); break; case PROBATION: for (Probation probation : employee.getProbation()) if (probation.getId().equals(document.getReferenceId())) probation.getDocuments().add(document.getDocument()); break; case APR_DETAILS: for (APRDetail aprDetail : employee.getAprDetails()) { if (aprDetail.getId().equals(document.getReferenceId())) aprDetail.getDocuments().add(document.getDocument()); } break; default: break; } } } }
EmployeeDocumentsService { public void populateDocumentsInRespectiveObjects(Employee employee) { List<EmployeeDocument> documents = employeeDocumentsRepository.findByEmployeeId(employee.getId(), employee.getTenantId()); for (EmployeeDocument document : documents) { EntityType referenceType = EntityType.valueOf(document.getReferenceType()); switch (referenceType) { case EMPLOYEE_HEADER: employee.getDocuments().add(document.getDocument()); break; case ASSIGNMENT: for (Assignment assignment : employee.getAssignments()) if (assignment.getId().equals(document.getReferenceId())) assignment.getDocuments().add(document.getDocument()); break; case SERVICE: for (ServiceHistory serviceHistory : employee.getServiceHistory()) if (serviceHistory.getId().equals(document.getReferenceId())) serviceHistory.getDocuments().add(document.getDocument()); break; case TECHNICAL: for (TechnicalQualification technicalQualification : employee.getTechnical()) if (technicalQualification.getId().equals(document.getReferenceId())) technicalQualification.getDocuments().add(document.getDocument()); break; case EDUCATION: for (EducationalQualification educationalQualification : employee.getEducation()) if (educationalQualification.getId().equals(document.getReferenceId())) educationalQualification.getDocuments().add(document.getDocument()); break; case TEST: for (DepartmentalTest departmentalTest : employee.getTest()) if (departmentalTest.getId().equals(document.getReferenceId())) departmentalTest.getDocuments().add(document.getDocument()); break; case REGULARISATION: for (Regularisation regularisation : employee.getRegularisation()) if (regularisation.getId().equals(document.getReferenceId())) regularisation.getDocuments().add(document.getDocument()); break; case PROBATION: for (Probation probation : employee.getProbation()) if (probation.getId().equals(document.getReferenceId())) probation.getDocuments().add(document.getDocument()); break; case APR_DETAILS: for (APRDetail aprDetail : employee.getAprDetails()) { if (aprDetail.getId().equals(document.getReferenceId())) aprDetail.getDocuments().add(document.getDocument()); } break; default: break; } } }  }
EmployeeDocumentsService { public void populateDocumentsInRespectiveObjects(Employee employee) { List<EmployeeDocument> documents = employeeDocumentsRepository.findByEmployeeId(employee.getId(), employee.getTenantId()); for (EmployeeDocument document : documents) { EntityType referenceType = EntityType.valueOf(document.getReferenceType()); switch (referenceType) { case EMPLOYEE_HEADER: employee.getDocuments().add(document.getDocument()); break; case ASSIGNMENT: for (Assignment assignment : employee.getAssignments()) if (assignment.getId().equals(document.getReferenceId())) assignment.getDocuments().add(document.getDocument()); break; case SERVICE: for (ServiceHistory serviceHistory : employee.getServiceHistory()) if (serviceHistory.getId().equals(document.getReferenceId())) serviceHistory.getDocuments().add(document.getDocument()); break; case TECHNICAL: for (TechnicalQualification technicalQualification : employee.getTechnical()) if (technicalQualification.getId().equals(document.getReferenceId())) technicalQualification.getDocuments().add(document.getDocument()); break; case EDUCATION: for (EducationalQualification educationalQualification : employee.getEducation()) if (educationalQualification.getId().equals(document.getReferenceId())) educationalQualification.getDocuments().add(document.getDocument()); break; case TEST: for (DepartmentalTest departmentalTest : employee.getTest()) if (departmentalTest.getId().equals(document.getReferenceId())) departmentalTest.getDocuments().add(document.getDocument()); break; case REGULARISATION: for (Regularisation regularisation : employee.getRegularisation()) if (regularisation.getId().equals(document.getReferenceId())) regularisation.getDocuments().add(document.getDocument()); break; case PROBATION: for (Probation probation : employee.getProbation()) if (probation.getId().equals(document.getReferenceId())) probation.getDocuments().add(document.getDocument()); break; case APR_DETAILS: for (APRDetail aprDetail : employee.getAprDetails()) { if (aprDetail.getId().equals(document.getReferenceId())) aprDetail.getDocuments().add(document.getDocument()); } break; default: break; } } }  void update(Employee employee); void updateDocumentsForNominee(List<Nominee> nominees); void populateDocumentsInRespectiveObjects(Employee employee); List<EmployeeDocument> getDocumentsForReferenceType(Long employeeId, Long referenceId,
															   String entityType, String tenantId); EmployeeDocumentsRepository getEmployeeDocumentsRepository(); void setEmployeeDocumentsRepository(EmployeeDocumentsRepository employeeDocumentsRepository); }
EmployeeDocumentsService { public void populateDocumentsInRespectiveObjects(Employee employee) { List<EmployeeDocument> documents = employeeDocumentsRepository.findByEmployeeId(employee.getId(), employee.getTenantId()); for (EmployeeDocument document : documents) { EntityType referenceType = EntityType.valueOf(document.getReferenceType()); switch (referenceType) { case EMPLOYEE_HEADER: employee.getDocuments().add(document.getDocument()); break; case ASSIGNMENT: for (Assignment assignment : employee.getAssignments()) if (assignment.getId().equals(document.getReferenceId())) assignment.getDocuments().add(document.getDocument()); break; case SERVICE: for (ServiceHistory serviceHistory : employee.getServiceHistory()) if (serviceHistory.getId().equals(document.getReferenceId())) serviceHistory.getDocuments().add(document.getDocument()); break; case TECHNICAL: for (TechnicalQualification technicalQualification : employee.getTechnical()) if (technicalQualification.getId().equals(document.getReferenceId())) technicalQualification.getDocuments().add(document.getDocument()); break; case EDUCATION: for (EducationalQualification educationalQualification : employee.getEducation()) if (educationalQualification.getId().equals(document.getReferenceId())) educationalQualification.getDocuments().add(document.getDocument()); break; case TEST: for (DepartmentalTest departmentalTest : employee.getTest()) if (departmentalTest.getId().equals(document.getReferenceId())) departmentalTest.getDocuments().add(document.getDocument()); break; case REGULARISATION: for (Regularisation regularisation : employee.getRegularisation()) if (regularisation.getId().equals(document.getReferenceId())) regularisation.getDocuments().add(document.getDocument()); break; case PROBATION: for (Probation probation : employee.getProbation()) if (probation.getId().equals(document.getReferenceId())) probation.getDocuments().add(document.getDocument()); break; case APR_DETAILS: for (APRDetail aprDetail : employee.getAprDetails()) { if (aprDetail.getId().equals(document.getReferenceId())) aprDetail.getDocuments().add(document.getDocument()); } break; default: break; } } }  void update(Employee employee); void updateDocumentsForNominee(List<Nominee> nominees); void populateDocumentsInRespectiveObjects(Employee employee); List<EmployeeDocument> getDocumentsForReferenceType(Long employeeId, Long referenceId,
															   String entityType, String tenantId); EmployeeDocumentsRepository getEmployeeDocumentsRepository(); void setEmployeeDocumentsRepository(EmployeeDocumentsRepository employeeDocumentsRepository);  }