diff --git a/app/loader/SignalConsoApplicationLoader.scala b/app/loader/SignalConsoApplicationLoader.scala index 6fadcf6b..8f8950c7 100644 --- a/app/loader/SignalConsoApplicationLoader.scala +++ b/app/loader/SignalConsoApplicationLoader.scala @@ -91,7 +91,6 @@ import repositories.website.WebsiteRepositoryInterface import services._ import services.antivirus.AntivirusService import services.antivirus.AntivirusServiceInterface -import services.emails.BaseEmail import services.emails.MailRetriesService import services.emails.MailService import services.emails.MailServiceInterface @@ -249,7 +248,7 @@ class SignalConsoComponents( amazonBucketName = applicationConfiguration.amazonBucketName ) - def s3Service: S3ServiceInterface = new S3Service() + val s3Service: S3ServiceInterface = new S3Service() // Actor val antivirusScanActor: typed.ActorRef[AntivirusScanActor.ScanCommand] = actorSystem.spawn( @@ -390,7 +389,7 @@ class SignalConsoComponents( val emailNotificationOrchestrator = new EmailNotificationOrchestrator(mailService, subscriptionRepository) - def buildReportOrchestrator(emailService: MailServiceInterface) = new ReportOrchestrator( + private def buildReportOrchestrator(emailService: MailServiceInterface) = new ReportOrchestrator( emailService, reportConsumerReviewOrchestrator, reportRepository, diff --git a/app/models/report/sampledata/SampleDataService.scala b/app/models/report/sampledata/SampleDataService.scala index 9db7f494..4273b439 100644 --- a/app/models/report/sampledata/SampleDataService.scala +++ b/app/models/report/sampledata/SampleDataService.scala @@ -194,11 +194,13 @@ class SampleDataService( } .flatMap(_ => userRepository.updatePassword(user.id, password = "test")) - private def delete(users: List[User]) = - users.traverse { u => + private def delete(predefinedUsers: List[User]) = + predefinedUsers.traverse { predefinedUser => for { - companies <- companyAccessRepository.fetchCompaniesWithLevel(u) - sirets = companies.map(_.company.siret.value) + maybeUser <- userRepository.get(predefinedUser.id) + maybeCompany <- maybeUser.traverse(user => companyAccessRepository.fetchCompaniesWithLevel(user)) + companies = maybeCompany.getOrElse(List.empty) + sirets = companies.map(c => c.company.siret.value) reportList <- reportRepository .getReports( None, @@ -207,12 +209,11 @@ class SampleDataService( None ) .map(_.entities.map(_.report.id)) - _ <- reportList.traverse(reportAdminActionOrchestrator.deleteReport) - companies <- companyAccessRepository.fetchCompaniesWithLevel(u) - websites <- websiteRepository.searchByCompaniesId(companies.map(_.company.id)) - _ <- websites.map(_.id).traverse(websiteRepository.delete) - _ <- companies.traverse(c => companyRepository.delete(c.company.id)) - _ <- userRepository.hardDelete(u.id) + _ <- reportList.traverse(reportAdminActionOrchestrator.deleteReport) + websites <- websiteRepository.searchByCompaniesId(companies.map(_.company.id)) + _ <- websites.map(_.id).traverse(websiteRepository.delete) + _ <- companies.traverse(c => companyRepository.delete(c.company.id)) + _ <- maybeUser.traverse(user => userRepository.hardDelete(user.id)) } yield () }