Package org.raml.model

Examples of org.raml.model.Raml


        return target;
    }

    private void verifyFullDump(Raml source, String dump)
    {
        Raml target = verifyDump(source, dump);

        //*********** URI PARAMETERS ***********

        UriParameter srcHost = source.getBaseUriParameters().get("host");
        UriParameter tgtHost = target.getBaseUriParameters().get("host");
        assertThat(tgtHost.getDisplayName(), is(srcHost.getDisplayName()));
        assertThat(tgtHost.getDescription(), is(srcHost.getDescription()));
        assertThat(tgtHost.getType(), is(srcHost.getType()));
        assertThat(tgtHost.getMinLength(), is(srcHost.getMinLength()));
        assertThat(tgtHost.getMaxLength(), is(srcHost.getMaxLength()));
        assertThat(tgtHost.getPattern(), is(srcHost.getPattern()));

        UriParameter srcPort = source.getBaseUriParameters().get("port");
        UriParameter tgtPort = target.getBaseUriParameters().get("port");
        assertThat(tgtPort.getType(), is(srcPort.getType()));
        assertThat(tgtPort.getMinimum(), is(srcPort.getMinimum()));
        assertThat(tgtPort.getMaximum(), is(srcPort.getMaximum()));

        UriParameter srcPath = source.getBaseUriParameters().get("path");
        UriParameter tgtPath = target.getBaseUriParameters().get("path");
        assertThat(tgtPath.getType(), is(srcPath.getType()));
        assertThat(tgtPath.getEnumeration().size(), is(srcPath.getEnumeration().size()));
        assertThat(tgtPath.getEnumeration().get(0), is(srcPath.getEnumeration().get(0)));
        assertThat(tgtPath.getEnumeration().get(1), is(srcPath.getEnumeration().get(1)));
        assertThat(tgtPath.getEnumeration().get(2), is(srcPath.getEnumeration().get(2)));

        //*********** DOCUMENTATION ***********

        List<DocumentationItem> srcDoc = source.getDocumentation();
        List<DocumentationItem> tgtDoc = target.getDocumentation();
        assertThat(tgtDoc.get(0).getTitle(), is(srcDoc.get(0).getTitle()));
        assertThat(tgtDoc.get(0).getContent(), is(srcDoc.get(0).getContent()));

        //*********** GLOBAL SCHEMAS ***********

        List<Map<String, String>> srcSchemas = source.getSchemas();
        List<Map<String, String>> tgtSchemas = target.getSchemas();
        assertThat(tgtSchemas.size(), is(srcSchemas.size()));
        assertThat(tgtSchemas.get(0).get("league-json"), is(srcSchemas.get(0).get("league-json")));
        assertThat(tgtSchemas.get(1).get("league-xml"), is(srcSchemas.get(1).get("league-xml")));

        //*********** FORM PARAMETERS ***********

        Map<String, List<FormParameter>> srcFormParams = source.getResource("/media").getAction(GET).getBody().get("multipart/form-data").getFormParameters();
        Map<String, List<FormParameter>> tgtFormParams = target.getResource("/media").getAction(GET).getBody().get("multipart/form-data").getFormParameters();
        assertThat(srcFormParams.size(), is(tgtFormParams.size()));
        assertThat(srcFormParams.get("form-1").size(), is(tgtFormParams.get("form-1").size()));
        assertThat(srcFormParams.get("form-1").get(0).getDisplayName(), is(tgtFormParams.get("form-1").get(0).getDisplayName()));
        assertThat(srcFormParams.get("form-2").size(), is(tgtFormParams.get("form-2").size()));
        assertThat(srcFormParams.get("form-2").get(0).getDisplayName(), is(tgtFormParams.get("form-2").get(0).getDisplayName()));

        //*********** RESOURCE TYPES ************

        assertThat(target.getResourceTypes().size(), is(source.getResourceTypes().size()));
        assertThat(target.getResourceTypes().get(0).get("basic").getDisplayName(),
                   is(source.getResourceTypes().get(0).get("basic").getDisplayName()));
        assertThat(target.getResourceTypes().get(1).get("complex").getDisplayName(),
                   is(source.getResourceTypes().get(1).get("complex").getDisplayName()));

        assertThat(target.getResource("/").getType(), is(source.getResource("/").getType()));
        assertThat(target.getResource("/media").getType(), is(source.getResource("/media").getType()));

        //*********** TRAITS ************

        assertThat(target.getTraits().size(), is(source.getTraits().size()));
        assertThat(target.getTraits().get(0).get("simple").getDisplayName(),
                   is(source.getTraits().get(0).get("simple").getDisplayName()));
        assertThat(target.getTraits().get(1).get("knotty").getDisplayName(),
                   is(source.getTraits().get(1).get("knotty").getDisplayName()));

        assertThat(target.getResource("/").getAction(HEAD).getIs(), is(source.getResource("/").getAction(HEAD).getIs()));

        //*********** SECURITY SCHEMES ************

        assertThat(target.getSecuritySchemes().size(), is(source.getSecuritySchemes().size()));
        SecurityScheme tOauth2 = target.getSecuritySchemes().get(0).get("oauth_2_0");
        SecurityScheme sOauth2 = source.getSecuritySchemes().get(0).get("oauth_2_0");
        assertThat(tOauth2.getDescription(), is(sOauth2.getDescription()));
        assertThat(tOauth2.getDescribedBy().getHeaders().size(), is(sOauth2.getDescribedBy().getHeaders().size()));
        assertThat(tOauth2.getDescribedBy().getHeaders().get("Authorization").getDescription(),
                   is(sOauth2.getDescribedBy().getHeaders().get("Authorization").getDescription()));
        assertThat(tOauth2.getDescribedBy().getQueryParameters().size(), is(sOauth2.getDescribedBy().getQueryParameters().size()));
        assertThat(tOauth2.getDescribedBy().getQueryParameters().get("access_token").getDescription(),
                   is(sOauth2.getDescribedBy().getQueryParameters().get("access_token").getDescription()));
        assertThat(tOauth2.getDescribedBy().getResponses().size(), is(sOauth2.getDescribedBy().getResponses().size()));
        assertThat(tOauth2.getDescribedBy().getResponses().get("401").getDescription(),
                   is(sOauth2.getDescribedBy().getResponses().get("401").getDescription()));
        assertThat(tOauth2.getSettings().getAccessTokenUri(), is(sOauth2.getSettings().getAccessTokenUri()));
        assertThat(tOauth2.getSettings().getAccessTokenUri(), is("https://api.dropbox.com/1/oauth2/token"));
        assertThat(tOauth2.getSettings().getAuthorizationUri(), is(sOauth2.getSettings().getAuthorizationUri()));
        assertThat(sOauth2.getSettings().getAuthorizationUri(), is("https://www.dropbox.com/1/oauth2/authorize"));
        assertThat(tOauth2.getSettings().getScopes().size(), is(sOauth2.getSettings().getScopes().size()));
        assertThat(tOauth2.getSettings().getScopes().size(), is(1));
        assertThat(tOauth2.getSettings().getAuthorizationGrants().size(), is(sOauth2.getSettings().getAuthorizationGrants().size()));
        assertThat(tOauth2.getSettings().getAuthorizationGrants().size(), is(2));



        assertThat(target.getResource("/").getSecuredBy().size(), is(source.getResource("/").getSecuredBy().size()));
        assertThat(target.getResource("/").getSecuredBy().get(0).getName(), is(source.getResource("/").getSecuredBy().get(0).getName()));
        assertThat(target.getResource("/").getSecuredBy().get(0).getParameters().size(),
                   is(source.getResource("/").getSecuredBy().get(0).getParameters().size()));
        assertThat(target.getResource("/").getSecuredBy().get(0).getParameters().get("scopes").get(0),
                   is(source.getResource("/").getSecuredBy().get(0).getParameters().get("scopes").get(0)));
        assertThat(target.getResource("/").getSecuredBy().get(1).getName(), is(source.getResource("/").getSecuredBy().get(1).getName()));
        assertThat(target.getResource("/").getSecuredBy().get(2).getName(), is(source.getResource("/").getSecuredBy().get(2).getName()));

        //*********** PROTOCOLS ************

        assertThat(target.getProtocols().size(), is(source.getProtocols().size()));
        assertThat(target.getProtocols().get(0), is(source.getProtocols().get(0)));
        assertThat(target.getProtocols().get(1), is(source.getProtocols().get(1)));
    }
