ecotone-dev icon indicating copy to clipboard operation
ecotone-dev copied to clipboard

Different behavior: Real EventStore vs. InMemoryEventStore

Open davchs opened this issue 2 years ago • 0 comments

Ecotone version(s) affected: 1.88.2

Description
Inside my controlle when i send a command with the same aggregate identifier twice it will throw an ConcurrencyException. But in my test the behaviour is different no Exception will be thrown.

How to reproduce

Test:

public function testCanNotCreateTicketWithAnExistingId(): void
    {
        // assert
        $this->expectException(ConcurrencyException::class);
        // arrange
        $ticketId = Uuid::uuid4();
        $userId = Uuid::uuid4();
        $priority = Priority::createMediumPriority();
        // act
        $tickets = $this->getEcotoneLite()
            ->sendCommand(new CreateTicket($ticketId, $userId, $priority))
            ->sendCommand(new CreateTicket($ticketId, $userId, $priority));
    }

    private function getEcotoneLite(): FlowTestSupport
    {
        return EcotoneLite::bootstrapFlowTestingWithEventStore(
            [Ticket::class],
            [new UuidConverter(), new PriorityConverter()],
            configuration: ServiceConfiguration::createWithDefaults()
                ->withNamespaces(['App\Helpdesk\Infrastructure\Converter'])
                ->withExtensionObjects([InMemoryEventSourcedRepository::createEmpty()])
        );
    }
   

Controller:

  #[Route(path: '/create-ticket/{id}', name: 'create-ticket')]
    public function __invoke(string $id): JsonResponse
    {
        $priority = Priority::createLowPriority();
        $this->commandBus->send(new CreateTicket(Uuid::fromString($id), Uuid::uuid4(), $priority));

        return new JsonResponse(['uuid' => (string)$ticketId]);
    }
    

davchs avatar Jun 24 '23 14:06 davchs