Search in sources :

Example 1 with PUT

use of org.raml.model.ActionType.PUT in project microservice_framework by CJSCommonPlatform.

the class RestAdapterGenerator_CodeStructureTest method shouldGenerateResourceInterfaceWithOneSynchronousPUTMethod.

@Test
public void shouldGenerateResourceInterfaceWithOneSynchronousPUTMethod() throws Exception {
    generator.run(restRamlWithDefaults().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<?> 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" }));
    assertThat(method.getAnnotation(Produces.class), not(nullValue()));
    assertThat(method.getAnnotation(Produces.class).value(), is(new String[] { "application/vnd.ctx.query.query1+json" }));
}
Also used : Response(javax.ws.rs.core.Response) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CommonGeneratorProperties(uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties) Method(java.lang.reflect.Method) PUT(org.raml.model.ActionType.PUT) PUT(javax.ws.rs.PUT) Test(org.junit.Test)

Example 2 with PUT

use of org.raml.model.ActionType.PUT 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" }));
}
Also used : Response(javax.ws.rs.core.Response) Consumes(javax.ws.rs.Consumes) CommonGeneratorProperties(uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties) Method(java.lang.reflect.Method) PUT(org.raml.model.ActionType.PUT) PUT(javax.ws.rs.PUT) Test(org.junit.Test)

Aggregations

Method (java.lang.reflect.Method)2 Consumes (javax.ws.rs.Consumes)2 PUT (javax.ws.rs.PUT)2 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2 PUT (org.raml.model.ActionType.PUT)2 CommonGeneratorProperties (uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties)2 Produces (javax.ws.rs.Produces)1