Package com.gatehill.apibms.core.model

Examples of com.gatehill.apibms.core.model.RequestDefinition


    private void buildRequests(Map<String, String> parentHeaders, ResourceDefinition resource, AstAction astAction, AstTransactionExample example) {
        if (null != example.getRequests() && example.getRequests().size() > 0) {
            // get all requests
            for (AstRequest astRequest : example.getRequests()) {
                // build request
                final RequestDefinition request = new RequestDefinition();
                resource.getRequests().add(request);
                request.setVerb(astAction.getMethod());

                // set headers for inbound matching / request selection
                final Map<String, String> requestHeaders = new HashMap<>();
                requestHeaders.putAll(parentHeaders);
                requestHeaders.putAll(asMap(astRequest.getHeaders()));
                request.setHeaders(requestHeaders);

                LOGGER.trace("Added request from example: {}", request);
            }

        } else {
            // add a default request if none is specified
            final RequestDefinition request = new RequestDefinition();
            resource.getRequests().add(request);
            request.setVerb(astAction.getMethod());

            // set headers for inbound matching / request selection
            final Map<String, String> requestHeaders = new HashMap<>();
            requestHeaders.putAll(parentHeaders);
            request.setHeaders(requestHeaders);

            LOGGER.trace("Added default request: {}", request);
        }

        LOGGER.debug("Built {} request(s) from example", resource.getRequests().size());
View Full Code Here


        final ResourceDefinition endpoint1 = actual.getEndpoints().get(0);
        Assert.assertNotNull(endpoint1);
        Assert.assertEquals("/message", endpoint1.getUrl());

        Assert.assertEquals(1, endpoint1.getRequests().size());
        final RequestDefinition request = endpoint1.getRequests().get(0);
        Assert.assertEquals("GET", request.getVerb());

        Assert.assertEquals(1, endpoint1.getResponses().size());
        final ResponseDefinition response = endpoint1.getResponses().get(HTTP_SC_OK);
        Assert.assertEquals(200, response.getCode());
        Assert.assertEquals("Hello World!\n", response.getBody());
View Full Code Here

        final ResourceDefinition endpoint1 = actual.getEndpoints().get(0);
        Assert.assertNotNull(endpoint1);
        Assert.assertEquals("/message", endpoint1.getUrl());

        Assert.assertEquals(1, endpoint1.getRequests().size());
        final RequestDefinition request = endpoint1.getRequests().get(0);
        Assert.assertEquals("GET", request.getVerb());

        Assert.assertEquals(1, endpoint1.getResponses().size());
        final ResponseDefinition response = endpoint1.getResponses().get(HTTP_SC_OK);

        // FIXME trailing \n is stripped off
View Full Code Here

                            LOGGER.info("Found endpoint: {}", currentEndpoint.getName());

                            final String[] http = child.getTextContent().split(" ");
                            currentEndpoint.setUrl(http[1]);

                            final RequestDefinition request = new RequestDefinition();
                            currentEndpoint.getRequests().add(request);
                            request.setVerb(http[0]);
                        }

                        // <ul><li><p>Response 200 (text/plain)</p>
                        if (isEndpointResponse(child.getNodeName())) {
                            final ResponseDefinition response = parseResponseDefinition(child);
View Full Code Here

TOP

Related Classes of com.gatehill.apibms.core.model.RequestDefinition

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.