use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldCreateJmsEndpointInADifferentPackage.
@Test
public void shouldCreateJmsEndpointInADifferentPackage() throws Exception {
SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:structure.controller.command", "my-context.events.something-happened", serviceName, componentName);
generator.run(subscriptionDescriptor, configurationWithBasePackage("uk.package2", outputFolder, generatorProperties));
Class<?> clazz = compiler.compiledClassOf("uk.package2", "ContextEventProcessorStructureControllerCommandJmsListener");
assertThat(clazz.getName(), is("uk.package2.ContextEventProcessorStructureControllerCommandJmsListener"));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldCreateAnnotatedJmsEndpointWithMessageSelectorContainingOneEvent_PluralPillarName.
@Test
public void shouldCreateAnnotatedJmsEndpointWithMessageSelectorContainingOneEvent_PluralPillarName() throws Exception {
SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:structure.event", "structure.events.test-event", serviceName, componentName);
generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties));
Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "ContextEventProcessorStructureEventJmsListener");
assertThat(clazz.getAnnotation(MessageDriven.class), is(notNullValue()));
assertThat(clazz.getAnnotation(MessageDriven.class).activationConfig(), hasItemInArray(allOf(propertyName(equalTo("messageSelector")), propertyValue(equalTo("CPPNAME in('structure.events.test-event')")))));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGenerator method run.
/**
* Generates JMS endpoint classes from a SubscriptionDescriptorDef document.
*
* @param subscriptionDescriptor the subscriptionDescriptor document
* @param configuration contains package of generated sources, as well as source and destination
* folders
*/
@Override
public void run(final SubscriptionDescriptor subscriptionDescriptor, final GeneratorConfig configuration) {
final CommonGeneratorProperties commonGeneratorProperties = (CommonGeneratorProperties) configuration.getGeneratorProperties();
final String basePackageName = configuration.getBasePackageName();
final List<Subscription> subscriptions = subscriptionDescriptor.getSubscriptions();
subscriptions.stream().flatMap(subscription -> generatedClassesFrom(subscriptionDescriptor, subscription, commonGeneratorProperties, basePackageName)).forEach(generatedClass -> writeClass(configuration, basePackageName, generatedClass, LOGGER));
final List<Event> allEvents = subscriptions.stream().map(Subscription::getEvents).flatMap(Collection::stream).collect(toList());
final String contextName = subscriptionDescriptor.getService();
final String componentName = subscriptionDescriptor.getServiceComponent();
subscriptionMediaTypeToSchemaIdGenerator.generateMediaTypeToSchemaIdMapper(contextName, componentName, allEvents, configuration);
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class RamlToJmsSubscriptionConverter method convert.
public SubscriptionDescriptorDef convert(final Raml raml, final String componentName) {
final String baseUri = raml.getBaseUri();
final String service = subscriptionNamesGenerator.createContextNameFrom(baseUri);
final List<Subscription> subscriptions = resourcesListToSubscriptionListConverter.getSubscriptions(raml.getResources().values());
final SubscriptionDescriptor subscriptionDescriptor = new SubscriptionDescriptor(SUBSCRIPTION_SPEC_VERSION, service, componentName, subscriptions);
return new SubscriptionDescriptorDef(subscriptionDescriptor);
}
Aggregations