use of uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_CodeStructureTest method shouldAddInterceptorChainProcessorIfThereIsPOSTResourceInRAML.
@Test
public void shouldAddInterceptorChainProcessorIfThereIsPOSTResourceInRAML() throws Exception {
generator.run(restRamlWithCommandApiDefaults().with(defaultPostResource().withRelativeUri("/some/path")).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, new CommonGeneratorProperties()));
final Class<?> resourceClass = compiler.compiledClassOf(BASE_PACKAGE, "resource", "DefaultCommandApiSomePathResource");
final Field chainProcess = resourceClass.getDeclaredField(INTERCEPTOR_CHAIN_PROCESSOR);
assertThat(chainProcess, not(nullValue()));
assertThat(chainProcess.getType(), equalTo(InterceptorChainProcessor.class));
assertThat(chainProcess.getAnnotation(Inject.class), not(nullValue()));
assertThat(chainProcess.getModifiers(), is(0));
}
use of uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_CodeStructureTest method shouldGenerateResourceInterfaceWithOneDELETEMethod.
@Test
public void shouldGenerateResourceInterfaceWithOneDELETEMethod() throws Exception {
generator.run(restRamlWithDefaults().with(resource("/some/path").with(httpActionWithDefaultMapping(DELETE, "application/vnd.default+json").with(mapping().withName("blah").withRequestType("application/vnd.default+json")))).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, new CommonGeneratorProperties()));
final Class<?> interfaceClass = compiler.compiledInterfaceOf(RESOURCE_PACKAGE);
final List<Method> methods = methodsOf(interfaceClass);
assertThat(methods, hasSize(1));
final Method method = methods.get(0);
assertThat(method.getReturnType(), equalTo(Response.class));
assertThat(method.getAnnotation(DELETE.class), not(nullValue()));
assertThat(method.getAnnotation(Consumes.class), not(nullValue()));
assertThat(method.getAnnotation(Consumes.class).value(), is(new String[] { "application/vnd.default+json" }));
}
use of uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_CodeStructureTest method shouldAddActionMapperBean.
@Test
public void shouldAddActionMapperBean() throws Exception {
generator.run(restRamlWithCommandApiDefaults().with(resource("/user").with(defaultGetAction())).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, new CommonGeneratorProperties()));
final Class<?> resourceClass = compiler.compiledClassOf(BASE_PACKAGE, "resource", "DefaultCommandApiUserResource");
final Field mapping = resourceClass.getDeclaredField("actionMapper");
assertThat(mapping, not(nullValue()));
assertThat(mapping.getType(), equalTo(ActionMapper.class));
assertThat(mapping.getAnnotation(Inject.class), not(nullValue()));
assertThat(mapping.getAnnotation(Named.class), not(nullValue()));
assertThat(mapping.getAnnotation(Named.class).value(), is("DefaultCommandApiUserResourceActionMapper"));
assertThat(mapping.getModifiers(), is(0));
}
use of uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_CodeStructureTest method shouldGenerateResourceInterfaceWithOneSynchronousPOSTMethod.
@Test
public void shouldGenerateResourceInterfaceWithOneSynchronousPOSTMethod() throws Exception {
generator.run(restRamlWithDefaults().with(resource("/some/path").with(httpActionWithDefaultMapping(POST, "application/vnd.default+json").withResponseTypes("application/vnd.ctx.query.query1+json").with(mapping().withName("blah").withRequestType("application/vnd.default+json").withResponseType("application/vnd.ctx.query.query1+json")))).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, new CommonGeneratorProperties()));
final Class<?> interfaceClass = compiler.compiledInterfaceOf(RESOURCE_PACKAGE);
final List<Method> methods = methodsOf(interfaceClass);
assertThat(methods, hasSize(1));
final Method method = methods.get(0);
assertThat(method.getReturnType(), equalTo(Response.class));
assertThat(method.getAnnotation(POST.class), not(nullValue()));
assertThat(method.getAnnotation(Consumes.class), not(nullValue()));
assertThat(method.getAnnotation(Consumes.class).value(), is(new String[] { "application/vnd.default+json" }));
assertThat(method.getAnnotation(Produces.class), not(nullValue()));
assertThat(method.getAnnotation(Produces.class).value(), is(new String[] { "application/vnd.ctx.query.query1+json" }));
}
use of uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_CodeStructureTest method shouldGenerateResourceInterfaceWithOneSynchronousPATCHMethod.
@Test
public void shouldGenerateResourceInterfaceWithOneSynchronousPATCHMethod() throws Exception {
generator.run(restRamlWithDefaults().with(resource("/some/path").with(httpActionWithDefaultMapping(PATCH, "application/vnd.default+json").withResponseTypes("application/vnd.ctx.query.query1+json").with(mapping().withName("blah").withRequestType("application/vnd.default+json").withResponseType("application/vnd.ctx.query.query1+json")))).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, new CommonGeneratorProperties()));
final Class<?> interfaceClass = compiler.compiledInterfaceOf(RESOURCE_PACKAGE);
final List<Method> methods = methodsOf(interfaceClass);
assertThat(methods, hasSize(1));
final Method method = methods.get(0);
assertThat(method.getReturnType(), equalTo(Response.class));
assertThat(method.getAnnotation(PATCH.class), not(nullValue()));
assertThat(method.getAnnotation(Consumes.class), not(nullValue()));
assertThat(method.getAnnotation(Consumes.class).value(), is(new String[] { "application/vnd.default+json" }));
assertThat(method.getAnnotation(Produces.class), not(nullValue()));
assertThat(method.getAnnotation(Produces.class).value(), is(new String[] { "application/vnd.ctx.query.query1+json" }));
}
Aggregations