private ContainerRequest mockContainerRequest() { ContainerRequest containerRequest = mock(ContainerRequest.class); when(containerRequest.getBaseUri()).thenReturn(baseUri); when(containerRequest.getRequestUri()).thenReturn(requestUri); when(containerRequest.getMethod()).thenReturn(httpMethod); when(containerRequest.getRequestHeaders()).thenReturn(requestHeaders); return containerRequest; }
private void setHeaders(MultivaluedMap<String, Object> headers) { this.headers = headers; Object location = headers.getFirst(HttpHeaders.LOCATION); if (location != null) { if (location instanceof URI) { final URI locationUri = (URI) location; if (!locationUri.isAbsolute()) { final URI base = (statusType.getStatusCode() == Status.CREATED.getStatusCode()) ? request.getAbsolutePath() : request.getBaseUri(); location = UriBuilder.fromUri(base) .path(locationUri.getRawPath()) .replaceQuery(locationUri.getRawQuery()) .fragment(locationUri.getRawFragment()) .build(); } headers.putSingle(HttpHeaders.LOCATION, location); } } }