use of uk.gov.justice.services.core.mapping.MediaTypes in project microservice_framework by CJSCommonPlatform.
the class MediaTypeProviderTest method shouldReturnEmptyIfNoResponseMediaTypeFoundForTheActionName.
@Test
public void shouldReturnEmptyIfNoResponseMediaTypeFoundForTheActionName() throws Exception {
final String actionName = "example.add-recipe";
final MediaTypes mediaTypes = mock(MediaTypes.class);
when(mediaTypesMappingCache.mediaTypesFor(actionName)).thenReturn(of(mediaTypes));
when(mediaTypes.getResponseMediaType()).thenReturn(empty());
assertThat(mediaTypeProvider.getResponseMediaType(actionName), is(empty()));
}
use of uk.gov.justice.services.core.mapping.MediaTypes in project microservice_framework by CJSCommonPlatform.
the class MediaTypeProviderTest method shouldReturnEmptyIfNoRequestMediaTypeFoundForTheActionName.
@Test
public void shouldReturnEmptyIfNoRequestMediaTypeFoundForTheActionName() throws Exception {
final String actionName = "example.add-recipe";
final MediaTypes mediaTypes = mock(MediaTypes.class);
when(mediaTypesMappingCache.mediaTypesFor(actionName)).thenReturn(of(mediaTypes));
when(mediaTypes.getRequestMediaType()).thenReturn(empty());
assertThat(mediaTypeProvider.getRequestMediaType(actionName), is(empty()));
}
use of uk.gov.justice.services.core.mapping.MediaTypes in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_ActionNameToMediaTypesMapperTest method shouldGenerateMediaTypeToSchemaIdMapper.
@Test
public void shouldGenerateMediaTypeToSchemaIdMapper() throws Exception {
final String actionName = "contextA.someAction";
generator.run(restRamlWithQueryApiDefaults().with(resource("/user").with(httpAction(GET).with(mapping().withName(actionName).withResponseType(MEDIA_TYPE_1.toString())).withResponseTypes(MEDIA_TYPE_1.toString()))).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, new CommonGeneratorProperties()));
final Class<?> mediaTypesMapperClass = compiler.compiledClassOf(BASE_PACKAGE, "mapper", "WarnameActionNameToMediaTypesMapper");
final ActionNameToMediaTypesMapper instance = (ActionNameToMediaTypesMapper) mediaTypesMapperClass.newInstance();
final Map<String, MediaTypes> actionNameToMediaTypesMap = instance.getActionNameToMediaTypesMap();
assertThat(actionNameToMediaTypesMap.size(), is(1));
assertThat(actionNameToMediaTypesMap.get(actionName).getResponseMediaType(), is(Optional.of(MEDIA_TYPE_1)));
assertThat(actionNameToMediaTypesMap.get(actionName).getRequestMediaType(), is(Optional.empty()));
}
Aggregations