Search in sources :

Example 6 with MimeType

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

the class AbstractContentTypeRamlValidator method validate.

@Override
protected void validate(final Resource resource) {
    actionTypes.forEach(actionType -> {
        final Action action = resource.getActions().get(actionType);
        if (action != null) {
            final Collection<MimeType> mediaTypes = mediaTypesToValidate(action);
            checkNonEmpty(mediaTypes);
        }
    });
}
Also used : Action(org.raml.model.Action) MimeType(org.raml.model.MimeType)

Example 7 with MimeType

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

the class RamlResourceToSubscriptionConverter method asSubscription.

public Subscription asSubscription(final Resource resource) {
    final String resourceUri = resource.getUri();
    final String subscriptionName = subscriptionNamesGenerator.createSubscriptionNameFrom(resourceUri);
    final Collection<MimeType> mimeTypes = resource.getAction(POST).getBody().values();
    final List<Event> events = ramlMimeTypeListToEventListConverter.toEvents(mimeTypes);
    final String eventSourceName = subscriptionNamesGenerator.createEventSourceNameFrom(resourceUri);
    final String jmsUri = jmsUriGenerator.createJmsUriFrom(resourceUri);
    final String restUri = null;
    final Eventsource eventsource = new Eventsource(eventSourceName, new Location(jmsUri, restUri));
    return new Subscription(subscriptionName, events, eventsource);
}
Also used : Eventsource(uk.gov.justice.subscription.domain.Eventsource) Event(uk.gov.justice.subscription.domain.Event) Subscription(uk.gov.justice.subscription.domain.Subscription) MimeType(org.raml.model.MimeType) Location(uk.gov.justice.subscription.domain.Location)

Example 8 with MimeType

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

the class ActionMimeTypeDefinitionTest method shouldCreateWithRequestTypeAndReturnRequestTypeAsNameType.

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

Example 9 with MimeType

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

the class ActionMimeTypeDefinitionTest method shouldCreateWithResponseTypeAndReturnResponseTypeAsResponeType.

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

Example 10 with MimeType

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

the class ActionMimeTypeDefinitionTest method shouldCreateWithResponseTypeAndReturnResponseTypeAsNameType.

@Test
public void shouldCreateWithResponseTypeAndReturnResponseTypeAsNameType() throws Exception {
    final MimeType mimeType = mock(MimeType.class);
    assertThat(definitionWithResponse(mimeType).getNameType(), sameInstance(mimeType));
}
Also used : 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