use of org.raml.model.Action in project microservice_framework by CJSCommonPlatform.
the class ResourceBuilder method build.
public Resource build() {
final Resource resource = new Resource();
resource.setParentUri(parentUri);
resource.setRelativeUri(relativeUri);
resource.setUriParameters(uriParameters);
final Map<ActionType, Action> actions = new HashMap<>();
for (final HttpActionBuilder httpActionBuilder : httpActionBuilders) {
final Action action = httpActionBuilder.build();
action.setResource(resource);
actions.put(action.getType(), action);
}
resource.setActions(actions);
return resource;
}
use of org.raml.model.Action in project microservice_framework by CJSCommonPlatform.
the class ActionsTest method shouldReturnEmptyListForActionContainingResponseAndNoBodyType.
@Test
public void shouldReturnEmptyListForActionContainingResponseAndNoBodyType() throws Exception {
final Action action = httpAction().withHttpActionResponseAndNoBody().build();
assertThat(responseMimeTypesOf(action), equalTo(EMPTY_LIST));
}
use of org.raml.model.Action 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));
}
use of org.raml.model.Action in project microservice_framework by CJSCommonPlatform.
the class NamesTest method shouldBuildResourceMethodNameFromAction.
@Test
public void shouldBuildResourceMethodNameFromAction() throws Exception {
final MappingBuilder mappingBuilder = mapping().withName("command.create-user").withRequestType("application/vnd.command.create-user+json");
final Action action = httpAction().withHttpActionType(GET).withDescription(mappingDescriptionWith(mappingBuilder).build()).build();
action.setResource(resource().withRelativeUri("test").build());
final String shortMimeType = Names.resourceMethodNameWithNoMimeTypeFrom(action);
assertThat(shortMimeType, is("getTest"));
}
use of org.raml.model.Action in project microservice_framework by CJSCommonPlatform.
the class NamesTest method shouldGenerateCorrectResourceNameForGetWithResponseMimeType.
@Test
public void shouldGenerateCorrectResourceNameForGetWithResponseMimeType() {
final Action action = HttpActionBuilder.defaultGetAction().withResourceUri("/some/path/{recipeId}/").build();
final ActionMimeTypeDefinition actionMimeTypeDefinition = ActionMimeTypeDefinition.definitionWithResponse(new MimeType("application/vnd.command.create-user+json"));
assertThat(Names.buildResourceMethodNameFromVerbUriAndMimeType(action, actionMimeTypeDefinition), equalTo("getSomePathRecipeIdCommandCreateUser"));
}
Aggregations