Testing events generated from PersistentEntity event streams

I would like to test the code which handles events from my persistent entity as seen here:

    TopicProducer.singleStreamWithOffset { fromOffset =>
      persistentEntityRegistry
        .eventStream(TicketEvent.Tag, fromOffset)
        .filter(_.event.isInstanceOf[TicketsCreated])
        .mapAsync(4) {
          case EventStreamElement(id, TicketsCreated(_, _), offset) =>
            // I would like to test this code
            generateTicketPdfs
              .invoke(OrderId(UUID.fromString(id)))
              .map(_ => TicketsCreatedMessage -> offset)
        }
    }

Is there some support in a test utils library which I can re-use?
I would also like to test retry/error handling behaviour when the generateTicketPdfs function fails.

I am now testing this code via a “full service test” cos I havent found another way todo it.
So I am interacting with the persistent entity to let it trigger/persist the necessary events.

Hi @leozilla,

in order to test the code in:

 // I would like to test this code
            generateTicketPdfs
              .invoke(OrderId(UUID.fromString(id)))
              .map(_ => TicketsCreatedMessage -> offset)

I’d suggest you extracted that to a separated method.

But it looks like generateTicketPdfs is a call to a remote service. If that’s the case, then your only choice is to mock the remote service since Lagom doesn’t support integration (multi-service) tests.

Cheers,