Merge "Reorder modifiers"
[so.git] / mso-api-handlers / mso-api-handler-infra / src / test / java / org / openecomp / mso / apihandlerinfra / tenantisolation / mock / AaiStubResponse.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.openecomp.mso.apihandlerinfra.tenantisolation.mock;
22
23 import static com.github.tomakehurst.wiremock.client.WireMock.*;
24
25 import javax.ws.rs.core.MediaType;
26
27 public class AaiStubResponse {
28         
29         public static String DEFAULT_ERROR_RESPONSE = "{ \"requestError\":{ \"serviceException\" : {\"messageId\": \"500\",\"text\": \"Test error message!\"}}}";
30         
31         public static void setupAllMocks() {}
32         
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)));
40         }
41         
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)));
48         }
49         
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)));
56         }
57 }