diff --git a/app/controllers/AccountController.scala b/app/controllers/AccountController.scala index 2c118acc..83a71ece 100644 --- a/app/controllers/AccountController.scala +++ b/app/controllers/AccountController.scala @@ -97,11 +97,11 @@ class AccountController( } def fetchPendingAgent(role: Option[UserRole]) = - SecuredAction.andThen(WithRole(UserRole.AdminsAndReadOnly)).async { request => + SecuredAction.andThen(WithRole(UserRole.AdminsAndReadOnly)).async { _ => role match { case Some(UserRole.DGCCRF) | Some(UserRole.DGAL) | None => accessesOrchestrator - .listAgentPendingTokens(request.identity, role) + .listAgentPendingTokens(role) .map(tokens => Ok(Json.toJson(tokens))) case Some(role) => Future.failed(error.AppError.WrongUserRole(role)) } diff --git a/app/models/report/sampledata/ReportGenerator.scala b/app/models/report/sampledata/ReportGenerator.scala index 84dcffa4..25db1136 100644 --- a/app/models/report/sampledata/ReportGenerator.scala +++ b/app/models/report/sampledata/ReportGenerator.scala @@ -51,7 +51,6 @@ object ReportGenerator { influencer: Option[Influencer], consumerUser: ConsumerUser, tags: List[ReportTag], - expired: Boolean, french: Boolean ): ReportDraft = ReportDraft( @@ -111,7 +110,7 @@ object ReportGenerator { ) } - def visibleReports(company: Company, expired: Boolean) = + def visibleReports(company: Company) = ReportTag.values.collect { case ReportTag.LitigeContractuel => generateReport( @@ -122,7 +121,6 @@ object ReportGenerator { influencer = None, consumerUser = generateConsumerUser, tags = List(ReportTag.LitigeContractuel), - expired = expired, french = true ) case tag @ ReportTag.ProduitDangereux => @@ -134,7 +132,6 @@ object ReportGenerator { influencer = None, consumerUser = generateConsumerUser, tags = List(tag), - expired = expired, french = true ) case tag @ ReportTag.DemarchageTelephonique => @@ -146,7 +143,6 @@ object ReportGenerator { influencer = None, consumerUser = generateConsumerUser, tags = List(tag), - expired = expired, french = true ) case tag @ ReportTag.Influenceur => @@ -158,7 +154,6 @@ object ReportGenerator { influencer = Some(Influencer(Some(TikTok), None, "InfluencerPseudo")), consumerUser = generateConsumerUser, tags = List(tag), - expired = expired, french = true ) case tag @ ReportTag.ReponseConso => @@ -170,7 +165,6 @@ object ReportGenerator { influencer = None, consumerUser = generateConsumerUser, tags = List(tag), - expired = expired, french = true ) case tag @ ReportTag.Internet => @@ -182,7 +176,6 @@ object ReportGenerator { influencer = None, consumerUser = generateConsumerUser, tags = List(tag), - expired = expired, french = true ) @@ -195,7 +188,6 @@ object ReportGenerator { influencer = None, consumerUser = generateConsumerUser, tags = List(tag), - expired = expired, french = true ) }.toList diff --git a/app/models/report/sampledata/SampleDataService.scala b/app/models/report/sampledata/SampleDataService.scala index 2ef0a0e6..9db7f494 100644 --- a/app/models/report/sampledata/SampleDataService.scala +++ b/app/models/report/sampledata/SampleDataService.scala @@ -127,10 +127,10 @@ class SampleDataService( for { _ <- companyRepository.create(c) _ <- proUsers.traverse(accessTokenRepository.giveCompanyAccess(c, _, AccessLevel.ADMIN)) - reports = ReportGenerator.visibleReports(c, expired = false) + reports = ReportGenerator.visibleReports(c) createdReports <- reports.traverse(reportOrchestrator.createReport) _ <- createdReports.traverse { r => - val creationDate = OffsetDateTime.now().minusDays(Random.between(1, 20)) + val creationDate = OffsetDateTime.now().minusDays(Random.between(1L, 20L)) reportRepository.update( r.id, r.copy( @@ -167,10 +167,10 @@ class SampleDataService( ) private def processedReports(c: Company, response: IncomingReportResponse, proUser: User) = for { - createdReports <- ReportGenerator.visibleReports(c, expired = false).traverse(reportOrchestrator.createReport) + createdReports <- ReportGenerator.visibleReports(c).traverse(reportOrchestrator.createReport) updateReports <- createdReports.traverse { r => - val creationDate = OffsetDateTime.now().minusWeeks(Random.between(1, 101)) + val creationDate = OffsetDateTime.now().minusWeeks(Random.between(1L, 101L)) reportRepository.update( r.id, r.copy( diff --git a/app/orchestrators/AccessesOrchestrator.scala b/app/orchestrators/AccessesOrchestrator.scala index 275c3562..6d050fb9 100644 --- a/app/orchestrators/AccessesOrchestrator.scala +++ b/app/orchestrators/AccessesOrchestrator.scala @@ -139,7 +139,7 @@ class AccessesOrchestrator( } yield () } - def listAgentPendingTokens(user: User, maybeRequestedRole: Option[UserRole]): Future[List[AgentAccessToken]] = + def listAgentPendingTokens(maybeRequestedRole: Option[UserRole]): Future[List[AgentAccessToken]] = accessTokenRepository.fetchPendingAgentTokens .map( _.flatMap { token => diff --git a/test/tasks/report/ReportRemindersTaskUnitSpec.scala b/test/tasks/report/ReportRemindersTaskUnitSpec.scala index 93c99a14..a66b7816 100644 --- a/test/tasks/report/ReportRemindersTaskUnitSpec.scala +++ b/test/tasks/report/ReportRemindersTaskUnitSpec.scala @@ -4,6 +4,7 @@ import org.apache.pekko.actor.testkit.typed.scaladsl.ActorTestKit import config.ExportReportsToSFTPConfiguration import config.ProbeConfiguration import config.ReportRemindersTaskConfiguration +import config.SampleDataConfiguration import config.TaskConfiguration import models.company.AccessLevel import models.event.Event @@ -56,7 +57,8 @@ class ReportRemindersTaskUnitSpec extends Specification with FutureMatchers { inactiveAccounts = null, companyUpdate = null, probe = ProbeConfiguration(false), - exportReportsToSFTP = ExportReportsToSFTPConfiguration("./reports.csv", LocalTime.of(3, 30)) + exportReportsToSFTP = ExportReportsToSFTPConfiguration("./reports.csv", LocalTime.of(3, 30)), + sampleData = SampleDataConfiguration(true, LocalTime.of(3, 30)) ) val testKit = ActorTestKit()