### Question:
S3V4Authentication { static StringBuilder buildCanonicalRequest(MappingHttpRequest request, String signedHeaders, String payloadHash) { StringBuilder sb = new StringBuilder(512); sb.append(request.getMethod().getName()); sb.append('\n'); sb.append(buildCanonicalResourcePath(request.getServicePath())); sb.append('\n'); buildCanonicalQueryString(request.getParameters(), sb); sb.append('\n'); buildCanonicalHeaders(request, signedHeaders, sb); sb.append('\n'); sb.append(signedHeaders); sb.append('\n'); if (payloadHash != null) sb.append(payloadHash); return sb; } private  S3V4Authentication();  static final String AWS_V4_AUTH_TYPE; static final String AWS_CONTENT_SHA_HEADER; static final String AWS_EXPIRES_PARAM; static final String AWS_DECODED_CONTENT_LEN; static final String STREAMING_PAYLOAD; static final String UNSIGNED_PAYLOAD; }### Answer:
@Test public void testBuildCanonicalRequestForHeaders() { StringBuilder canonicalRequest = S3V4Authentication.buildCanonicalRequest(headersRequest, SIGNED_HEADERS, headersRequest.getHeader ("x-amz-content-sha256")); assertEquals(CANONICAL_HEADERS_REQUEST, canonicalRequest.toString()); }
@Test public void testBuildCanonicalRequestForPresigned() { StringBuilder canonicalRequest = S3V4Authentication.buildCanonicalRequest(paramsRequest, "host", "UNSIGNED-PAYLOAD"); assertEquals(CANONICAL_PRESIGNED_REQUEST, canonicalRequest.toString()); }