Search in sources :

Example 1 with Adapter

use of uk.gov.justice.services.core.annotation.Adapter 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 2 with Adapter

use of uk.gov.justice.services.core.annotation.Adapter 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 3 with Adapter

use of uk.gov.justice.services.core.annotation.Adapter 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 4 with Adapter

use of uk.gov.justice.services.core.annotation.Adapter 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)

Example 5 with Adapter

use of uk.gov.justice.services.core.annotation.Adapter in project microservice_framework by CJSCommonPlatform.

the class SubscriptionJmsEndpointGeneratorTest method shouldCreateJmsEndpointAnnotatedWithControllerCommandAdapter.

@Test
public void shouldCreateJmsEndpointAnnotatedWithControllerCommandAdapter() throws Exception {
    SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:people.some.query", "people.abc", "abc", "COMMAND_CONTROLLER");
    generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, new GeneratorPropertiesFactory().withServiceComponentOf(COMMAND_CONTROLLER)));
    Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "AbcCommandControllerPeopleSomeQueryJmsListener");
    Adapter adapterAnnotation = clazz.getAnnotation(Adapter.class);
    assertThat(adapterAnnotation, not(nullValue()));
    assertThat(adapterAnnotation.value(), is(COMMAND_CONTROLLER));
}
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

Test (org.junit.Test)5 GeneratorPropertiesFactory (uk.gov.justice.raml.jms.config.GeneratorPropertiesFactory)5 Adapter (uk.gov.justice.services.core.annotation.Adapter)5 SubscriptionDescriptor (uk.gov.justice.subscription.domain.SubscriptionDescriptor)5 Field (java.lang.reflect.Field)1 ReflectionUtil.setField (uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.setField)1