@Test public void deleteStudy() throws Exception { when(ancestryRepository.findByStudyId(STUDY.getId())).thenReturn(Arrays.asList(ETH1, ETH2)); studyService.deleteRelatedInfoByStudy(STUDY); studyDeletionService.deleteStudy(STUDY, SECURE_USER); verify(ancestryRepository, times(1)).delete(ETH1); verify(ancestryRepository, times(1)).delete(ETH2); verify(trackingOperationService, times(1)).delete(STUDY, SECURE_USER); verify(studyRepository, times(1)).delete(STUDY); verify(deletedStudyRepository, times(1)).save(Matchers.any(DeletedStudy.class)); }
public void deleteStudy(Study study, SecureUser user) { getLog().warn("Deleting study: ".concat(String.valueOf(study.getId()))); Collection<Ancestry> ancestriesAttachedToStudy = ancestryRepository.findByStudyId(study.getId()); for (Ancestry ancestry : ancestriesAttachedToStudy) { ancestryRepository.delete(ancestry); } studyService.deleteRelatedInfoByStudy(study); trackingOperationService.delete(study, user); DeletedStudy deletedStudy = createDeletedStudy(study); Publication publication = study.getPublicationId(); study.setPublicationId(null); studyRepository.save(study); studyRepository.delete(study); publicationOperationsService.deletePublicationWithNoStudies(publication); getLog().info("Saving details of deleted study: ".concat(String.valueOf(deletedStudy.getId()))); deletedStudyRepository.save(deletedStudy); }
StudyDeletionService { public void deleteStudy(Study study, SecureUser user) { getLog().warn("Deleting study: ".concat(String.valueOf(study.getId()))); Collection<Ancestry> ancestriesAttachedToStudy = ancestryRepository.findByStudyId(study.getId()); for (Ancestry ancestry : ancestriesAttachedToStudy) { ancestryRepository.delete(ancestry); } studyService.deleteRelatedInfoByStudy(study); trackingOperationService.delete(study, user); DeletedStudy deletedStudy = createDeletedStudy(study); Publication publication = study.getPublicationId(); study.setPublicationId(null); studyRepository.save(study); studyRepository.delete(study); publicationOperationsService.deletePublicationWithNoStudies(publication); getLog().info("Saving details of deleted study: ".concat(String.valueOf(deletedStudy.getId()))); deletedStudyRepository.save(deletedStudy); } }
StudyDeletionService { public void deleteStudy(Study study, SecureUser user) { getLog().warn("Deleting study: ".concat(String.valueOf(study.getId()))); Collection<Ancestry> ancestriesAttachedToStudy = ancestryRepository.findByStudyId(study.getId()); for (Ancestry ancestry : ancestriesAttachedToStudy) { ancestryRepository.delete(ancestry); } studyService.deleteRelatedInfoByStudy(study); trackingOperationService.delete(study, user); DeletedStudy deletedStudy = createDeletedStudy(study); Publication publication = study.getPublicationId(); study.setPublicationId(null); studyRepository.save(study); studyRepository.delete(study); publicationOperationsService.deletePublicationWithNoStudies(publication); getLog().info("Saving details of deleted study: ".concat(String.valueOf(deletedStudy.getId()))); deletedStudyRepository.save(deletedStudy); } @Autowired  StudyDeletionService(AncestryRepository ancestryRepository,
                                @Qualifier("studyTrackingOperationServiceImpl") TrackingOperationService trackingOperationService,
                                StudyRepository studyRepository,
                                DeletedStudyRepository deletedStudyRepository,
                                StudyService studyService,
                                PublicationOperationsService publicationOperationsService); }
StudyDeletionService { public void deleteStudy(Study study, SecureUser user) { getLog().warn("Deleting study: ".concat(String.valueOf(study.getId()))); Collection<Ancestry> ancestriesAttachedToStudy = ancestryRepository.findByStudyId(study.getId()); for (Ancestry ancestry : ancestriesAttachedToStudy) { ancestryRepository.delete(ancestry); } studyService.deleteRelatedInfoByStudy(study); trackingOperationService.delete(study, user); DeletedStudy deletedStudy = createDeletedStudy(study); Publication publication = study.getPublicationId(); study.setPublicationId(null); studyRepository.save(study); studyRepository.delete(study); publicationOperationsService.deletePublicationWithNoStudies(publication); getLog().info("Saving details of deleted study: ".concat(String.valueOf(deletedStudy.getId()))); deletedStudyRepository.save(deletedStudy); } @Autowired  StudyDeletionService(AncestryRepository ancestryRepository,
                                @Qualifier("studyTrackingOperationServiceImpl") TrackingOperationService trackingOperationService,
                                StudyRepository studyRepository,
                                DeletedStudyRepository deletedStudyRepository,
                                StudyService studyService,
                                PublicationOperationsService publicationOperationsService); void deleteStudy(Study study, SecureUser user); }
StudyDeletionService { public void deleteStudy(Study study, SecureUser user) { getLog().warn("Deleting study: ".concat(String.valueOf(study.getId()))); Collection<Ancestry> ancestriesAttachedToStudy = ancestryRepository.findByStudyId(study.getId()); for (Ancestry ancestry : ancestriesAttachedToStudy) { ancestryRepository.delete(ancestry); } studyService.deleteRelatedInfoByStudy(study); trackingOperationService.delete(study, user); DeletedStudy deletedStudy = createDeletedStudy(study); Publication publication = study.getPublicationId(); study.setPublicationId(null); studyRepository.save(study); studyRepository.delete(study); publicationOperationsService.deletePublicationWithNoStudies(publication); getLog().info("Saving details of deleted study: ".concat(String.valueOf(deletedStudy.getId()))); deletedStudyRepository.save(deletedStudy); } @Autowired  StudyDeletionService(AncestryRepository ancestryRepository,
                                @Qualifier("studyTrackingOperationServiceImpl") TrackingOperationService trackingOperationService,
                                StudyRepository studyRepository,
                                DeletedStudyRepository deletedStudyRepository,
                                StudyService studyService,
                                PublicationOperationsService publicationOperationsService); void deleteStudy(Study study, SecureUser user);  }