Search in sources :

Example 1 with ActionMapper

use of uk.gov.justice.services.adapter.rest.mapping.ActionMapper 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));
}
Also used : Inject(javax.inject.Inject) Field(java.lang.reflect.Field) Named(javax.inject.Named) ActionMapper(uk.gov.justice.services.adapter.rest.mapping.ActionMapper) 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 Named (javax.inject.Named)1 Test (org.junit.Test)1 ActionMapper (uk.gov.justice.services.adapter.rest.mapping.ActionMapper)1 CommonGeneratorProperties (uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties)1