Package org.raml.model

Examples of org.raml.model.Raml


    }

    @Test
    public void parentUriTemplate()
    {
        Raml raml = parseRaml(RAML);

        Resource apiId = raml.getResource("/apis/{apiId}");
        assertThat(apiId.getUriParameters().size(), is(1));
        assertThat(apiId.getUriParameters().get("apiId").getType(), is(ParamType.STRING));

        Resource childId = raml.getResource("/apis/{apiId}/{childId}");
        assertThat(childId.getUriParameters().size(), is(1));
        assertThat(childId.getResolvedUriParameters().size(), is(2));
        assertThat(childId.getResolvedUriParameters().get("apiId").getType(), is(ParamType.STRING));
        assertThat(childId.getResolvedUriParameters().get("childId").getType(), is(ParamType.STRING));
    }
View Full Code Here


{

    @Test
    public void addTrait()
    {
        Raml raml = this.parseRaml("org/raml/traits/single-trait-add.yaml");
        Map<String,QueryParameter> queryParams = raml.getResources().get("/media").getAction(GET).getQueryParameters();
        assertThat(queryParams.size(), is(1));
        assertThat(queryParams.get("count").getType(), is(ParamType.INTEGER));
        assertThat(raml.getResources().get("/media").getAction(POST).getQueryParameters().size(), is(2));
    }
View Full Code Here

    }

    @Test
    public void mergeTrait()
    {
        Raml raml = this.parseRaml("org/raml/traits/single-trait-merge.yaml");
        assertThat(raml.getResources().get("/media").getAction(GET).getQueryParameters().size(), is(2));
    }
View Full Code Here

    }

    @Test
    public void addOptionalTrait()
    {
        Raml raml = this.parseRaml("org/raml/traits/single-trait-optional-add.yaml");
        assertThat(raml.getResources().get("/media").getAction(GET), nullValue());
    }
View Full Code Here

    }

    @Test
    public void mergeOptionalTrait()
    {
        Raml raml = this.parseRaml("org/raml/traits/single-trait-optional-merge.yaml");
        assertThat(raml.getResources().get("/media").getAction(GET).getQueryParameters().size(), is(2));
    }
View Full Code Here

    }

    @Test
    public void fullConfig()
    {
        Raml raml = parseRaml(ramlSource);

        //documentation
        List<DocumentationItem> documentation = raml.getDocumentation();
        assertThat(documentation.size(), is(2));
        assertThat(documentation.get(0).getTitle(), is("Home"));
        assertThat(documentation.get(0).getContent(), startsWith("Lorem ipsum dolor sit"));
        assertThat(documentation.get(1).getTitle(), is("section"));
        assertThat(documentation.get(1).getContent(), is("section content"));

        //basic attributes
        assertThat(raml.getTitle(), is("Sample API"));
        assertThat(raml.getVersion(), is("v1"));
        String baseUri = "https://{host}.sample.com:{port}/{path}";
        String basePath = "/{path}";
        assertThat(raml.getBaseUri(), is(baseUri));
        assertThat(raml.getBasePath(), is(basePath));
        assertThat(raml.getUri(), is(""));
        assertThat(raml.getProtocols().size(), is(2));
        assertThat(raml.getProtocols().get(0), is(HTTP));
        assertThat(raml.getProtocols().get(1), is(HTTPS));

        //uri parameters
        assertThat(raml.getBaseUriParameters().size(), is(3));
        Map<String, UriParameter> tagUriParameters = raml.getResource("/tags/{tagId}").getUriParameters();
        assertThat(tagUriParameters.size(), is(1));
        assertThat(tagUriParameters.get("tagId").getDisplayName(), is("tagId"));
        assertThat(tagUriParameters.get("tagId").isRequired(), is(true));
        assertThat(tagUriParameters.get("tagId").getType(), is(ParamType.STRING));

        UriParameter hostParam = raml.getBaseUriParameters().get("host");
        assertThat(hostParam.getDisplayName(), is("Host"));
        assertThat(hostParam.getDescription(), is("host name"));
        assertThat(hostParam.getType(), is(STRING));
        assertThat(hostParam.getMinLength(), is(5));
        assertThat(hostParam.getMaxLength(), is(10));
        assertThat(hostParam.getPattern(), is("[a-z]*"));

        UriParameter portParam = raml.getBaseUriParameters().get("port");
        assertThat(portParam.getType(), is(INTEGER));
        assertThat(portParam.getMinimum(), is(new BigDecimal(1025)));
        assertThat(portParam.getMaximum(), is(new BigDecimal(65535)));

        assertThat(hostParam.getType(), is(STRING));
        UriParameter pathParam = raml.getBaseUriParameters().get("path");
        assertThat(pathParam.getType(), is(STRING));
        assertThat(pathParam.getEnumeration().size(), is(3));
        assertThat(pathParam.getEnumeration().get(0), is("one"));
        assertThat(pathParam.getEnumeration().get(1), is("two"));
        assertThat(pathParam.getEnumeration().get(2), is("three"));

        //resources
        assertThat(raml.getResources().size(), is(3));

        String rootUri = "/";
        Resource rootResource = raml.getResources().get(rootUri);
        assertThat(rootResource.getRelativeUri(), is(rootUri));
        assertThat(rootResource.getUri(), is(rootUri));
        assertThat(rootResource.getDisplayName(), is("Root resource"));
        assertThat(rootResource.getDescription(), is("Root resource description"));
        assertThat(rootResource.getAction(ActionType.HEAD).getProtocols().size(), is(1));
        assertThat(rootResource.getAction(ActionType.HEAD).getProtocols().get(0), is(HTTP));

        String mediaUri = "/media";
        Resource mediaResource = raml.getResources().get(mediaUri);
        assertThat(mediaResource.getRelativeUri(), is(mediaUri));
        assertThat(mediaResource.getUri(), is(mediaUri));
        assertThat(mediaResource.getDisplayName(), is("Media collection"));

        //actions
View Full Code Here

TOP

Related Classes of org.raml.model.Raml

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.