Package org.raml.model

Examples of org.raml.model.Action


    public void roundtrip()
    {
        MimeType mimeType = new MimeType();
        mimeType.setFormParameters(buildMap(Collections.singletonList(new FormParameter())));

        Action action = new Action();
        action.setBody(buildMap(mimeType));
        action.setResponses(buildMap(new Response()));

        Resource resource = new Resource();
        resource.setActions(buildMap(ActionType.GET, action));

        SecuritySchemeDescriptor describedBy = new SecuritySchemeDescriptor();
View Full Code Here


    @Test
    public void schemas()
    {
        Map<String, String> schemas = raml.getConsolidatedSchemas();
        Action post = raml.getResources().get("/presentations").getAction(ActionType.POST);
        assertTrue(schemas.containsKey(post.getBody().get("application/json").getSchema()));
    }
View Full Code Here

        assertThat(mediaResource.getUri(), is(mediaUri));
        assertThat(mediaResource.getDisplayName(), is("Media collection"));

        //actions
        assertThat(mediaResource.getActions().size(), is(2));
        Action action = mediaResource.getAction(ActionType.GET);
        assertThat(action.getType(), is(ActionType.GET));
        assertThat(action.getDescription(), is("retrieve media"));

        //action headers
        assertThat(action.getHeaders().size(), is(1));
        Header apiKeyHeader = action.getHeaders().get("api-key");
        assertThat(apiKeyHeader.getDisplayName(), is("Api key"));
        assertThat(apiKeyHeader.getDescription(), is("Api key description"));
        assertThat(apiKeyHeader.getType(), is(STRING));
        assertThat(apiKeyHeader.isRequired(), is(true));
        assertThat(apiKeyHeader.getMinLength(), is(10));
        assertThat(apiKeyHeader.getMaxLength(), is(10));
        assertThat(apiKeyHeader.getExample(), is("0123456789"));

        //action query parameters
        assertThat(action.getQueryParameters().size(), is(1));
        QueryParameter pageQueryParam = action.getQueryParameters().get("page");
        assertThat(pageQueryParam.getType(), is(INTEGER));
        assertThat(pageQueryParam.isRequired(), is(false));
        assertThat(pageQueryParam.getDefaultValue(), is("1"));
        assertThat(pageQueryParam.getMinimum(), is(new BigDecimal(1)));

        //action body types
        assertThat(action.getBody().size(), is(3));
        String jsonMime = "application/json";
        MimeType jsonBody = action.getBody().get(jsonMime);
        assertThat(jsonBody.getType(), is(jsonMime));
        assertThat(jsonBody.getSchema(), containsString("\"input\": {"));
        assertThat(jsonBody.getExample(), is("{ \"input\": \"hola\" }"));

        String formMime = "multipart/form-data";
        MimeType formBody = action.getBody().get(formMime);
        assertThat(formBody.getType(), is(formMime));
        assertThat(formBody.getFormParameters().size(), is(2));
        List<FormParameter> form1Param = formBody.getFormParameters().get("form-1");
        assertThat(form1Param.get(0).getDisplayName(), is("form 1"));
        assertThat(form1Param.get(0).getDescription(), is("form 1 description"));
        assertThat(form1Param.get(0).getType(), is(NUMBER));
        assertThat(form1Param.get(0).isRequired(), is(true));
        assertThat(form1Param.get(0).getMinimum(), is(new BigDecimal("9.5")));
        assertThat(form1Param.get(0).getMaximum(), is(new BigDecimal("10.5")));
        assertThat(form1Param.get(1).getType(), is(STRING));
        assertThat(form1Param.get(1).getEnumeration().size(), is(3));

        //action responses
        assertThat(action.getResponses().size(), is(3));
        Response response200 = action.getResponses().get("200");
        assertThat(response200.getBody().size(), is(1));
        assertThat(response200.getBody().get("application/json").getExample(), is("{ \"key\": \"value\" }"));
        assertThat(response200.getHeaders().size(), is(2));
        Response response400 = action.getResponses().get("400");
        assertThat(response400.getBody().size(), is(2));
        assertThat(response400.getBody().get("text/xml").getExample(), is("<root>none</root>"));
        assertThat(response400.getBody().get("text/plain").getType(), is("text/plain"));
        Response response404 = action.getResponses().get("404");
        assertThat(response404.getDescription(), is("not found"));

        //nested resource
        assertThat(mediaResource.getResources().size(), is(1));
        String mediaItemUri = "/{mediaId}";
View Full Code Here

TOP

Related Classes of org.raml.model.Action

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.