2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.apihandlerinfra.tenantisolation.mock;
23 import static com.github.tomakehurst.wiremock.client.WireMock.*;
25 import javax.ws.rs.core.MediaType;
27 public class AaiStubResponse {
29 public static String DEFAULT_ERROR_RESPONSE = "{ \"requestError\":{ \"serviceException\" : {\"messageId\": \"500\",\"text\": \"Test error message!\"}}}";
31 public static void setupAllMocks() {}
33 public static void MockGetRequest(String link, int returnCode, String response) {
34 stubFor(get(urlPathEqualTo(link))
35 .willReturn(aResponse()
36 .withHeader("Content-Type", MediaType.APPLICATION_JSON)
37 .withHeader("Accept", MediaType.APPLICATION_JSON)
38 .withStatus(returnCode)
39 .withBody(response)));
42 public static void MockPutRequest(String link, int returnCode, String response) {
43 stubFor(put(urlPathEqualTo(link))
44 .willReturn(aResponse()
45 .withStatus(returnCode)
46 .withHeader("Content-Type", MediaType.APPLICATION_JSON)
47 .withBody(response)));
50 public static void MockPostRequest(String link, int returnCode) {
51 stubFor(post(urlPathEqualTo(link))
52 .willReturn(aResponse()
53 .withHeader("Content-Type", MediaType.APPLICATION_JSON)
54 .withHeader("X-HTTP-Method-Override", "PATCH")
55 .withStatus(returnCode)));