Change the header to SO
[so.git] / bpmn / MSOMockServer / src / main / java / org / openecomp / mso / bpmn / mock / StubResponseDatabase.java
1 /*
2  * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
3  */
4 /*- 
5  * ============LICENSE_START======================================================= 
6  * ONAP - SO 
7  * ================================================================================ 
8  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. 
9  * ================================================================================ 
10  * Licensed under the Apache License, Version 2.0 (the "License"); 
11  * you may not use this file except in compliance with the License. 
12  * You may obtain a copy of the License at 
13  * 
14  *      http://www.apache.org/licenses/LICENSE-2.0 
15  * 
16  * Unless required by applicable law or agreed to in writing, software 
17  * distributed under the License is distributed on an "AS IS" BASIS, 
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
19  * See the License for the specific language governing permissions and 
20  * limitations under the License. 
21  * ============LICENSE_END========================================================= 
22  */ 
23
24 package org.openecomp.mso.bpmn.mock;
25
26 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
27 import static com.github.tomakehurst.wiremock.client.WireMock.post;
28 import static com.github.tomakehurst.wiremock.client.WireMock.get;
29 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
30 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
31
32 /**
33  * Stub response class for Database stubs
34  * including database adapter, catalog db,
35  * and other databases.
36  */
37 public class StubResponseDatabase {
38
39         public static void setupAllMocks() {
40
41         }
42
43         public static void MockUpdateRequestDB(String fileName){
44                 stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
45                                 .willReturn(aResponse()
46                                 .withStatus(200)
47                             .withHeader("Content-Type", "text/xml")
48                                 .withBodyFile(fileName)));
49         }       
50         
51         public static void mockUpdateRequestDB(int statusCode, String reponseFile) {
52                 stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
53                                 .willReturn(aResponse()
54                                 .withStatus(statusCode)
55                             .withHeader("Content-Type", "text/xml")
56                                 .withBodyFile(reponseFile)));
57         }
58
59         public static void MockGetAllottedResourcesByModelInvariantId(String modelInvariantId, String responseFile){
60                 stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
61                                 .willReturn(aResponse()
62                                 .withStatus(200)
63                             .withHeader("Content-Type", "application/json")
64                                 .withBodyFile(responseFile)));
65         }
66
67         public static void MockGetAllottedResourcesByModelInvariantId_500(String modelInvariantId, String responseFile){
68                 stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
69                                 .willReturn(aResponse()
70                                 .withStatus(500)));
71         }
72         
73         public static void MockGetVnfCatalogDataCustomizationUuid(String vnfModelCustomizationUuid,  String responseFile){
74                 stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid))
75                                   .willReturn(aResponse()
76                                   .withStatus(200)
77                                   .withHeader("Content-Type", "application/json")
78                                   .withBodyFile(responseFile)));
79         }
80
81         public static void MockGetVfModuleByModelNameCatalogData(String vfModuleModelName, String responseFile){
82                 stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName))
83                                   .willReturn(aResponse()
84                                   .withStatus(200)
85                                   .withHeader("Content-Type", "application/json")
86                                   .withBodyFile(responseFile)));
87         }
88         
89         public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String serviceModelVersion, String responseFile){
90                 stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid + 
91                                 "&serviceModelVersion=" + serviceModelVersion))
92                                   .willReturn(aResponse()
93                                   .withStatus(200)
94                                   .withHeader("Content-Type", "application/json")
95                                   .withBodyFile(responseFile)));
96         }
97         
98         public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String responseFile){
99                 stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid))
100                                   .willReturn(aResponse()
101                                   .withStatus(200)
102                                   .withHeader("Content-Type", "application/json")
103                                   .withBodyFile(responseFile)));
104         }       
105         
106
107 }