use of uk.gov.justice.services.core.annotation.Handles in project microservice_framework by CJSCommonPlatform.
the class DirectClientGeneratorCodeStructureTest method shouldGenerateTwoMethodsAnnotatedWithHandlesAnnotationForGET.
@Test
public void shouldGenerateTwoMethodsAnnotatedWithHandlesAnnotationForGET() throws Exception {
generator.run(raml().withBaseUri("http://localhost:8080/warname/query/api/service").with(resource().with(httpAction(GET).withResponseTypes("application/vnd.ctx.query2+json", "application/vnd.ctx.query1+json").with(mapping().withName("actionABC").withResponseType("application/vnd.ctx.query1+json")).with(mapping().withName("actionBCD").withResponseType("application/vnd.ctx.query2+json")))).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties().withServiceComponentOf("SOME_COMPONENT")));
final Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "DirectSomeComponent2QueryApiServiceClient");
final List<Method> methods = methodsOf(clazz);
assertThat(methods, hasSize(2));
final Method method1 = methods.get(0);
final Handles handlesAnnotation1 = method1.getAnnotation(Handles.class);
assertThat(handlesAnnotation1, not(nullValue()));
assertThat(handlesAnnotation1.value(), is("actionABC"));
final Method method2 = methods.get(1);
final Handles handlesAnnotation2 = method2.getAnnotation(Handles.class);
assertThat(handlesAnnotation2, not(nullValue()));
assertThat(handlesAnnotation2.value(), is("actionBCD"));
}
use of uk.gov.justice.services.core.annotation.Handles in project microservice_framework by CJSCommonPlatform.
the class AbstractClientGeneratorTest method shouldGenerateAnnotatedMethod.
@Test
public void shouldGenerateAnnotatedMethod() throws Exception {
generator.run(messagingRamlWithDefaults().withDefaultMessagingResource().build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, generatorProperties().withDefaultServiceComponent()));
final Class<?> generatedClass = compiler.compiledClassOf(BASE_PACKAGE, "RemoteABCController");
final 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("some.action"));
assertThat(method.getParameterCount(), is(1));
assertThat(method.getParameters()[0].getType(), equalTo(JsonEnvelope.class));
}
use of uk.gov.justice.services.core.annotation.Handles in project microservice_framework by CJSCommonPlatform.
the class RestClientGenerator_CodeStructureTest method shouldGenerateMethodAnnotatedWithHandlesAnnotationForPUT.
@Test
public void shouldGenerateMethodAnnotatedWithHandlesAnnotationForPUT() throws Exception {
generator.run(restRamlWithDefaults().with(resource("/some/path/{recipeId}").with(httpAction(PUT, "application/vnd.cakeshop.command.update-recipe+json").withDescription(PUT_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("putSomePathRecipeIdCakeshopCommandUpdateRecipe"));
final Handles handlesAnnotation = method.getAnnotation(Handles.class);
assertThat(handlesAnnotation, not(nullValue()));
assertThat(handlesAnnotation.value(), is("cakeshop.update-recipe"));
}
use of uk.gov.justice.services.core.annotation.Handles in project microservice_framework by CJSCommonPlatform.
the class RestClientGenerator_CodeStructureTest method shouldGenerateMethodAnnotatedWithHandlesAnnotationForDELETE.
@Test
public void shouldGenerateMethodAnnotatedWithHandlesAnnotationForDELETE() throws Exception {
generator.run(restRamlWithDefaults().with(resource("/some/path/{recipeId}").with(httpAction(DELETE, "application/vnd.cakeshop.command.delete-recipe+json").withDescription(DELETE_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("deleteSomePathRecipeIdCakeshopCommandDeleteRecipe"));
final Handles handlesAnnotation = method.getAnnotation(Handles.class);
assertThat(handlesAnnotation, not(nullValue()));
assertThat(handlesAnnotation.value(), is("cakeshop.delete-recipe"));
}
use of uk.gov.justice.services.core.annotation.Handles in project microservice_framework by CJSCommonPlatform.
the class OtherRecipeEventListener method recipeAdded.
@Handles("other.recipe-added")
public void recipeAdded(final JsonEnvelope event) {
final RecipeAdded recipeAdded = jsonObjectConverter.convert(event.payloadAsJsonObject(), RecipeAdded.class);
recipeRepository.save(otherRecipeAddedToRecipeConverter.convert(recipeAdded));
for (final Ingredient ingredient : recipeAddedToIngredientsConverter.convert(recipeAdded)) {
if (ingredientRepository.findByNameIgnoreCase(ingredient.getName()).isEmpty()) {
ingredientRepository.save(ingredient);
}
}
}
Aggregations