use of uk.gov.justice.maven.generator.io.files.parser.core.GeneratorConfig in project microservice_framework by CJSCommonPlatform.
the class JmsEndpointGeneratorTest method shouldConvertRamlToASubscriptionThenRunTheEndpointGenerators.
@Test
public void shouldConvertRamlToASubscriptionThenRunTheEndpointGenerators() throws Exception {
final String serviceComponent = "EVENT_LISTENER";
final Raml raml = mock(Raml.class);
final GeneratorConfig configuration = mock(GeneratorConfig.class);
final CommonGeneratorProperties commonGeneratorProperties = mock(CommonGeneratorProperties.class);
final SubscriptionDescriptorDef subscriptionDescriptorDef = mock(SubscriptionDescriptorDef.class);
final SubscriptionDescriptor subscriptionDescriptor = mock(SubscriptionDescriptor.class);
when(configuration.getGeneratorProperties()).thenReturn(commonGeneratorProperties);
when(commonGeneratorProperties.getServiceComponent()).thenReturn(serviceComponent);
when(ramlToJmsSubscriptionConverter.convert(raml, serviceComponent)).thenReturn(subscriptionDescriptorDef);
when(subscriptionDescriptorDef.getSubscriptionDescriptor()).thenReturn(subscriptionDescriptor);
jmsEndpointGenerator.run(raml, configuration);
final InOrder inOrder = inOrder(ramlValidator, ramlToJmsSubscriptionConverter, subscriptionJmsEndpointGenerator);
inOrder.verify(ramlValidator).validate(raml);
inOrder.verify(ramlToJmsSubscriptionConverter).convert(raml, serviceComponent);
inOrder.verify(subscriptionJmsEndpointGenerator).run(subscriptionDescriptor, configuration);
}
use of uk.gov.justice.maven.generator.io.files.parser.core.GeneratorConfig in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_CodeStructureTest method shouldGenerateInterfaceInSpecifiedPackage.
@Test
public void shouldGenerateInterfaceInSpecifiedPackage() throws Exception {
final String basePackageName = "uk.gov.test1";
java.nio.file.Path outputPath = get(outputFolder.getRoot().getAbsolutePath());
final GeneratorConfig config = new GeneratorConfig(outputPath, outputPath, basePackageName, new CommonGeneratorProperties(), singletonList(outputPath.getParent()));
generator.run(restRamlWithDefaults().with(defaultPostResource()).build(), config);
final Class<?> interfaceClass = compiler.compiledInterfaceOf(basePackageName + ".resource");
assertThat(interfaceClass.getPackage().getName(), is(basePackageName + ".resource"));
}
use of uk.gov.justice.maven.generator.io.files.parser.core.GeneratorConfig in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_CodeStructureTest method shouldGenerateClassInSpecifiedPackage.
@Test
public void shouldGenerateClassInSpecifiedPackage() throws Exception {
final String basePackageName = "uk.gov.test2";
java.nio.file.Path outputPath = get(outputFolder.getRoot().getAbsolutePath());
generator.run(restRamlWithCommandApiDefaults().with(defaultPostResource().withRelativeUri("/some/path")).build(), new GeneratorConfig(outputPath, outputPath, basePackageName, new CommonGeneratorProperties(), singletonList(outputPath.getParent())));
final Class<?> resourceImplementation = compiler.compiledClassOf(basePackageName, "resource", "DefaultCommandApiSomePathResource");
assertThat(resourceImplementation.getPackage().getName(), is(basePackageName + ".resource"));
}
use of uk.gov.justice.maven.generator.io.files.parser.core.GeneratorConfig in project microservice_framework by CJSCommonPlatform.
the class SubscriptionJmsEndpointGenerator method run.
/**
* Generates JMS endpoint classes from a SubscriptionDescriptorDef document.
*
* @param subscriptionDescriptor the subscriptionDescriptor document
* @param configuration contains package of generated sources, as well as source and destination
* folders
*/
@Override
public void run(final SubscriptionDescriptor subscriptionDescriptor, final GeneratorConfig configuration) {
final CommonGeneratorProperties commonGeneratorProperties = (CommonGeneratorProperties) configuration.getGeneratorProperties();
final String basePackageName = configuration.getBasePackageName();
final List<Subscription> subscriptions = subscriptionDescriptor.getSubscriptions();
subscriptions.stream().flatMap(subscription -> generatedClassesFrom(subscriptionDescriptor, subscription, commonGeneratorProperties, basePackageName)).forEach(generatedClass -> writeClass(configuration, basePackageName, generatedClass, LOGGER));
final List<Event> allEvents = subscriptions.stream().map(Subscription::getEvents).flatMap(Collection::stream).collect(toList());
final String contextName = subscriptionDescriptor.getService();
final String componentName = subscriptionDescriptor.getServiceComponent();
subscriptionMediaTypeToSchemaIdGenerator.generateMediaTypeToSchemaIdMapper(contextName, componentName, allEvents, configuration);
}
Aggregations