Skip to content

Commit

Permalink
Push test metadata upon entity deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
MKodde committed Jul 5, 2023
1 parent bac9671 commit ae2325f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
use Surfnet\ServiceProviderDashboard\Application\Exception\EntityNotDeletedException;
use Surfnet\ServiceProviderDashboard\Application\Exception\UnableToDeleteEntityException;
use Surfnet\ServiceProviderDashboard\Domain\Repository\DeleteManageEntityRepository;
use Surfnet\ServiceProviderDashboard\Domain\Repository\PublishEntityRepository;

class DeletePublishedTestEntityCommandHandler implements CommandHandler
{
public function __construct(
private readonly DeleteManageEntityRepository $deleteEntityRepository,
private readonly PublishEntityRepository $publishClient,
private readonly LoggerInterface $logger
) {
}
Expand Down Expand Up @@ -56,7 +58,10 @@ public function handle(DeletePublishedTestEntityCommand $command)
}

if ($response !== DeleteManageEntityRepository::RESULT_SUCCESS) {
throw new EntityNotDeletedException('Deleting the entity yielded an non success response');
throw new EntityNotDeletedException('Deleting the entity yielded a non success response');
}

// Push metadata to EngineBlock and other listeners nudging them to update their indexed entity metadata
$this->publishClient->pushMetadata();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ services:
class: Surfnet\ServiceProviderDashboard\Application\CommandHandler\Entity\DeletePublishedTestEntityCommandHandler
arguments:
- '@surfnet.manage.client.delete_client.test_environment'
- '@Surfnet\ServiceProviderDashboard\Infrastructure\Manage\Client\PublishEntityClient'
public: true
tags:
- { name: tactician.handler, command: Surfnet\ServiceProviderDashboard\Application\Command\Entity\DeletePublishedTestEntityCommand }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Surfnet\ServiceProviderDashboard\Application\Exception\UnableToDeleteEntityException;
use Surfnet\ServiceProviderDashboard\Domain\Entity\Constants;
use Surfnet\ServiceProviderDashboard\Domain\Repository\DeleteManageEntityRepository;
use Surfnet\ServiceProviderDashboard\Domain\Repository\PublishEntityRepository;

class DeletePublishedTestEntityCommandHandlerTest extends MockeryTestCase
{
Expand All @@ -42,18 +43,23 @@ class DeletePublishedTestEntityCommandHandlerTest extends MockeryTestCase
private $repository;

/**
* @var LoggerInterface|Mock
* @var LoggerInterface&Mock
*/
private $logger;

private PublishEntityRepository $publishClient;

public function setUp(): void
{
$this->repository = m::mock(DeleteManageEntityRepository::class);

$this->logger = m::mock(LoggerInterface::class);

$this->publishClient = m::mock(PublishEntityRepository::class);

$this->commandHandler = new DeletePublishedTestEntityCommandHandler(
$this->repository,
$this->publishClient,
$this->logger
);
}
Expand All @@ -62,6 +68,10 @@ public function test_it_can_delete_an_entity_from_test()
{
$command = new DeletePublishedTestEntityCommand('d6f394b2-08b1-4882-8b32-81688c15c489', Constants::TYPE_SAML);

$this->publishClient
->shouldReceive('pushMetadata')
->once();

$this->repository
->shouldReceive('delete')
->with('d6f394b2-08b1-4882-8b32-81688c15c489', Constants::TYPE_SAML)
Expand Down

0 comments on commit ae2325f

Please sign in to comment.