Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"laminas/laminas-code": "^4",
"jms/serializer": "^3.32",
"laravel/framework": "^9.5.2|^10.0|^11.0|^12.0|^13.0",
"prooph/pdo-event-store": "^1.16.2",
"prooph/pdo-event-store": "^1.16.3",
"psr/log": "^2.0|^3.0",
"queue-interop/queue-interop": "^0.8",
"ramsey/uuid": "^4.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/PdoEventSourcing/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"require": {
"ecotone/dbal": "~1.254.0",
"prooph/pdo-event-store": "^1.16.2"
"prooph/pdo-event-store": "^1.16.3"
},
"require-dev": {
"phpunit/phpunit": "^10.5|^11.0",
Expand Down Expand Up @@ -79,4 +79,4 @@
"wikimedia/composer-merge-plugin": true
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,38 @@ protected function setUp(): void
$this->missingEvent = $connection->fetchAssociative(sprintf('select * from %s where no = ?', $streamName), [2]);
$connection->delete($streamName, ['no' => 2]);

$initialTimestamp = 1712501960;
$initialTimestamp = (new \DateTimeImmutable('now', new \DateTimeZone('UTC')))->getTimestamp();

$metadata = json_decode($connection->fetchOne(sprintf('select metadata from %s where no = ?', $streamName), [1]), true);
$metadata['timestamp'] = $initialTimestamp;
$connection->update($streamName, ['metadata' => json_encode($metadata), 'created_at' => date(DATE_ATOM, $initialTimestamp)], ['no' => 1]);

$metadata = json_decode($connection->fetchOne(sprintf('select metadata from %s where no = ?', $streamName), [3]), true);
$metadata['timestamp'] = $initialTimestamp + 100;
$connection->update($streamName, ['metadata' => json_encode($metadata), 'created_at' => date(DATE_ATOM, $initialTimestamp + 100)], ['no' => 3]);
$metadata['timestamp'] = $initialTimestamp + 10;
$connection->update($streamName, ['metadata' => json_encode($metadata), 'created_at' => date(DATE_ATOM, $initialTimestamp + 10)], ['no' => 3]);

$metadata = json_decode($connection->fetchOne(sprintf('select metadata from %s where no = ?', $streamName), [4]), true);
$metadata['timestamp'] = $initialTimestamp + 200;
$connection->update($streamName, ['metadata' => json_encode($metadata), 'created_at' => date(DATE_ATOM, $initialTimestamp + 200)], ['no' => 4]);
$metadata['timestamp'] = $initialTimestamp + 20;
$connection->update($streamName, ['metadata' => json_encode($metadata), 'created_at' => date(DATE_ATOM, $initialTimestamp + 20)], ['no' => 4]);
}

public function test_detecting_gaps_without_detection_window(): void
{
$gapDetection = new GapDetection([10, 20, 50]);
$gapDetection = new GapDetection([0]);

$ecotone = $this->bootstrapEcotoneWithGapDetection($gapDetection);
$ecotone->initializeProjection(InProgressTicketList::IN_PROGRESS_TICKET_PROJECTION);
$ecotone->run(InProgressTicketList::IN_PROGRESS_TICKET_PROJECTION);

self::assertEquals([
['ticket_id' => '123', 'ticket_type' => 'alert'],
['ticket_id' => '124', 'ticket_type' => 'alert'],
['ticket_id' => '125', 'ticket_type' => 'warning'],
], $ecotone->sendQueryWithRouting('getInProgressTickets'));

$this->addMissingEvent();

$ecotone->resetProjection(InProgressTicketList::IN_PROGRESS_TICKET_PROJECTION);
$ecotone->run(InProgressTicketList::IN_PROGRESS_TICKET_PROJECTION);

self::assertEquals([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Integration;
namespace Test\Ecotone\EventSourcing\Integration;

use Doctrine\DBAL\Connection;
use Ecotone\Dbal\Configuration\DbalConfiguration;
Expand Down Expand Up @@ -54,35 +54,37 @@ protected function setUp(): void
$this->missingEvent = $connection->fetchAssociative(sprintf('select * from %s where no = ?', $streamName), [2]);
$connection->delete($streamName, ['no' => 2]);

$initialTimestamp = 1712501960;
$initialTimestamp = time();

$metadata = json_decode($connection->fetchOne(sprintf('select metadata from %s where no = ?', $streamName), [1]), true);
$metadata['timestamp'] = $initialTimestamp;
$connection->update($streamName, ['metadata' => json_encode($metadata), 'created_at' => date(DATE_ATOM, $initialTimestamp)], ['no' => 1]);

$metadata = json_decode($connection->fetchOne(sprintf('select metadata from %s where no = ?', $streamName), [3]), true);
$metadata['timestamp'] = $initialTimestamp + 100;
$connection->update($streamName, ['metadata' => json_encode($metadata), 'created_at' => date(DATE_ATOM, $initialTimestamp + 100)], ['no' => 3]);
$metadata['timestamp'] = $initialTimestamp + 10;
$connection->update($streamName, ['metadata' => json_encode($metadata), 'created_at' => date(DATE_ATOM, $initialTimestamp + 10)], ['no' => 3]);

$metadata = json_decode($connection->fetchOne(sprintf('select metadata from %s where no = ?', $streamName), [4]), true);
$metadata['timestamp'] = $initialTimestamp + 200;
$connection->update($streamName, ['metadata' => json_encode($metadata), 'created_at' => date(DATE_ATOM, $initialTimestamp + 200)], ['no' => 4]);
$metadata['timestamp'] = $initialTimestamp + 20;
$connection->update($streamName, ['metadata' => json_encode($metadata), 'created_at' => date(DATE_ATOM, $initialTimestamp + 20)], ['no' => 4]);
}

public function test_detecting_gaps_without_detection_window(): void
{
$ecotone = $this->bootstrapEcotoneWithGapDetection(new GapDetection([10, 20, 50], null));
$ecotone = $this->bootstrapEcotoneWithGapDetection(new GapDetection([0], null));
$ecotone->sendCommand(new CloseTicket('124'));

self::assertEquals(
[
['ticket_id' => '123', 'ticket_type' => 'alert'],
['ticket_id' => '125', 'ticket_type' => 'warning'],
],
$ecotone->sendQueryWithRouting('getInProgressTickets')
);

$this->addMissingEvent();

$ecotone->resetProjection(InProgressTicketList::IN_PROGRESS_TICKET_PROJECTION);
$ecotone->triggerProjection(InProgressTicketList::IN_PROGRESS_TICKET_PROJECTION);

self::assertEquals(
Expand All @@ -95,7 +97,7 @@ public function test_detecting_gaps_without_detection_window(): void

public function test_detecting_gaps_with_detection_window(): void
{
$ecotone = $this->bootstrapEcotoneWithGapDetection(new GapDetection([10, 20, 50], new DateInterval('PT10S')));
$ecotone = $this->bootstrapEcotoneWithGapDetection(new GapDetection([0], new DateInterval('PT1S')));
$ecotone->sendCommand(new CloseTicket('124'));

self::assertEquals(
Expand Down
Loading