1 /* 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"). 5 * You may not use this file except in compliance with the License. 6 * A copy of the License is located at 7 * 8 * http://aws.amazon.com/apache2.0 9 * 10 * or in the "license" file accompanying this file. This file is distributed 11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 * express or implied. See the License for the specific language governing 13 * permissions and limitations under the License. 14 */ 15 16 package software.amazon.awssdk.protocol.tests.util.exception; 17 18 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; 19 import static com.github.tomakehurst.wiremock.client.WireMock.post; 20 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; 21 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; 22 23 public class ExceptionTestUtils { 24 25 /** 26 * Convenience method to configure WireMock to stub a 404 response for the specified path with 27 * the given body. 28 * 29 * @param path Matching path to stub for 30 * @param body Body to return in 404 response. 31 */ stub404Response(String path, String body)32 public static void stub404Response(String path, String body) { 33 stubFor(post(urlEqualTo(path)).willReturn(aResponse().withStatus(404).withBody(body))); 34 } 35 } 36