AmqpMessageDispatcherService extends BaseAmqpService { @EventListener(classes = TargetDeletedEvent.class) protected void targetDelete(final TargetDeletedEvent deleteEvent) { if (!shouldBeProcessed(deleteEvent)) { return; } sendDeleteMessage(deleteEvent.getTenant(), deleteEvent.getControllerId(), deleteEvent.getTargetAddress()); } protected  AmqpMessageDispatcherService(final RabbitTemplate rabbitTemplate,
            final AmqpMessageSenderService amqpSenderService, final ArtifactUrlHandler artifactUrlHandler,
            final SystemSecurityContext systemSecurityContext, final SystemManagement systemManagement,
            final TargetManagement targetManagement, final ServiceMatcher serviceMatcher,
            final DistributionSetManagement distributionSetManagement,
            final SoftwareModuleManagement softwareModuleManagement, final DeploymentManagement deploymentManagement);   }
@Test @Description("Verifies that sending a delete message when receiving a delete event works.") public void sendDeleteRequest() { final String amqpUri = "amqp: final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, amqpUri, Target.class.getName(), serviceMatcher.getServiceId()); amqpMessageDispatcherService.targetDelete(targetDeletedEvent); final Message sendMessage = createArgumentCapture(URI.create(amqpUri)); assertDeleteMessage(sendMessage); }
@Test @Description("Verifies that a delete message is not send if the address is not an amqp address.") public void sendDeleteRequestWithNoAmqpAdress() { final String noAmqpUri = "http: final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, noAmqpUri, Target.class.getName(), serviceMatcher.getServiceId()); amqpMessageDispatcherService.targetDelete(targetDeletedEvent); Mockito.verifyZeroInteractions(senderService); }
@Test @Description("Verfies that a delete message is not send if the address is null.") public void sendDeleteRequestWithNullAdress() { final String noAmqpUri = null; final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, noAmqpUri, Target.class.getName(), serviceMatcher.getServiceId()); amqpMessageDispatcherService.targetDelete(targetDeletedEvent); Mockito.verifyZeroInteractions(senderService); }