~jan0sch/smederee

Showing details for patch a69eaa79d1f9a48446cf19d12842579f6ff1e4c6.
2024-07-29 (Mon), 8:24 AM - Jens Grassel - a69eaa79d1f9a48446cf19d12842579f6ff1e4c6

Code Cleanup

Summary of changes
2 files modified with 5 lines added and 51 lines removed
  • modules/hub/src/test/scala/de/smederee/hub/Generators.scala with 0 added and 17 removed lines
  • modules/hub/src/test/scala/de/smederee/tickets/Generators.scala with 5 added and 34 removed lines
diff -rN -u old-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala new-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala
--- old-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala	2025-01-10 20:50:55.336646378 +0000
+++ new-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala	2025-01-10 20:50:55.340646386 +0000
@@ -124,17 +124,6 @@
 
     given Arbitrary[Account] = Arbitrary(genValidAccount)
 
-    val genValidAccounts: Gen[List[Account]] = Gen
-        .nonEmptyListOf(genValidAccount)
-        .map(_.foldLeft(List.empty[Account]) { (acc, a) =>
-            if (acc.exists(_.name === a.name))
-                acc
-            else
-                a :: acc
-        }) // Ensure distinct user names.
-
-    given Arbitrary[List[Account]] = Arbitrary(genValidAccounts)
-
     val genOrganisationId: Gen[OrganisationId] = Gen.delay(OrganisationId.randomOrganisationId)
 
     val genOrganisation: Gen[Organisation] =
@@ -157,8 +146,6 @@
 
     given Arbitrary[Organisation] = Arbitrary(genOrganisation)
 
