Package org.raml.model

Examples of org.raml.model.Resource


        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();
        describedBy.setHeaders(buildMap(new Header()));

        SecurityScheme securityScheme = new SecurityScheme();
View Full Code Here


    }

    @Test
    public void presentations()
    {
        Resource simpleResource = raml.getResources().get("/presentations");
        assertThat(simpleResource.getActions().size(), is(2));
        Map<String, QueryParameter> queryParameters = simpleResource.getAction(GET).getQueryParameters();
        assertThat(queryParameters.size(), is(3));
        assertThat(queryParameters.get("title").getDisplayName(), is("title"));
        assertThat(queryParameters.get("start").getDisplayName(), is("start"));
        assertThat(queryParameters.get("pages").getDisplayName(), is("pages"));
    }
View Full Code Here

    }

    @Test
    public void mixed()
    {
        Resource mixed = raml.getResources().get("/mixed");
        assertThat(mixed.getActions().size(), is(1));
        String[] h = {"hAction", "hType1", "hType0", "hTraitA", "hTraitR", "hTraitT1A",
                      "hTraitT1R", "hTraitT0A", "hTraitT0R"};
        Set headers = new HashSet<String>(Arrays.<String>asList(h));
        assertThat(mixed.getAction(ActionType.GET).getHeaders().keySet(), is(headers));
    }
View Full Code Here

    }

    @Test
    public void override()
    {
        Resource override = raml.getResources().get("/override");
        assertThat(override.getActions().size(), is(1));
        Map<String,QueryParameter> queryParameters = override.getAction(ActionType.GET).getQueryParameters();
        assertThat(queryParameters.size(), is(9));
        assertThat(queryParameters.get("action").getDisplayName(), is("action"));
        assertThat(queryParameters.get("traitOverA").getDisplayName(), is("traitOverA"));
        assertThat(queryParameters.get("traitOverR").getDisplayName(), is("traitOverR"));
        assertThat(queryParameters.get("typeOverR").getDisplayName(), is("typeOverR"));
View Full Code Here

        assertThat(raml.getTitle(), is("Sample API"));
        assertThat(raml.getVersion(), is("v1"));
        assertThat(raml.getBaseUri(), is("https://sample.com/api"));

        assertThat(raml.getResources().size(), is(1));
        Resource mediaResource = raml.getResources().get("/media");
        assertThat(mediaResource.getActions().size(), is(1));
        assertThat(mediaResource.getAction(ActionType.GET), is(Action.class));
    }
View Full Code Here

    public boolean onMappingNodeStart(MappingNode mappingNode, TupleType tupleType)
    {
        super.onMappingNodeStart(mappingNode, tupleType);
        if (getDocumentContext().peek() instanceof Resource)
        {
            Resource resource = (Resource) getDocumentContext().peek();
            getTemplateResolver().resolve(mappingNode, resource.getRelativeUri(), resource.getUri());
        }
        else if (isBodyBuilder(getBuilderContext().peek()))
        {
            getMediaTypeResolver().resolve(mappingNode);
        }
View Full Code Here

    @Override
    public void onMappingNodeEnd(MappingNode mappingNode, TupleType tupleType)
    {
        if (getDocumentContext().peek() instanceof Resource)
        {
            Resource resource = (Resource) getDocumentContext().peek();
            populateDefaultUriParameters(resource);
        }
        super.onMappingNodeEnd(mappingNode, tupleType);
    }
View Full Code Here

    @Test
    public void applyDefault()
    {

        Resource simpleResource = raml.getResources().get("/simple");
        assertThat(simpleResource.getActions().size(), is(4));

        Map<String, MimeType> getBody = simpleResource.getAction(ActionType.GET).getBody();
        assertThat(getBody, nullValue());
        Map<String, MimeType> getResponseBody = simpleResource.getAction(ActionType.GET).getResponses().get("200").getBody();
        assertThat(getResponseBody.size(), is(1));
        assertThat(getResponseBody.containsKey("application/json"), is(true));

        Map<String, MimeType> postBody = simpleResource.getAction(ActionType.POST).getBody();
        assertThat(postBody.size(), is(1));
        assertThat(postBody.containsKey("application/json"), is(true));

        Map<String, MimeType> putBody = simpleResource.getAction(PUT).getBody();
        assertThat(putBody.size(), is(1));
        assertThat(putBody.containsKey("application/json"), is(true));

        Map<String, MimeType> deleteBody = simpleResource.getAction(ActionType.DELETE).getResponses().get("204").getBody();
        assertThat(deleteBody, nullValue());

    }
View Full Code Here

    }

    @Test
    public void bodyWithFormParams()
    {
        Resource formResource = raml.getResources().get("/form");
        assertThat(formResource.getActions().size(), is(1));

        Map<String, MimeType> postBody = formResource.getAction(ActionType.POST).getBody();
        assertThat(postBody.size(), is(1));
        assertThat(postBody.containsKey("application/json"), is(true));
    }
View Full Code Here

    }

    @Test
    public void emptyBody()
    {
        Resource resource = raml.getResource("/empty");
        assertThat(resource.getAction(PUT).getBody().size(), is(1));
        assertThat(resource.getAction(PUT).getResponses().get("200").getBody().size(), is(1));
    }
View Full Code Here

TOP

Related Classes of org.raml.model.Resource

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.