use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldCreateAnnotatedCommandControllerEndpointWithDestinationLookupProperty2.
@Test
public void shouldCreateAnnotatedCommandControllerEndpointWithDestinationLookupProperty2() throws Exception {
SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:structure.controller.command", "my-context.events.something-happened", serviceName, componentName);
generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties));
Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "ContextEventProcessorStructureControllerCommandJmsListener");
assertThat(clazz.getAnnotation(MessageDriven.class), is(notNullValue()));
assertThat(clazz.getAnnotation(MessageDriven.class).activationConfig(), hasItemInArray(allOf(propertyName(equalTo("destinationLookup")), propertyValue(equalTo("structure.controller.command")))));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldCreateJmsEndpointAnnotatedWithEventProcessorAdapter.
@Test
public void shouldCreateJmsEndpointAnnotatedWithEventProcessorAdapter() throws Exception {
SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:people.event", "people.abc", "people", componentName);
generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, new GeneratorPropertiesFactory().withServiceComponentOf(EVENT_PROCESSOR)));
Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "PeopleEventProcessorPeopleEventJmsListener");
Adapter adapterAnnotation = clazz.getAnnotation(Adapter.class);
assertThat(adapterAnnotation, not(nullValue()));
assertThat(adapterAnnotation.value(), is(Component.EVENT_PROCESSOR));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldCreateClassContainsHyphens.
@Test
public void shouldCreateClassContainsHyphens() throws Exception {
SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:structure.event", "some event", "context-with-hyphens", componentName);
generator.run(subscriptionDescriptor, configurationWithBasePackage("uk.somepackage", outputFolder, generatorProperties));
Class<?> compiledClass = compiler.compiledClassOf("uk.somepackage", "ContextWithHyphensEventProcessorStructureEventJmsListener");
assertThat(compiledClass.getName(), is("uk.somepackage.ContextWithHyphensEventProcessorStructureEventJmsListener"));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldCreateAnnotatedJmsEndpointWithMessageSelectorContainingTwoCommand.
@Test
public void shouldCreateAnnotatedJmsEndpointWithMessageSelectorContainingTwoCommand() throws Exception {
String jmsUri = "jms:topic:people.controller.command";
Event event1 = event().withName("people.command1").withSchemaUri("http://justice.gov.uk/json/schemas/domains/example/people.command1.json").build();
Event event2 = event().withName("people.command2").withSchemaUri("http://justice.gov.uk/json/schemas/domains/example/people.command2.json").build();
Subscription subscription = subscription().withName("subscription").withEvent(event1).withEventsource(eventsource().withName("eventsource").withLocation(location().withJmsUri(jmsUri).withRestUri("http://localhost:8080/example/event-source-api/rest").build()).build()).build();
subscription.getEvents().add(event2);
SubscriptionDescriptor subscriptionDescriptor = subscriptionDescriptor().withSpecVersion("1.0.0").withService(serviceName).withServiceComponent(componentName).withSubscription(subscription).build();
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("messageSelector")), propertyValue(startsWith("CPPNAME in")), propertyValue(allOf(containsString("'people.command1'"), containsString("'people.command2'"))))));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldCreateJmsEventProcessorNamedAfterDestinationNameAndContextName.
@Test
public void shouldCreateJmsEventProcessorNamedAfterDestinationNameAndContextName() throws Exception {
SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:structure.event", "some event", "context", componentName);
generator.run(subscriptionDescriptor, configurationWithBasePackage("uk.somepackage", outputFolder, generatorProperties));
Class<?> compiledClass = compiler.compiledClassOf("uk.somepackage", "ContextEventProcessorStructureEventJmsListener");
assertThat(compiledClass.getName(), is("uk.somepackage.ContextEventProcessorStructureEventJmsListener"));
}
Aggregations