Search in sources :

Example 1 with FileInputDetailsFactory

use of uk.gov.justice.services.adapter.rest.multipart.FileInputDetailsFactory in project microservice_framework by CJSCommonPlatform.

the class RestAdapterGenerator_MultipartCodeStructureTest method shouldGenerateResourceClassWithInjectedFileInputDetailsFactory.

@Test
public void shouldGenerateResourceClassWithInjectedFileInputDetailsFactory() throws Exception {
    generator.run(restRamlWithCommandApiDefaults().with(resource("/some/path").with(httpAction().withHttpActionType(POST).withMediaTypeWithoutSchema(multipartWithFileFormParameter("photoId")).with(mapping().withName("upload").withRequestType(MULTIPART_FORM_DATA)))).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, new CommonGeneratorProperties()));
    final Class<?> resourceClass = compiler.compiledClassOf(BASE_PACKAGE, "resource", "DefaultCommandApiSomePathResource");
    final Field chainProcess = resourceClass.getDeclaredField("fileInputDetailsFactory");
    assertThat(chainProcess, not(nullValue()));
    assertThat(chainProcess.getType(), equalTo(FileInputDetailsFactory.class));
    assertThat(chainProcess.getAnnotation(Inject.class), not(nullValue()));
    assertThat(chainProcess.getModifiers(), is(0));
}
Also used : Inject(javax.inject.Inject) Field(java.lang.reflect.Field) FileInputDetailsFactory(uk.gov.justice.services.adapter.rest.multipart.FileInputDetailsFactory) CommonGeneratorProperties(uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties) Test(org.junit.Test)

Aggregations

Field (java.lang.reflect.Field)1 Inject (javax.inject.Inject)1 Test (org.junit.Test)1 FileInputDetailsFactory (uk.gov.justice.services.adapter.rest.multipart.FileInputDetailsFactory)1 CommonGeneratorProperties (uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties)1