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