Skip to content

Commit

Permalink
Fix spying channels + adjust quickstart naming (#328)
Browse files Browse the repository at this point in the history
* Fix spying channels + adjust quickstart naming

* fixes

* fix flaky test
  • Loading branch information
dgafka authored Jun 30, 2024
1 parent ca6a315 commit 713d1ee
Show file tree
Hide file tree
Showing 41 changed files with 79 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,14 @@ public function prepare(Configuration $messagingConfiguration, array $extensionO
foreach ($this->spiedChannels as $spiedChannel) {
$messagingConfiguration->registerDefaultChannelFor(SimpleMessageChannelBuilder::createPublishSubscribeChannel($spiedChannel));
}
foreach (array_unique(array_merge($testConfiguration->getSpiedChannels(), $this->spiedChannels)) as $spiedChannel) {
$spiedChannels = array_unique(array_merge($testConfiguration->getSpiedChannels(), $this->spiedChannels));
foreach ($spiedChannels as $spiedChannel) {
$messagingConfiguration
->registerChannelInterceptor(new SpiedChannelAdapterBuilder($spiedChannel));
}

if ($spiedChannels) {
$messagingConfiguration
->registerChannelInterceptor(new SpiedChannelAdapterBuilder($spiedChannel))
->registerMessageHandler(ServiceActivatorBuilder::create(
MessageCollectorHandler::class,
self::GET_SPIED_CHANNEL_RECORDED_MESSAGE_PAYLOADS
Expand Down
33 changes: 33 additions & 0 deletions packages/Ecotone/tests/Lite/EcotoneLiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Test\Ecotone\Lite;

use Ecotone\Lite\EcotoneLite;
use Ecotone\Lite\Test\TestConfiguration;
use Ecotone\Messaging\Channel\SimpleMessageChannelBuilder;
use Ecotone\Messaging\Config\ModulePackageList;
use Ecotone\Messaging\Config\ServiceConfiguration;
use PHPUnit\Framework\TestCase;
Expand All @@ -27,4 +29,35 @@ public function test_it_can_run_console_command(): void
$ecotone->runConsoleCommand('ecotone:list', []);
$this->expectNotToPerformAssertions();
}

public function test_with_spying_on_multiple_channels(): void
{
$ecotoneLite = EcotoneLite::bootstrapFlowTesting(
[],
[],
enableAsynchronousProcessing: [
SimpleMessageChannelBuilder::createQueueChannel('async1'),
SimpleMessageChannelBuilder::createQueueChannel('async2'),
],
testConfiguration: TestConfiguration::createWithDefaults()
->withSpyOnChannel('async1')
->withSpyOnChannel('async2')
);

$ecotoneLite->sendDirectToChannel('async1', 'test1');
$ecotoneLite->sendDirectToChannel('async2', 'test2');

$this->assertEquals(
[
'test1'
],
$ecotoneLite->getRecordedMessagePayloadsFrom('async1')
);
$this->assertEquals(
[
'test2'
],
$ecotoneLite->getRecordedMessagePayloadsFrom('async2')
);
}
}
2 changes: 1 addition & 1 deletion quickstart-examples/Asynchronous/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/BuildingBlocks/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/CQRS/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/ConsoleCommand/Laravel/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/ConsoleCommand/Symfony/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/Conversion/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "lendable-playground",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/ErrorHandling/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "workshop",
"name": "ecotone/quickstart",
"license": "MIT",
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/EventHandling/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/EventSourcing/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/Microservices/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/MicroservicesAdvanced/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getRegisteredProducts(): array
{
return DB::connection()->getDoctrineConnection()->fetchFirstColumn(
sprintf(<<<SQL
SELECT name FROM %s ORDER BY registered_at DESC
SELECT name FROM %s ORDER BY name ASC
SQL, self::TABLE_NAME));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getRegisteredProducts(#[MultiTenantConnection] Connection $conne
{
return $connection->fetchFirstColumn(
sprintf(<<<SQL
SELECT name FROM %s ORDER BY registered_at DESC
SELECT name FROM %s ORDER BY name ASC
SQL, self::TABLE_NAME));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/OutboxPattern/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/RefactorToReactiveSystem/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/Schedule/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/StatefulProjection/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "lendable-playground",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/Testing/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion quickstart-examples/Workflows/Saga/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "ecotone-quickstart",
"name": "ecotone/quickstart",
"license": "MIT",
"authors": [
{
Expand Down

0 comments on commit 713d1ee

Please sign in to comment.