Package org.raml.model

Examples of org.raml.model.Raml


        SecurityScheme securityScheme = new SecurityScheme();
        securityScheme.setDescribedBy(describedBy);
        securityScheme.setSettings(new SecuritySettings());

        Raml raml = new Raml();
        raml.setTitle("hi");
        raml.setBaseUriParameters(buildMap(new UriParameter()));
        raml.setDocumentation(Collections.singletonList(new DocumentationItem()));
        raml.setResources(buildMap(resource));
        raml.setProtocols(Collections.singletonList(Protocol.HTTP));
        raml.setResourceTypes(Collections.singletonList(buildMap(new Template())));
        raml.setTraits(Collections.singletonList(buildMap(new Template())));
        raml.setSecuritySchemes(Collections.singletonList(buildMap(securityScheme)));
        raml.setSecuredBy(Collections.singletonList(new SecurityReference("ref")));

        byte[] bytes = SerializationUtils.serialize(raml);
        Raml copy = (Raml) SerializationUtils.deserialize(bytes);
        assertThat(copy.getTitle(), is(raml.getTitle()));
    }
View Full Code Here


{

    @Test
    public void nullValues() throws Exception
    {
        Raml raml = parseRaml("org/raml/null-elements.yaml");
        Map<String, MimeType> body = raml.getResources().get("/leagues").getAction(ActionType.GET).getResponses().get("200").getBody();
        assertNotNull(body.get("text/xml"));
        assertNotNull(body.get("application/json"));
    }
View Full Code Here

    @Test
    public void emitter() throws Exception
    {
        RamlDocumentBuilder builder1 = new RamlDocumentBuilder();
        Raml raml1 = parseRaml(ramlSource, builder1);
        String emitted1 = YamlDocumentBuilder.dumpFromAst(builder1.getRootNode());

        RamlDocumentBuilder builder2 = new RamlDocumentBuilder();
        Raml raml2 = builder2.build(emitted1, "");

        assertThat(raml2.getResources().get("/presentations").getAction(GET).getQueryParameters().size(),
                   is(raml1.getResources().get("/presentations").getAction(GET).getQueryParameters().size()));
    }
View Full Code Here

{

    @Test
    public void emitFullConfigFromRaml()
    {
        Raml raml = parseRaml("org/raml/full-config.yaml");
        RamlEmitter emitter = new RamlEmitter();
        String dumpFromRaml = emitter.dump(raml);
        verifyFullDump(raml, dumpFromRaml);
    }
View Full Code Here

    @Test
    public void emitFullConfigFromAst()
    {
        RamlDocumentBuilder builder = new RamlDocumentBuilder();
        Raml raml = parseRaml("org/raml/full-config.yaml", builder);
        String dumpFromAst = YamlDocumentBuilder.dumpFromAst(builder.getRootNode());
        verifyDump(raml, dumpFromAst);
    }
View Full Code Here

    @Test
    public void emitConfigWithIncludesFromAst()
    {
        RamlDocumentBuilder builder = new RamlDocumentBuilder();
        Raml raml = parseRaml("org/raml/root-elements-includes.yaml", builder);
        String dumpFromAst = YamlDocumentBuilder.dumpFromAst(builder.getRootNode());
        verifyDump(raml, dumpFromAst);
    }
View Full Code Here

    }

    @Test
    public void emitEmptyBody()
    {
        Raml raml = parseRaml("org/raml/empty-body.raml");
        RamlEmitter emitter = new RamlEmitter();
        emitter.dump(raml);
    }
View Full Code Here

    }

    @Test
    public void emitRegexp()
    {
        Raml raml = parseRaml("org/raml/emitter/pattern.yaml");
        RamlEmitter emitter = new RamlEmitter();
        String dump = emitter.dump(raml);
        assertThat(dump, containsString("([a-zA-Z0-9_\\.\\+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-\\.]+)"));
    }
View Full Code Here

                      "    minimum: 1\n" +
                      "   number:\n" +
                      "    type: number\n" +
                      "    maximum: 9.5\n" +
                      "    minimum: 2.0";
        Raml raml = parseRaml(yaml, "");
        RamlEmitter emitter = new RamlEmitter();
        String dump = emitter.dump(raml);
        assertThat(dump, containsString("maximum: 8"));
        assertThat(dump, not(containsString("maximum: 8.0")));
        assertThat(dump, containsString("minimum: 1"));
View Full Code Here

    }

    private Raml verifyDump(Raml source, String dump)
    {
        RamlDocumentBuilder verifier = new RamlDocumentBuilder();
        Raml target = verifier.build(dump, "");

        assertThat(target.getTitle(), is(source.getTitle()));
        assertThat(target.getVersion(), is(source.getVersion()));
        assertThat(target.getBaseUri(), is(source.getBaseUri()));
        assertThat(target.getBaseUriParameters().size(), is(source.getBaseUriParameters().size()));
        assertThat(target.getDocumentation().size(), is(source.getDocumentation().size()));
        assertThat(target.getResources().size(), is(source.getResources().size()));

        return target;
    }
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.