Search in sources :

Example 1 with Response

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

the class HttpActionBuilder method build.

public Action build() {
    final Action action = new Action();
    action.setType(actionType);
    if (description != null) {
        action.setDescription(description);
    } else if (mappingDescription != null) {
        action.setDescription(mappingDescription.build());
    }
    action.setBody(body);
    if (responseMap.isEmpty()) {
        final HashMap<String, Response> responsesFromList = new HashMap<>();
        responses.forEach(response -> responsesFromList.put(valueOf(OK.getStatusCode()), response));
        action.setResponses(responsesFromList);
    } else {
        action.setResponses(responseMap);
    }
    if (resource != null) {
        action.setResource(resource);
    }
    action.setQueryParameters(queryParameters);
    return action;
}
Also used : Response(org.raml.model.Response) Action(org.raml.model.Action) HashMap(java.util.HashMap)

Example 2 with Response

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

the class HttpActionBuilder method withHttpActionResponseAndEmptyBody.

public HttpActionBuilder withHttpActionResponseAndEmptyBody() {
    final Map<String, MimeType> respBody = new HashMap<>();
    final Response response = new Response();
    response.setBody(respBody);
    responses.add(response);
    return this;
}
Also used : Response(org.raml.model.Response) HashMap(java.util.HashMap) MimeType(org.raml.model.MimeType)

Example 3 with Response

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

the class ResponseBuilder method build.

public Response build() {
    final Response response = new Response();
    response.setDescription(description);
    response.setBody(responseBody);
    return response;
}
Also used : Response(org.raml.model.Response)

Example 4 with Response

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

the class ActionsTest method shouldReturnFalseIfActionHasResponseTypesWithAcceptedType.

@Test
public void shouldReturnFalseIfActionHasResponseTypesWithAcceptedType() throws Exception {
    final Map<String, Response> responses = new HashMap<>();
    responses.put(valueOf(INTERNAL_SERVER_ERROR.getStatusCode()), response().build());
    responses.put(valueOf(BAD_REQUEST.getStatusCode()), response().build());
    responses.put(valueOf(ACCEPTED.getStatusCode()), response().build());
    final Action action = httpAction().withResponsesFrom(responses).build();
    assertThat(isSynchronousAction(action), equalTo(false));
}
Also used : Response(org.raml.model.Response) HttpActionBuilder.httpAction(uk.gov.justice.services.generators.test.utils.builder.HttpActionBuilder.httpAction) Action(org.raml.model.Action) Actions.isSynchronousAction(uk.gov.justice.services.generators.commons.helper.Actions.isSynchronousAction) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

Response (org.raml.model.Response)4 HashMap (java.util.HashMap)3 Action (org.raml.model.Action)2 Test (org.junit.Test)1 MimeType (org.raml.model.MimeType)1 Actions.isSynchronousAction (uk.gov.justice.services.generators.commons.helper.Actions.isSynchronousAction)1 HttpActionBuilder.httpAction (uk.gov.justice.services.generators.test.utils.builder.HttpActionBuilder.httpAction)1