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.post;
25 import static com.github.tomakehurst.wiremock.client.WireMock.get;
26 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
30 * Stub response class for Database stubs
31 * including database adapter, catalog db,
32 * and other databases.
34 public class StubResponseDatabase {
36 public static void setupAllMocks() {
40 public static void MockUpdateRequestDB(String fileName){
41 stubFor(post(urlEqualTo("/services/RequestsDbAdapter"))
42 .willReturn(aResponse()
44 .withHeader("Content-Type", "text/xml")
45 .withBodyFile(fileName)));
48 public static void mockUpdateRequestDB(int statusCode, String reponseFile) {
49 stubFor(post(urlEqualTo("/services/RequestsDbAdapter"))
50 .willReturn(aResponse()
51 .withStatus(statusCode)
52 .withHeader("Content-Type", "text/xml")
53 .withBodyFile(reponseFile)));
56 public static void MockGetAllottedResourcesByModelInvariantId(String modelInvariantId, String responseFile){
57 stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
58 .willReturn(aResponse()
60 .withHeader("Content-Type", "application/json")
61 .withBodyFile(responseFile)));
64 public static void MockGetAllottedResourcesByModelInvariantId_500(String modelInvariantId, String responseFile){
65 stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
66 .willReturn(aResponse()
70 public static void MockGetVnfCatalogDataCustomizationUuid(String vnfModelCustomizationUuid, String responseFile){
71 stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid))
72 .willReturn(aResponse()
74 .withHeader("Content-Type", "application/json")
75 .withBodyFile(responseFile)));
78 public static void MockGetVfModuleByModelNameCatalogData(String vfModuleModelName, String responseFile){
79 stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName))
80 .willReturn(aResponse()
82 .withHeader("Content-Type", "application/json")
83 .withBodyFile(responseFile)));
86 public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String serviceModelVersion, String responseFile){
87 stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid=" +
88 serviceModelInvariantUuid +
89 "&serviceModelVersion=" + serviceModelVersion))
90 .willReturn(aResponse()
92 .withHeader("Content-Type", "application/json")
93 .withBodyFile(responseFile)));
96 public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String responseFile){
97 stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid))
98 .willReturn(aResponse()
100 .withHeader("Content-Type", "application/json")
101 .withBodyFile(responseFile)));
104 public static void MockGetServiceResourcesCatalogDataByModelUuid(String serviceModelUuid, String responseFile){
105 stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=" + serviceModelUuid))
106 .willReturn(aResponse()
108 .withHeader("Content-Type", "application/json")
109 .withBodyFile(responseFile)));
112 public static void MockPostRequestDB(){
113 stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
114 .willReturn(aResponse()
116 .withHeader("Content-Type", "text/xml")));