Search in sources :

Example 6 with GeneratorPropertiesFactory

use of uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory in project microservice_framework by CJSCommonPlatform.

the class SubscriptionJmsEndpointGeneratorTest method shouldCreateJmsEndpointAnnotatedWithCommandHandlerAdapter.

@Test
public void shouldCreateJmsEndpointAnnotatedWithCommandHandlerAdapter() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:people.some.queue", "people.abc", "abc", "COMMAND_HANDLER");
    generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, new GeneratorPropertiesFactory().withServiceComponentOf(COMMAND_HANDLER)));
    Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "AbcCommandHandlerPeopleSomeQueueJmsListener");
    Adapter adapterAnnotation = clazz.getAnnotation(Adapter.class);
    assertThat(adapterAnnotation, not(nullValue()));
    assertThat(adapterAnnotation.value(), is(COMMAND_HANDLER));
}
Also used : GeneratorPropertiesFactory(uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory) Adapter(uk.gov.justice.services.core.annotation.Adapter) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Example 7 with GeneratorPropertiesFactory

use of uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory in project microservice_framework by CJSCommonPlatform.

the class SubscriptionJmsEndpointGeneratorTest method shouldCreateJmsEndpointAnnotatedWithCustomEventListenerAdapter.

@Test
public void shouldCreateJmsEndpointAnnotatedWithCustomEventListenerAdapter() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:people.event", "people.abc", "custom", "CUSTOM_EVENT_LISTENER");
    generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, new GeneratorPropertiesFactory().withServiceComponentOf("CUSTOM_EVENT_LISTENER")));
    Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "CustomCustomEventListenerPeopleEventJmsListener");
    Adapter adapterAnnotation = clazz.getAnnotation(Adapter.class);
    assertThat(adapterAnnotation, not(nullValue()));
    assertThat(adapterAnnotation.value(), is("CUSTOM_EVENT_LISTENER"));
    final Class<?> customEventFilterInterceptor = compiler.compiledClassOf(BASE_PACKAGE, "CustomCustomEventListenerPeopleEventEventFilterInterceptor");
    final Field eventFilter = customEventFilterInterceptor.getDeclaredField("eventFilter");
    final Class<?> customEventFilterClass = eventFilter.getType();
    assertThat(customEventFilterClass.getName(), is("uk.test.CustomCustomEventListenerPeopleEventEventFilter"));
}
Also used : Field(java.lang.reflect.Field) ReflectionUtil.setField(uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.setField) GeneratorPropertiesFactory(uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory) Adapter(uk.gov.justice.services.core.annotation.Adapter) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Example 8 with GeneratorPropertiesFactory

use of uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory 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 9 with GeneratorPropertiesFactory

use of uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory 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));
}
Also used : GeneratorPropertiesFactory(uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory) Adapter(uk.gov.justice.services.core.annotation.Adapter) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Example 10 with GeneratorPropertiesFactory

use of uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory in project microservice_framework by CJSCommonPlatform.

the class SubscriptionJmsEndpointGeneratorTest method shouldCreateJmsEndpointAnnotatedWithEventListenerAdapter.

@Test
public void shouldCreateJmsEndpointAnnotatedWithEventListenerAdapter() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:people.event", "people.abc", "people", "EVENT_LISTENER");
    generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, new GeneratorPropertiesFactory().withServiceComponentOf(EVENT_LISTENER)));
    Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "PeopleEventListenerPeopleEventJmsListener");
    Adapter adapterAnnotation = clazz.getAnnotation(Adapter.class);
    assertThat(adapterAnnotation, not(nullValue()));
    assertThat(adapterAnnotation.value(), is(Component.EVENT_LISTENER));
}
Also used : GeneratorPropertiesFactory(uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory) Adapter(uk.gov.justice.services.core.annotation.Adapter) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Aggregations

GeneratorPropertiesFactory (uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory)12 Test (org.junit.Test)11 SubscriptionDescriptor (uk.gov.justice.subscription.domain.SubscriptionDescriptor)11 Adapter (uk.gov.justice.services.core.annotation.Adapter)5 TypeSpec (com.squareup.javapoet.TypeSpec)3 GeneratorProperties (uk.gov.justice.maven.generator.io.files.parser.core.GeneratorProperties)3 CommonGeneratorProperties (uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties)3 Event (uk.gov.justice.subscription.domain.Event)3 Subscription (uk.gov.justice.subscription.domain.Subscription)3 MessageDriven (javax.ejb.MessageDriven)2 Field (java.lang.reflect.Field)1 ActivationConfigProperty (javax.ejb.ActivationConfigProperty)1 Pool (org.jboss.ejb3.annotation.Pool)1 Before (org.junit.Before)1 JavaCompilerUtil (uk.gov.justice.services.test.utils.core.compiler.JavaCompilerUtil)1 ReflectionUtil.setField (uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.setField)1