Fix tests

This commit is contained in:
Paul-Henri Froidmont 2025-10-13 15:46:22 +02:00
parent efdc50eb1d
commit 87bd780f9f
Signed by: phfroidmont
GPG key ID: BE948AFD7E7873BE
34 changed files with 230 additions and 303 deletions

View file

@ -2,16 +2,6 @@ package lu.foyer
package contracts
import zio.*
import zio.Console.*
import zio.http.*
import zio.http.codec.*
import zio.http.codec.PathCodec.path
import zio.http.endpoint.*
import zio.schema.*
import java.net.URI
import java.time.LocalDate
import java.util.UUID
class ContractController(
val commandEngine: CommandEngine[ContractCommand, ContractEvent, ContractState])

View file

@ -1,22 +1,21 @@
package lu.foyer
package contracts
import java.util.UUID
import zio.*
class ContractEventRepositoryInMemory(events: Ref[Map[UUID, Event[ContractEvent]]])
class ContractEventRepositoryInMemory(events: Ref[Map[String, Event[ContractEvent]]])
extends EventRepository[ContractEvent]
with InMemoryRepository[Event[ContractEvent]](events):
def fetchOne(entityId: UUID, eventId: UUID): Task[Option[Event[ContractEvent]]] =
def fetchOne(entityId: String, eventId: String): Task[Option[Event[ContractEvent]]] =
events.get.map(_.get(eventId))
def fetchMany(entityId: UUID, page: Page): Task[Paged[Event[ContractEvent]]] =
def fetchMany(entityId: String, page: Page): Task[Paged[Event[ContractEvent]]] =
events.get
.map(entities =>
val items = entities.values
.filter(_.entityId == entityId)
.drop(page.number.getOrElse(0) * page.size.getOrElse(50))
.take(page.size.getOrElse(50))
Paged(items.toList, if page.totals.getOrElse(false) then Some(entities.size) else None)
Paged(items.toList, if page.totals.getOrElse(true) then Some(entities.size) else None)
)
object ContractEventRepositoryInMemory:

View file

@ -1,10 +1,9 @@
package lu.foyer
package contracts
import java.util.UUID
import zio.*
class ContractStateRepositoryInMemory(clients: Ref[Map[UUID, Entity[ContractState]]])
class ContractStateRepositoryInMemory(clients: Ref[Map[String, Entity[ContractState]]])
extends StateRepository[ContractState]
with InMemoryRepository[Entity[ContractState]](clients)

View file

@ -1,12 +1,7 @@
package lu.foyer
package contracts
import java.util.UUID
import zio.*
import lu.foyer.clients.Address
import scala.math.BigDecimal.RoundingMode
import java.util.Currency
import lu.foyer.clients.Country
object EmployeeServiceImpl extends EmployeeService:

View file

@ -1,11 +1,12 @@
package lu.foyer
package contracts
import java.util.UUID
import zio.*
import lu.foyer.clients.Address
import scala.math.BigDecimal.RoundingMode
import java.util.Currency
import scala.math.BigDecimal.RoundingMode
import zio.*
import lu.foyer.clients.Address
import lu.foyer.clients.Country
object PremiumServiceImpl extends PremiumService: