use of uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_CodeStructureTest method shouldGenerateResourceClassWithOneSynchronousPUTMethod.
@Test
public void shouldGenerateResourceClassWithOneSynchronousPUTMethod() throws Exception {
generator.run(restRamlWithCommandApiDefaults().with(resource("/some/path").with(httpActionWithDefaultMapping(PUT, "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<?> class1 = compiler.compiledClassOf(BASE_PACKAGE, "resource", "DefaultCommandApiSomePathResource");
final List<Method> methods = methodsOf(class1);
assertThat(methods, hasSize(1));
final Method method = methods.get(0);
assertThat(method.getReturnType(), equalTo(Response.class));
assertThat(method.getParameterCount(), is(1));
assertThat(method.getParameters()[0].getType(), equalTo(JsonObject.class));
}
use of uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_CodeStructureTest method shouldGenerateInterfaceThatContainsMethodWithBodyParameter.
@Test
public void shouldGenerateInterfaceThatContainsMethodWithBodyParameter() throws Exception {
generator.run(restRamlWithDefaults().with(defaultPostResource()).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.getParameterCount(), is(1));
assertThat(method.getParameters()[0].getType(), equalTo(JsonObject.class));
}
use of uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_CodeStructureTest method shouldGenerateResourceInterfaceWithOnePUTMethod.
@Test
public void shouldGenerateResourceInterfaceWithOnePUTMethod() throws Exception {
generator.run(restRamlWithDefaults().with(resource("/some/path").with(httpActionWithDefaultMapping(PUT, "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(PUT.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 shouldGenerateResourceClassContainingOneMethod.
@Test
public void shouldGenerateResourceClassContainingOneMethod() throws Exception {
generator.run(restRamlWithCommandApiDefaults().with(defaultPostResource().withRelativeUri("/some/path")).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, new CommonGeneratorProperties()));
final Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "resource", "DefaultCommandApiSomePathResource");
assertThat(clazz.isInterface(), is(false));
final List<Method> methods = methodsOf(clazz);
assertThat(methods, hasSize(1));
final Method method = methods.get(0);
assertThat(method.getReturnType(), equalTo(Response.class));
}
use of uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_CodeStructureTest method shouldGenerateResourceInterfaceWithOnePATCHMethod.
@Test
public void shouldGenerateResourceInterfaceWithOnePATCHMethod() throws Exception {
generator.run(restRamlWithDefaults().with(resource("/some/path").with(httpActionWithDefaultMapping(PATCH, "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(PATCH.class), not(nullValue()));
assertThat(method.getAnnotation(Consumes.class), not(nullValue()));
assertThat(method.getAnnotation(Consumes.class).value(), is(new String[] { "application/vnd.default+json" }));
}
Aggregations