Search in sources :

Example 16 with SubscriptionDescriptor

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

the class SubscriptionJmsEndpointGeneratorTest method shouldCreateJmsEndpointAnnotatedWithoutPoolConfiguration.

@Test
public void shouldCreateJmsEndpointAnnotatedWithoutPoolConfiguration() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:people.person-added", "people.abc", "people", "EVENT_LISTENER");
    generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties));
    Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "PeopleEventListenerPeoplePersonAddedJmsListener");
    Pool poolAnnotation = clazz.getAnnotation(Pool.class);
    assertThat(poolAnnotation, nullValue());
}
Also used : Pool(org.jboss.ejb3.annotation.Pool) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Example 17 with SubscriptionDescriptor

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

the class SubscriptionJmsEndpointGeneratorTest method shouldCreateJmsClass.

@Test
public void shouldCreateJmsClass() 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));
    File packageDir = new File(outputFolder.getRoot().getAbsolutePath() + BASE_PACKAGE_FOLDER);
    assertThat(asList(packageDir.listFiles()), hasItem(hasProperty("name", equalTo("ContextEventProcessorStructureControllerCommandJmsListener.java"))));
}
Also used : File(java.io.File) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Example 18 with SubscriptionDescriptor

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

the class SubscriptionJmsEndpointGeneratorTest method shouldCreateJmsEndpointImplementingMessageListener.

@Test
public void shouldCreateJmsEndpointImplementingMessageListener() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:somecontext.controller.command", "somecontext.command1", serviceName, componentName);
    generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties));
    Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "ContextEventProcessorSomecontextControllerCommandJmsListener");
    assertThat(clazz.getInterfaces().length, equalTo(1));
    assertThat(clazz.getInterfaces()[0], equalTo(MessageListener.class));
}
Also used : MessageListener(javax.jms.MessageListener) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Example 19 with SubscriptionDescriptor

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

the class SubscriptionJmsEndpointGeneratorTest method shouldCreateJmsEndpointWithAnnotatedInterceptorChainProcessorProperty.

@Test
public void shouldCreateJmsEndpointWithAnnotatedInterceptorChainProcessorProperty() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:somecontext.controller.command", "somecontext.command1", serviceName, componentName);
    generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties));
    Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "ContextEventProcessorSomecontextControllerCommandJmsListener");
    Field chainProcessField = clazz.getDeclaredField(INTERCEPTOR_CHAIN_PROCESSOR);
    assertThat(chainProcessField, not(nullValue()));
    assertThat(chainProcessField.getType(), CoreMatchers.equalTo((InterceptorChainProcessor.class)));
    assertThat(chainProcessField.getAnnotations(), arrayWithSize(1));
    assertThat(chainProcessField.getAnnotation(Inject.class), not(nullValue()));
}
Also used : Inject(javax.inject.Inject) Field(java.lang.reflect.Field) ReflectionUtil.setField(uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.setField) SubscriptionDescriptor(uk.gov.justice.subscription.domain.SubscriptionDescriptor) Test(org.junit.Test)

Example 20 with SubscriptionDescriptor

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

the class SubscriptionJmsEndpointGeneratorTest method shouldCreateAnnotatedControllerCommandEndpointWithQueueAsDestinationType.

@Test
public void shouldCreateAnnotatedControllerCommandEndpointWithQueueAsDestinationType() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:queue:structure.something", "structure.abc", "people", "COMMAND_CONTROLLER");
    generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties));
    Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "PeopleCommandControllerStructureSomethingJmsListener");
    assertThat(clazz.getAnnotation(MessageDriven.class), is(notNullValue()));
    assertThat(clazz.getAnnotation(MessageDriven.class).activationConfig(), hasItemInArray(allOf(propertyName(equalTo("destinationType")), propertyValue(equalTo("javax.jms.Queue")))));
}
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