use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldOverwriteJmsClass.
@Test
public void shouldOverwriteJmsClass() throws Exception {
String path = outputFolder.getRoot().getAbsolutePath() + BASE_PACKAGE_FOLDER;
File packageDir = new File(path);
packageDir.mkdirs();
write(Paths.get(path + "/StructureControllerCommandJmsListener.java"), Collections.singletonList("Old file content"));
SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:structure.controller.command", "my-context.events.something-happened", serviceName, componentName);
generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties));
List<String> lines = Files.readAllLines(Paths.get(path + "/ContextEventProcessorStructureControllerCommandJmsListener.java"));
assertThat(lines.get(0), not(containsString("Old file content")));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldCreateAnnotatedEventListenerEndpointWithSharedSubscriptionsPropertySetToTrue.
@Test
public void shouldCreateAnnotatedEventListenerEndpointWithSharedSubscriptionsPropertySetToTrue() throws Exception {
SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:structure.event", "structure.abc", 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("shareSubscriptions")), propertyValue(equalTo("true")))));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldCreateMultipleJmsClasses.
@SuppressWarnings("unchecked")
@Test
public void shouldCreateMultipleJmsClasses() throws Exception {
String structureJmsUri = "jms:topic:structure.controller.command";
String peopleJmsUri = "jms:topic:people.controller.command";
Event event = event().withName("my-context.events.something-happened").withSchemaUri("http://justice.gov.uk/json/schemas/domains/example/my-context.events.something-happened.json").build();
Subscription subscription = subscription().withName("subscription").withEvent(event).withEventsource(eventsource().withName("eventsource").withLocation(location().withJmsUri(structureJmsUri).withRestUri("http://localhost:8080/example/event-source-api/rest").build()).build()).build();
Subscription subscription2 = subscription().withName("subscription2").withEvent(event).withEventsource(eventsource().withName("eventsource").withLocation(location().withJmsUri(peopleJmsUri).withRestUri("http://localhost:8080/example/event-source-api/rest").build()).build()).build();
SubscriptionDescriptor subscriptionDescriptor = subscriptionDescriptor().withSpecVersion("1.0.0").withService(serviceName).withServiceComponent(componentName).withSubscription(subscription).build();
subscriptionDescriptor.getSubscriptions().add(subscription2);
generator.run(subscriptionDescriptor, configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties));
File packageDir = new File(outputFolder.getRoot().getAbsolutePath() + BASE_PACKAGE_FOLDER);
final File[] a = packageDir.listFiles();
assertThat(asList(a), hasItems(hasProperty("name", equalTo("ContextEventProcessorPeopleControllerCommandJmsListener.java")), hasProperty("name", equalTo("ContextEventProcessorStructureControllerCommandJmsListener.java"))));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGeneratorTest method shouldCreateAnnotatedEventListenerEndpointWithDestinationLookupProperty3.
@Test
public void shouldCreateAnnotatedEventListenerEndpointWithDestinationLookupProperty3() throws Exception {
SubscriptionDescriptor subscriptionDescriptor = setUpMessageSubscription("jms:topic:structure.event", "structure.abc", 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("destinationLookup")), propertyValue(equalTo("structure.event")))));
}
use of uk.gov.justice.subscription.domain.SubscriptionDescriptor 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));
}
Aggregations