2 * ============LICENSE_START=======================================================
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
19 package org.openecomp.mso.bpmn.mock;
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;
28 * Stub response class for Database stubs
29 * including database adapter, catalog db,
30 * and other databases.
32 public class StubResponseDatabase {
34 public static void setupAllMocks() {
38 public static void MockUpdateRequestDB(String fileName){
39 stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
40 .willReturn(aResponse()
42 .withHeader("Content-Type", "text/xml")
43 .withBodyFile(fileName)));
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)));
54 public static void MockGetAllottedResourcesByModelInvariantId(String modelInvariantId, String responseFile){
55 stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
56 .willReturn(aResponse()
58 .withHeader("Content-Type", "application/json")
59 .withBodyFile(responseFile)));
62 public static void MockGetAllottedResourcesByModelInvariantId_500(String modelInvariantId, String responseFile){
63 stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
64 .willReturn(aResponse()
68 public static void MockGetVnfCatalogDataCustomizationUuid(String vnfModelCustomizationUuid, String responseFile){
69 stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid))
70 .willReturn(aResponse()
72 .withHeader("Content-Type", "application/json")
73 .withBodyFile(responseFile)));
76 public static void MockGetVfModuleByModelNameCatalogData(String vfModuleModelName, String responseFile){
77 stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName))
78 .willReturn(aResponse()
80 .withHeader("Content-Type", "application/json")
81 .withBodyFile(responseFile)));
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()
89 .withHeader("Content-Type", "application/json")
90 .withBodyFile(responseFile)));
93 public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String responseFile){
94 stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid))
95 .willReturn(aResponse()
97 .withHeader("Content-Type", "application/json")
98 .withBodyFile(responseFile)));
101 public static void MockGetServiceResourcesCatalogDataByModelUuid(String serviceModelUuid, String responseFile){
102 stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=" + serviceModelUuid))
103 .willReturn(aResponse()
105 .withHeader("Content-Type", "application/json")
106 .withBodyFile(responseFile)));