use of uk.gov.justice.services.core.annotation.Handles in project microservice_framework by CJSCommonPlatform.
the class RestClientGenerator_CodeStructureTest method shouldGenerateMethodAnnotatedWithHandlesAnnotationForPOST.
@Test
public void shouldGenerateMethodAnnotatedWithHandlesAnnotationForPOST() throws Exception {
generator.run(restRamlWithDefaults().with(resource("/some/path/{recipeId}").with(httpAction(POST, "application/vnd.cakeshop.command.create-recipe+json").withDescription(POST_MAPPING_ANNOTATION))).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties().withServiceComponentOf("CUSTOM_COMPONENT")));
final Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "RemoteCustomComponent2ServiceCommandApi");
final List<Method> methods = methodsOf(clazz);
assertThat(methods, hasSize(1));
final Method method = methods.get(0);
final Handles handlesAnnotation = method.getAnnotation(Handles.class);
assertThat(method.getName(), equalTo("postSomePathRecipeIdCakeshopCommandCreateRecipe"));
assertThat(handlesAnnotation, not(nullValue()));
assertThat(handlesAnnotation.value(), is("cakeshop.create-recipe"));
}
use of uk.gov.justice.services.core.annotation.Handles in project microservice_framework by CJSCommonPlatform.
the class RestClientGenerator_CodeStructureTest method shouldGenerateMethodAnnotatedWithHandlesAnnotationForPATCH.
@Test
public void shouldGenerateMethodAnnotatedWithHandlesAnnotationForPATCH() throws Exception {
generator.run(restRamlWithDefaults().with(resource("/some/path/{recipeId}").with(httpAction(PATCH, "application/vnd.cakeshop.command.patch-recipe+json").withDescription(PATCH_MAPPING_ANNOTATION))).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties().withServiceComponentOf("CUSTOM_COMPONENT")));
final Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "RemoteCustomComponent2ServiceCommandApi");
final List<Method> methods = methodsOf(clazz);
assertThat(methods, hasSize(1));
final Method method = methods.get(0);
assertThat(method.getName(), equalTo("patchSomePathRecipeIdCakeshopCommandPatchRecipe"));
final Handles handlesAnnotation = method.getAnnotation(Handles.class);
assertThat(handlesAnnotation, not(nullValue()));
assertThat(handlesAnnotation.value(), is("cakeshop.patch-recipe"));
}
use of uk.gov.justice.services.core.annotation.Handles in project microservice_framework by CJSCommonPlatform.
the class MessagingClientGenerator_CodeStructureTest method shouldGenerateMethodAnnotatedWithHandlesAnnotationForGET.
@Test
public void shouldGenerateMethodAnnotatedWithHandlesAnnotationForGET() throws Exception {
generator.run(messagingRamlWithDefaults().with(resource().withRelativeUri("/cakeshop.handler.command").with(httpActionWithDefaultMapping(GET).withResponseTypes("application/vnd.cakeshop.actionabc+json"))).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties().withServiceComponentOf("COMMAND_CONTROLLER")));
final Class<?> generatedClass = compiler.compiledClassOf(BASE_PACKAGE, "RemoteCommandController2EventProcessorMessageContextCakeshopHandlerCommand");
List<Method> methods = methodsOf(generatedClass);
assertThat(methods, hasSize(1));
final Method method = methods.get(0);
final Handles handlesAnnotation = method.getAnnotation(Handles.class);
assertThat(handlesAnnotation, not(nullValue()));
assertThat(handlesAnnotation.value(), is("cakeshop.actionabc"));
}
use of uk.gov.justice.services.core.annotation.Handles in project microservice_framework by CJSCommonPlatform.
the class MessagingClientGenerator_CodeStructureTest method shouldGenerateMethodAnnotatedWithHandlesAnnotation.
@Test
public void shouldGenerateMethodAnnotatedWithHandlesAnnotation() throws Exception {
generator.run(messagingRamlWithDefaults().with(resource().withRelativeUri("/cakeshop.controller.command").with(httpActionWithDefaultMapping(POST, "application/vnd.cakeshop.actionabc+json"))).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties().withServiceComponentOf("COMMAND_CONTROLLER")));
final Class<?> generatedClass = compiler.compiledClassOf(BASE_PACKAGE, "RemoteCommandController2EventProcessorMessageContextCakeshopControllerCommand");
List<Method> methods = methodsOf(generatedClass);
assertThat(methods, hasSize(1));
final Method method = methods.get(0);
final Handles handlesAnnotation = method.getAnnotation(Handles.class);
assertThat(handlesAnnotation, not(nullValue()));
assertThat(handlesAnnotation.value(), is("cakeshop.actionabc"));
}
use of uk.gov.justice.services.core.annotation.Handles in project microservice_framework by CJSCommonPlatform.
the class RecipeCommandHandler method removeRecipe.
@Handles("example.command.remove-recipe")
public void removeRecipe(final JsonEnvelope command) throws EventStreamException {
LOGGER.trace("=============> Inside remove-recipe Command Handler. RecipeId: " + command.payloadAsJsonObject().getString(FIELD_RECIPE_ID));
final UUID recipeId = getUUID(command.payloadAsJsonObject(), FIELD_RECIPE_ID).get();
final EventStream eventStream = eventSource.getStreamById(recipeId);
final Recipe recipe = aggregateService.get(eventStream, Recipe.class);
eventStream.append(recipe.removeRecipe().map(toEnvelopeWithMetadataFrom(command)));
}
Aggregations