Search in sources :

Example 11 with MimeType

use of org.raml.model.MimeType in project microservice_framework by CJSCommonPlatform.

the class ActionMimeTypeDefinitionTest method shouldCreateWithRequestTypeAndResponseTypeAndAndReturnResponseTypeAsResponseType.

@Test
public void shouldCreateWithRequestTypeAndResponseTypeAndAndReturnResponseTypeAsResponseType() throws Exception {
    final MimeType requestType = mock(MimeType.class);
    final MimeType responseType = mock(MimeType.class);
    assertThat(definitionWithRequestAndResponse(requestType, responseType).getResponseType(), sameInstance(responseType));
}
Also used : MimeType(org.raml.model.MimeType) Test(org.junit.Test)

Example 12 with MimeType

use of org.raml.model.MimeType in project microservice_framework by CJSCommonPlatform.

the class ActionMimeTypeDefinitionTest method shouldCreateWithRequestTypeAndResponseTypeAndReturnRequestTypeAsNameType.

@Test
public void shouldCreateWithRequestTypeAndResponseTypeAndReturnRequestTypeAsNameType() throws Exception {
    final MimeType requestType = mock(MimeType.class);
    final MimeType responseType = mock(MimeType.class);
    assertThat(definitionWithRequestAndResponse(requestType, responseType).getNameType(), sameInstance(requestType));
}
Also used : MimeType(org.raml.model.MimeType) Test(org.junit.Test)

Example 13 with MimeType

use of org.raml.model.MimeType in project microservice_framework by CJSCommonPlatform.

the class ActionMimeTypeDefinitionTest method shouldCreateWithRequestTypeAndReturnRequestTypeAsResponeType.

@Test
public void shouldCreateWithRequestTypeAndReturnRequestTypeAsResponeType() throws Exception {
    final MimeType mimeType = mock(MimeType.class);
    assertThat(definitionWithRequest(mimeType).getResponseType(), sameInstance(mimeType));
}
Also used : MimeType(org.raml.model.MimeType) Test(org.junit.Test)

Example 14 with MimeType

use of org.raml.model.MimeType in project microservice_framework by CJSCommonPlatform.

the class NamesTest method shouldGenerateCorrectResourceNameForPostWithRequestMimeType.

@Test
public void shouldGenerateCorrectResourceNameForPostWithRequestMimeType() {
    final Action action = HttpActionBuilder.defaultPostAction().withResourceUri("/some/path/{recipeId}/").build();
    final ActionMimeTypeDefinition actionMimeTypeDefinition = ActionMimeTypeDefinition.definitionWithRequest(new MimeType("application/vnd.command.create-user+json"));
    assertThat(Names.buildResourceMethodNameFromVerbUriAndMimeType(action, actionMimeTypeDefinition), equalTo("postSomePathRecipeIdCommandCreateUser"));
}
Also used : ActionMimeTypeDefinition(uk.gov.justice.services.generators.commons.client.ActionMimeTypeDefinition) HttpActionBuilder.httpAction(uk.gov.justice.services.generators.test.utils.builder.HttpActionBuilder.httpAction) Action(org.raml.model.Action) MimeType(org.raml.model.MimeType) Test(org.junit.Test)

Example 15 with MimeType

use of org.raml.model.MimeType in project microservice_framework by CJSCommonPlatform.

the class NamesTest method shouldBuildResourceMethodNameFromActionIfNoMapping.

@Test
public void shouldBuildResourceMethodNameFromActionIfNoMapping() throws Exception {
    final Action action = httpAction().withHttpActionType(POST).build();
    action.setResource(resource().withRelativeUri("test").build());
    final String shortMimeType = Names.resourceMethodNameFrom(action, new MimeType("application/vnd.command.create-user+json"));
    assertThat(shortMimeType, is("postTest"));
}
Also used : HttpActionBuilder.httpAction(uk.gov.justice.services.generators.test.utils.builder.HttpActionBuilder.httpAction) Action(org.raml.model.Action) MimeType(org.raml.model.MimeType) Test(org.junit.Test)

Aggregations

MimeType (org.raml.model.MimeType)38 Test (org.junit.Test)30 Action (org.raml.model.Action)6 Event (uk.gov.justice.subscription.domain.Event)6 HttpActionBuilder.httpAction (uk.gov.justice.services.generators.test.utils.builder.HttpActionBuilder.httpAction)4 MediaType (uk.gov.justice.services.core.mapping.MediaType)3 MediaTypeToSchemaIdMapper (uk.gov.justice.services.core.mapping.MediaTypeToSchemaIdMapper)3 CommonGeneratorProperties (uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties)3 Subscription (uk.gov.justice.subscription.domain.Subscription)3 HashMap (java.util.HashMap)2 Resource (org.raml.model.Resource)2 ActionMimeTypeDefinition (uk.gov.justice.services.generators.commons.client.ActionMimeTypeDefinition)2 Eventsource (uk.gov.justice.subscription.domain.Eventsource)2 Location (uk.gov.justice.subscription.domain.Location)2 TypeSpec (com.squareup.javapoet.TypeSpec)1 ActionType (org.raml.model.ActionType)1 Response (org.raml.model.Response)1 SchemaParsingException (uk.gov.justice.services.generators.commons.mapping.SchemaParsingException)1 MappingBuilder (uk.gov.justice.services.generators.test.utils.builder.MappingBuilder)1 SubscriptionDescriptor (uk.gov.justice.subscription.domain.SubscriptionDescriptor)1