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.onap.so.bpmn.mock;
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
24 import static com.github.tomakehurst.wiremock.client.WireMock.get;
25 import static com.github.tomakehurst.wiremock.client.WireMock.post;
26 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
28 import com.github.tomakehurst.wiremock.WireMockServer;
31 * Stub response class for Database stubs
32 * including database adapter, catalog db,
33 * and other databases.
35 public class StubResponseDatabase {
37 public static void setupAllMocks() {
41 public static void MockUpdateRequestDB(WireMockServer wireMockServer, String fileName){
42 wireMockServer.stubFor(post(urlEqualTo("/services/RequestsDbAdapter"))
43 .willReturn(aResponse()
45 .withHeader("Content-Type", "text/xml")
46 .withBodyFile(fileName)));
49 public static void mockUpdateRequestDB(WireMockServer wireMockServer, int statusCode, String reponseFile) {
50 wireMockServer.stubFor(post(urlEqualTo("/services/RequestsDbAdapter"))
51 .willReturn(aResponse()
52 .withStatus(statusCode)
53 .withHeader("Content-Type", "text/xml")
54 .withBodyFile(reponseFile)));
57 public static void MockGetAllottedResourcesByModelInvariantId(WireMockServer wireMockServer, String modelInvariantId, String responseFile){
58 wireMockServer.stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
59 .willReturn(aResponse()
61 .withHeader("Content-Type", "application/json")
62 .withBodyFile(responseFile)));
65 public static void MockGetAllottedResourcesByModelInvariantId_500(WireMockServer wireMockServer, String modelInvariantId, String responseFile){
66 wireMockServer.stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
67 .willReturn(aResponse()
71 public static void MockGetVnfCatalogDataCustomizationUuid(WireMockServer wireMockServer, String vnfModelCustomizationUuid, String responseFile){
72 wireMockServer.stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid))
73 .willReturn(aResponse()
75 .withHeader("Content-Type", "application/json")
76 .withBodyFile(responseFile)));
79 public static void MockGetVfModuleByModelNameCatalogData(WireMockServer wireMockServer, String vfModuleModelName, String responseFile){
80 wireMockServer.stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName))
81 .willReturn(aResponse()
83 .withHeader("Content-Type", "application/json")
84 .withBodyFile(responseFile)));
87 public static void MockGetServiceResourcesCatalogData(WireMockServer wireMockServer, String serviceModelInvariantUuid, String serviceModelVersion, String responseFile){
88 wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid=" +
89 serviceModelInvariantUuid +
90 "&serviceModelVersion=" + serviceModelVersion))
91 .willReturn(aResponse()
93 .withHeader("Content-Type", "application/json")
94 .withBodyFile(responseFile)));
97 public static void MockGetServiceResourcesCatalogData(WireMockServer wireMockServer, String serviceModelInvariantUuid, String responseFile){
98 wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid))
99 .willReturn(aResponse()
101 .withHeader("Content-Type", "application/json")
102 .withBodyFile(responseFile)));
105 public static void MockGetServiceResourcesCatalogDataByModelUuid(WireMockServer wireMockServer, String serviceModelUuid, String responseFile){
106 wireMockServer.stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=" + serviceModelUuid))
107 .willReturn(aResponse()
109 .withHeader("Content-Type", "application/json")
110 .withBodyFile(responseFile)));
113 public static void MockPostRequestDB(WireMockServer wireMockServer){
114 wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
115 .willReturn(aResponse()
117 .withHeader("Content-Type", "text/xml")));