-    val genOrganisations: Gen[List[Organisation]] = Gen.nonEmptyListOf(genOrganisation)
-
     val genValidSession: Gen[Session] =
         for {
             id  <- genSessionId
@@ -169,8 +156,6 @@
 
     given Arbitrary[Session] = Arbitrary(genValidSession)
 
-    val genValidSessions: Gen[List[Session]] = Gen.nonEmptyListOf(genValidSession)
-
     val genValidVcsRepositoryName: Gen[VcsRepositoryName] = Gen
         .nonEmptyListOf(
             Gen.oneOf(
@@ -237,8 +222,6 @@
 
     given Arbitrary[VcsRepository] = Arbitrary(genValidVcsRepository)
 
-    val genValidVcsRepositories: Gen[List[VcsRepository]] = Gen.nonEmptyListOf(genValidVcsRepository)
-
     val genPermissions: Gen[Set[Permission]] = Gen.choose(0, 7).map(Permission.decode)
 
     given Arbitrary[Set[Permission]] = Arbitrary(genPermissions)
diff -rN -u old-smederee/modules/hub/src/test/scala/de/smederee/tickets/Generators.scala new-smederee/modules/hub/src/test/scala/de/smederee/tickets/Generators.scala
--- old-smederee/modules/hub/src/test/scala/de/smederee/tickets/Generators.scala	2025-01-10 20:50:55.336646378 +0000
+++ new-smederee/modules/hub/src/test/scala/de/smederee/tickets/Generators.scala	2025-01-10 20:50:55.340646386 +0000
@@ -10,8 +10,6 @@
 import java.util.Locale
 import java.util.UUID
 
-import cats.*
-import cats.syntax.all.*
 import de.smederee.email.EmailAddress
 import de.smederee.i18n.LanguageCode
 import de.smederee.security.*
@@ -100,14 +98,11 @@
 
     val genTicketContent: Gen[Option[TicketContent]] = Gen.alphaStr.map(TicketContent.from)
 
-    val genTicketStatus: Gen[TicketStatus]           = Gen.oneOf(TicketStatus.values.toList)
-    val genTicketStatusList: Gen[List[TicketStatus]] = Gen.nonEmptyListOf(genTicketStatus).map(_.distinct)
+    val genTicketStatus: Gen[TicketStatus] = Gen.oneOf(TicketStatus.values.toList)
 
-    val genTicketResolution: Gen[TicketResolution]        = Gen.oneOf(TicketResolution.values.toList)
-    val genTicketResolutions: Gen[List[TicketResolution]] = Gen.nonEmptyListOf(genTicketResolution).map(_.distinct)
+    val genTicketResolution: Gen[TicketResolution] = Gen.oneOf(TicketResolution.values.toList)
 
-    val genTicketNumber: Gen[TicketNumber]        = Gen.choose(0, Int.MaxValue).map(TicketNumber.apply)
-    val genTicketNumbers: Gen[List[TicketNumber]] = Gen.nonEmptyListOf(genTicketNumber).map(_.distinct)
+    val genTicketNumber: Gen[TicketNumber] = Gen.choose(0, Int.MaxValue).map(TicketNumber.apply)
 
     val genTicketTitle: Gen[TicketTitle] =
         Gen.nonEmptyListOf(Gen.alphaNumChar).map(_.take(TicketTitle.MaxLength).mkString).map(TicketTitle.apply)
@@ -121,8 +116,6 @@
 
     given Arbitrary[TicketsUser] = Arbitrary(genTicketsUser)
 
-    val genTicketsUsers: Gen[List[TicketsUser]] = Gen.nonEmptyListOf(genTicketsUser)
-
     val genTicket: Gen[Ticket] = for {
         number     <- genTicketNumber
         title      <- genTicketTitle
@@ -145,10 +138,6 @@
 
     given Arbitrary[Ticket] = Arbitrary(genTicket)
 
-    val genTickets: Gen[List[Ticket]] =
-        Gen.nonEmptyListOf(genTicket)
-            .map(_.zipWithIndex.map(tuple => tuple._1.copy(number = TicketNumber(tuple._2 + 1))))
-
     val genTicketComment: Gen[TicketComment] =
         for {
             content   <- genTicketCommentContent
@@ -159,8 +148,6 @@
 
     given Arbitrary[TicketComment] = Arbitrary(genTicketComment)
 
-    val genTicketComments: Gen[List[TicketComment]] = Gen.nonEmptyListOf(genTicketComment)
-
     val genTicketFilter: Gen[TicketFilter] =
         for {
             number     <- Gen.listOf(genTicketNumber)
@@ -185,15 +172,6 @@
 
     given Arbitrary[ProjectOwner] = Arbitrary(genProjectOwner)
 
-    val genProjectOwners: Gen[List[ProjectOwner]] = Gen
-        .nonEmptyListOf(genProjectOwner)
-        .map(_.foldLeft(List.empty[ProjectOwner]) { (acc, a) =>
-            if (acc.exists(_.name === a.name))
-                acc
-            else
-                a :: acc
-        }) // Ensure distinct user names.
-
     val genLabelName: Gen[LabelName] =
         Gen.nonEmptyListOf(Gen.alphaNumChar).map(_.take(LabelName.MaxLength).mkString).map(LabelName.apply)
 
@@ -218,8 +196,6 @@
 
     given Arbitrary[Label] = Arbitrary(genLabel)
 
-    val genLabels: Gen[List[Label]] = Gen.nonEmptyListOf(genLabel).map(_.distinct)
-
     val genMilestoneTitle: Gen[MilestoneTitle] =
         Gen.nonEmptyListOf(Gen.alphaNumChar).map(_.take(MilestoneTitle.MaxLength).mkString).map(MilestoneTitle.apply)
 
@@ -237,8 +213,6 @@
 
     given Arbitrary[Milestone] = Arbitrary(genMilestone)
 
-    val genMilestones: Gen[List[Milestone]] = Gen.nonEmptyListOf(genMilestone).map(_.distinct)
-
     val genProjectName: Gen[ProjectName] = Gen
         .nonEmptyListOf(
             Gen.oneOf(
@@ -298,7 +272,4 @@
         } yield Project(owner, name, description, isPrivate)
 
     given Arbitrary[Project] = Arbitrary(genProject)
-
-    val genProjects: Gen[List[Project]] = Gen.nonEmptyListOf(genProject)
-
 }