View Full Code Here


    @Test
    public void emptyConfigTestCase()
    {
        String simpleTest = "";
        RamlDocumentBuilder builder = new RamlDocumentBuilder();
        Raml raml = builder.build(simpleTest, "");
        Assert.assertTrue(raml != null);
    }
View Full Code Here

    }

    @Test
    public void build()
    {
        Raml raml = parseRaml("org/raml/tagresolver/pojo-validator-found.yaml");

        assertThat(raml.getSchemas().size(), is(2));
        assertThat(raml.getSchemas().get(0).get("userjson"), containsString("\"username\":{\"type\":\"string\",\"required\":true}"));
        assertThat(raml.getSchemas().get(1).get("userxml"), containsString("<xs:attribute name=\"username\" type=\"xs:string\" use=\"required\"/>"));

        Map<ActionType,Action> actions = raml.getResources().get("/resource").getActions();

        assertThat(actions.get(POST).getBody().get("application/json").getSchema(), containsString("\"username\":{\"type\":\"string\",\"required\":true}"));
        assertThat(actions.get(POST).getBody().get("text/xml").getSchema(), containsString("<xs:attribute name=\"username\" type=\"xs:string\" use=\"required\"/>"));

        assertThat(actions.get(PUT).getBody().get("application/json").getSchema(), containsString("\"username\":{\"type\":\"string\",\"required\":true}"));
View Full Code Here

    public void typesWithParams()
    {
        String resource = "org/raml/validation/se-types-params.yaml";
        List<ValidationResult> validationResults = validateRaml(resource);
        assertThat(validationResults.size(), is(0));
        Raml raml = parseRaml(resource);
        assertThat(raml.getTitle(), is("Example API"));
    }
View Full Code Here

    public void github()
    {
        String resource = "org/raml/validation/github-api-v3.raml";
        List<ValidationResult> validationResults = validateRaml(resource);
        assertThat(validationResults.size(), is(0));
        Raml raml = parseRaml(resource);
        assertThat(raml.getTitle(), is("GitHub API"));
    }
View Full Code Here

    public void nullTemplateParameters()
    {
        String resource = "org/raml/validation/null-template-params.raml";
        List<ValidationResult> validationResults = validateRaml(resource);
        assertThat(validationResults.size(), is(0));
        Raml raml = parseRaml(resource);
        assertThat(raml.getTitle(), is("Template params API"));
    }
View Full Code Here

    public void instagram()
    {
        String resource = "org/raml/validation/instagram-api.raml";
        List<ValidationResult> validationResults = validateRaml(resource);
        assertThat(validationResults.size(), is(0));
        Raml raml = parseRaml(resource);
        assertThat(raml.getTitle(), is("Instagram API"));
    }
View Full Code Here

    private String ramlSource = "org/raml/params/required-param.yaml";

    @Test
    public void whenParameterIsYRequiredShouldBeTrue()
    {
        Raml raml = parseRaml(ramlSource);
        UriParameter uriParameter = raml.getBaseUriParameters().get("param2");
        assertThat(uriParameter.isRequired(), is(true));
    }
View Full Code Here

    }

    @Test
    public void typeFile()
    {
        Raml raml = parseRaml(ramlSource);
        QueryParameter queryParameter = raml.getResources().get("/resource").getAction(ActionType.GET).getQueryParameters().get("param");
        assertThat(queryParameter.getType(), is(ParamType.FILE));
    }
View Full Code Here

    }

    @Test
    public void whenParameterHasMultiTypeOrSingleTypeShouldBeAccepted()
    {
        Raml raml = parseRaml("org/raml/params/parameter-multi-type.yaml");

        Map<String, List<FormParameter>> formParameters = raml.getResources().get("/simple").getAction(POST).getBody().get("multipart/form-data").getFormParameters();

        FormParameter uriParameter = formParameters.get("acl").get(0);
        Assert.assertThat(uriParameter.getType(), CoreMatchers.is(ParamType.STRING));

        List<FormParameter> file = formParameters.get("file");
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.