Search in sources :

Example 21 with SubscriptionDescriptor

use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.

the class SubscriptionJmsEndpointGeneratorTest method shouldCreateJmsEndpointAnnotatedWithInterceptors.

@Test
public void shouldCreateJmsEndpointAnnotatedWithInterceptors() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:people.handler.command", "people.abc", serviceName, componentName);
    generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties));
    Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "ContextEventProcessorPeopleHandlerCommandJmsListener");
    Interceptors interceptorsAnnotation = clazz.getAnnotation(Interceptors.class);
    assertThat(interceptorsAnnotation, not(nullValue()));
    assertThat(interceptorsAnnotation.value(), hasItemInArray(JsonSchemaValidationInterceptor.class));
    assertThat(interceptorsAnnotation.value(), hasItemInArray(JmsLoggerMetadataInterceptor.class));
}
Also used : Interceptors(javax.interceptor.Interceptors) JsonSchemaValidationInterceptor(uk.gov.justice.services.adapter.messaging.JsonSchemaValidationInterceptor) JmsLoggerMetadataInterceptor(uk.gov.justice.services.adapter.messaging.JmsLoggerMetadataInterceptor) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Example 22 with SubscriptionDescriptor

use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.

the class SubscriptionJmsEndpointGeneratorTest method shouldNotContainDurableSubscriberPropertiesIfItsNotTopic.

@Test
public void shouldNotContainDurableSubscriberPropertiesIfItsNotTopic() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:people.controller.command", "people.event.abc", "people", "COMMAND_CONTROLLER");
    generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties));
    Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "PeopleCommandControllerPeopleControllerCommandJmsListener");
    ActivationConfigProperty[] activationConfig = clazz.getAnnotation(MessageDriven.class).activationConfig();
    assertThat(activationConfig, hasItemInArray(allOf(propertyName(equalTo("destinationType")), propertyValue(equalTo("javax.jms.Queue")))));
    assertThat(activationConfig, not(hasItemInArray(allOf(propertyName(equalTo("clientId")), propertyName(equalTo("subscriptionName")), propertyName(equalTo("subscriptionDurability"))))));
}
Also used : ActivationConfigProperty(javax.ejb.ActivationConfigProperty) MessageDriven(javax.ejb.MessageDriven) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Example 23 with SubscriptionDescriptor

use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.

the class SubscriptionJmsEndpointGeneratorTest method shouldCreateDurableTopicSubscriber.

@Test
public void shouldCreateDurableTopicSubscriber() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:people.event", "context1.event.abc", "people", "EVENT_LISTENER");
    generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, new GeneratorPropertiesFactory().withServiceComponentOf(EVENT_LISTENER)));
    Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "PeopleEventListenerPeopleEventJmsListener");
    ActivationConfigProperty[] activationConfig = clazz.getAnnotation(MessageDriven.class).activationConfig();
    assertThat(activationConfig, hasItemInArray(allOf(propertyName(equalTo("destinationType")), propertyValue(equalTo("javax.jms.Topic")))));
    assertThat(activationConfig, hasItemInArray(allOf(propertyName(equalTo("subscriptionDurability")), propertyValue(equalTo("Durable")))));
    assertThat(activationConfig, hasItemInArray(allOf(propertyName(equalTo("clientId")), propertyValue(equalTo("people.event.listener")))));
    assertThat(activationConfig, hasItemInArray(allOf(propertyName(equalTo("subscriptionName")), propertyValue(equalTo("people.event.listener.people.event")))));
}
Also used : ActivationConfigProperty(javax.ejb.ActivationConfigProperty) GeneratorPropertiesFactory(uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory) MessageDriven(javax.ejb.MessageDriven) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Example 24 with SubscriptionDescriptor

use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.

the class SubscriptionJmsEndpointGeneratorTest method shouldCreateAnnotatedJmsEndpointWithMessageSelectorContainingOneCommandWithAPost.

@Test
public void shouldCreateAnnotatedJmsEndpointWithMessageSelectorContainingOneCommandWithAPost() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:structure.controller.command", "structure.test-cmd", serviceName, "EVENT_PROCESSOR");
    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("messageSelector")), propertyValue(equalTo("CPPNAME in('structure.test-cmd')")))));
}
Also used : MessageDriven(javax.ejb.MessageDriven) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Example 25 with SubscriptionDescriptor

use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.

the class SubscriptionJmsEndpointGeneratorTest method shouldOnlyCreateMessageSelectorForPostActionAndIgnoreAllOtherActions.

@Test
public void shouldOnlyCreateMessageSelectorForPostActionAndIgnoreAllOtherActions() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:structure.controller.command", "structure.test-cmd1", 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("messageSelector")), propertyValue(equalTo("CPPNAME in('structure.test-cmd1')")))));
}
Also used : MessageDriven(javax.ejb.MessageDriven) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Aggregations

SubscriptionDescriptor (uk.gov.justice.subscription.domain.SubscriptionDescriptor)54 Test (org.junit.Test)52 MessageDriven (javax.ejb.MessageDriven)16 Subscription (uk.gov.justice.subscription.domain.Subscription)14 GeneratorPropertiesFactory (uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory)11 Event (uk.gov.justice.subscription.domain.Event)7 TypeSpec (com.squareup.javapoet.TypeSpec)5 Adapter (uk.gov.justice.services.core.annotation.Adapter)5 CommonGeneratorProperties (uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties)5 SubscriptionDescriptorDef (uk.gov.justice.subscription.domain.SubscriptionDescriptorDef)5 Field (java.lang.reflect.Field)4 ReflectionUtil.setField (uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.setField)4 File (java.io.File)3 Path (java.nio.file.Path)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 GeneratorProperties (uk.gov.justice.maven.generator.io.files.parser.core.GeneratorProperties)3 ActivationConfigProperty (javax.ejb.ActivationConfigProperty)2 Inject (javax.inject.Inject)2 Message (javax.jms.Message)2 MessageListener (javax.jms.MessageListener)2