use of uk.gov.justice.services.eventsourcing.source.core.EventSource in project microservice_framework by CJSCommonPlatform.
the class SubscriptionManagerProducer method subscriptionManager.
@Produces
public SubscriptionManager subscriptionManager(final InjectionPoint injectionPoint) {
final SubscriptionName subscriptionName = subscriptionNameAnnotationExtractor.getFrom(injectionPoint);
final Instance<EventSource> eventSourceInstance = eventsourceInstance.select(subscriptionName);
if (eventSourceInstance != null) {
final EventSource eventSource = eventSourceInstance.get();
final Subscription subscription = subscriptionDescriptorRegistry.getSubscription(subscriptionName.value());
return new SubscriptionManager(subscription, eventSource);
}
throw new SubscriptionManagerProducerException(format("Failed to find instance of event souce with Qualifier '%s'", subscriptionName.value()));
}
use of uk.gov.justice.services.eventsourcing.source.core.EventSource in project microservice_framework by CJSCommonPlatform.
the class SubscriptionManagerProducerTest method shouldCreateSubscriptionManagersOnStartUp.
@Test
public void shouldCreateSubscriptionManagersOnStartUp() throws Exception {
final InjectionPoint injectionPoint = mock(InjectionPoint.class);
final SubscriptionName subscriptionName = mock(SubscriptionName.class);
final EventSource eventSource = mock(EventSource.class);
final Subscription subscription = mock(Subscription.class);
when(subscriptionNameAnnotationExtractor.getFrom(injectionPoint)).thenReturn(subscriptionName);
when(eventsourceInstance.select(subscriptionName).get()).thenReturn(eventSource);
when(subscriptionDescriptorRegistry.getSubscription(subscriptionName.value())).thenReturn(subscription);
final SubscriptionManager subscriptionManager = subscriptionManagerProducer.subscriptionManager(injectionPoint);
assertThat(subscriptionManager.getEventSource(), is(eventSource));
assertThat(subscriptionManager.getSubscription(), is(subscription));
}
Aggregations