use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldCreateAnnotatedCommandControllerEndpointWithDestinationLookupProperty.
@Test
public void shouldCreateAnnotatedCommandControllerEndpointWithDestinationLookupProperty() throws Exception {
SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:people.controller.command", "people.abc", serviceName, "EVENT_PROCESSOR");
generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties));
Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "ContextEventProcessorPeopleControllerCommandJmsListener");
assertThat(clazz.getAnnotation(MessageDriven.class), is(notNullValue()));
assertThat(clazz.getAnnotation(MessageDriven.class).activationConfig(), hasItemInArray(allOf(propertyName(equalTo("destinationLookup")), propertyValue(equalTo("people.controller.command")))));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldNotAddMessageSelectorForEventListener.
@Test
public void shouldNotAddMessageSelectorForEventListener() throws Exception {
SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:structure.event", "structure.test-event", serviceName, "EVENT_LISTENER");
generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties));
Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "ContextEventListenerStructureEventJmsListener");
assertThat(clazz.getAnnotation(MessageDriven.class), is(notNullValue()));
assertThat(clazz.getAnnotation(MessageDriven.class).activationConfig(), not(hasItemInArray(propertyName(equalTo("messageSelector")))));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionDescriptorFileParserTest method shouldParseEverySubsctiptionYamlFileIntoASubscriptionDescriptor.
@Test
public void shouldParseEverySubsctiptionYamlFileIntoASubscriptionDescriptor() throws Exception {
final Path baseDir = mock(Path.class, RETURNS_DEEP_STUBS.get());
final Path subscriptionFile_1 = mock(Path.class);
final Path subscriptionFile_2 = mock(Path.class);
final Path filePath_1 = mock(Path.class);
final Path filePath_2 = mock(Path.class);
final SubscriptionDescriptor subscriptionDescriptor_1 = mock(SubscriptionDescriptor.class);
final SubscriptionDescriptor subscriptionDescriptor_2 = mock(SubscriptionDescriptor.class);
when(baseDir.resolve(subscriptionFile_1).toAbsolutePath()).thenReturn(filePath_1);
when(baseDir.resolve(subscriptionFile_2).toAbsolutePath()).thenReturn(filePath_2);
when(subscriptionDescriptorParser.read(filePath_1)).thenReturn(subscriptionDescriptor_1);
when(subscriptionDescriptorParser.read(filePath_2)).thenReturn(subscriptionDescriptor_2);
final Collection<SubscriptionDescriptor> subscriptionDescriptors = subscriptionDescriptorFileParser.parse(baseDir, asList(subscriptionFile_1, subscriptionFile_2));
assertThat(subscriptionDescriptors.size(), is(2));
assertThat(subscriptionDescriptors, hasItem(subscriptionDescriptor_1));
assertThat(subscriptionDescriptors, hasItem(subscriptionDescriptor_2));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class RamlToJmsSubscriptionConverterTest method shouldCreateASchemaObjectFromARamlObject.
@SuppressWarnings("unchecked")
@Test
public void shouldCreateASchemaObjectFromARamlObject() throws Exception {
final String componentName = "EVENT_LISTENER";
final String contextName = "people";
final String baseUri = "message://command/handler/message/people";
final Raml raml = mock(Raml.class, RETURNS_DEEP_STUBS.get());
final Resource resource_1 = mock(Resource.class);
final Resource resource_2 = mock(Resource.class);
final Resource resource_3 = mock(Resource.class);
final Subscription subscription_1 = mock(Subscription.class);
final Subscription subscription_2 = mock(Subscription.class);
final Subscription subscription_3 = mock(Subscription.class);
final List<Subscription> subscriptions = asList(subscription_1, subscription_2, subscription_3);
when(raml.getBaseUri()).thenReturn(baseUri);
when(subscriptionNamesGenerator.createContextNameFrom(baseUri)).thenReturn(contextName);
when(raml.getResources().values()).thenReturn(asList(resource_1, resource_2, resource_3));
when(resourcesListToSubscriptionListConverter.getSubscriptions(raml.getResources().values())).thenReturn(subscriptions);
final SubscriptionDescriptorDef subscriptionDescriptorDef = ramlToJmsSubscriptionConverter.convert(raml, componentName);
final SubscriptionDescriptor subscriptionDescriptor = subscriptionDescriptorDef.getSubscriptionDescriptor();
assertThat(subscriptionDescriptor.getSpecVersion(), is("1.0.0"));
assertThat(subscriptionDescriptor.getService(), is(contextName));
assertThat(subscriptionDescriptor.getServiceComponent(), is(componentName));
assertThat(subscriptionDescriptor.getSubscriptions().size(), is(3));
assertThat(subscriptionDescriptor.getSubscriptions(), hasItem(subscription_1));
assertThat(subscriptionDescriptor.getSubscriptions(), hasItem(subscription_2));
assertThat(subscriptionDescriptor.getSubscriptions(), hasItem(subscription_3));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionRegistryProducerTest method shouldCreateARegistryOfAllSubscriptionsFromTheClasspath.
@Test
public void shouldCreateARegistryOfAllSubscriptionsFromTheClasspath() throws Exception {
final Path path_1 = mock(Path.class);
final Path path_2 = mock(Path.class);
final SubscriptionDescriptor subscriptionDescriptor_1 = mock(SubscriptionDescriptor.class);
final SubscriptionDescriptor subscriptionDescriptor_2 = mock(SubscriptionDescriptor.class);
final String service_1 = "service_1";
final String service_2 = "service_2";
when(subscriptionDescriptorFileFinder.findOnClasspath()).thenReturn(asList(path_1, path_2));
when(subscriptionDescriptorParser.read(path_1)).thenReturn(subscriptionDescriptor_1);
when(subscriptionDescriptorParser.read(path_2)).thenReturn(subscriptionDescriptor_2);
when(subscriptionDescriptor_1.getService()).thenReturn(service_1);
when(subscriptionDescriptor_2.getService()).thenReturn(service_2);
final SubscriptionDescriptorRegistry subscriptionDescriptorRegistry = subscriptionRegistryProducer.subscriptionDescriptorRegistry(mock(InjectionPoint.class));
assertThat(subscriptionDescriptorRegistry.getSubscriptionDescriptorFor(service_1), is(of(subscriptionDescriptor_1)));
assertThat(subscriptionDescriptorRegistry.getSubscriptionDescriptorFor(service_2), is(of(subscriptionDescriptor_2)));
}
Aggregations