public String getUrl() { if (getQuery().isEmpty()) { return url; } final String queryString = CollectionUtils.constructQueryString(query); return String.format("%s?%s", url, queryString); }
public static StubRequest createFromHttpServletRequest(final HttpServletRequest request) throws IOException { final StubRequest assertionRequest = StubRequest.newStubRequest( request.getPathInfo(), HandlerUtils.extractPostRequestBody(request, "stubs")); assertionRequest.addMethod(request.getMethod()); final Enumeration<String> headerNamesEnumeration = request.getHeaderNames(); final List<String> headerNames = ObjectUtils.isNotNull(headerNamesEnumeration) ? Collections.list(request.getHeaderNames()) : new LinkedList<String>(); for (final String headerName : headerNames) { final String headerValue = request.getHeader(headerName); assertionRequest.getHeaders().put(StringUtils.toLower(headerName), headerValue); } assertionRequest.getQuery().putAll(CollectionUtils.constructParamMap(request.getQueryString())); return assertionRequest; }