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;
27 import com.github.tomakehurst.wiremock.WireMockServer;
30 * Stub response class for Database stubs including database adapter, catalog db, and other databases.
32 public class StubResponseDatabase {
34 public static void setupAllMocks() {
38 public static void MockUpdateRequestDB(WireMockServer wireMockServer, String fileName) {
39 wireMockServer.stubFor(post(urlEqualTo("/services/RequestsDbAdapter"))
40 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(fileName)));
43 public static void mockUpdateRequestDB(WireMockServer wireMockServer, int statusCode, String reponseFile) {
44 wireMockServer.stubFor(post(urlEqualTo("/services/RequestsDbAdapter")).willReturn(
45 aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml").withBodyFile(reponseFile)));
48 public static void MockGetAllottedResourcesByModelInvariantId(WireMockServer wireMockServer,
49 String modelInvariantId, String responseFile) {
51 .stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
52 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
53 .withBodyFile(responseFile)));
56 public static void MockGetAllottedResourcesByModelInvariantId_500(WireMockServer wireMockServer,
57 String modelInvariantId, String responseFile) {
59 .stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
60 .willReturn(aResponse().withStatus(500)));
63 public static void MockGetVnfCatalogDataCustomizationUuid(WireMockServer wireMockServer,
64 String vnfModelCustomizationUuid, String responseFile) {
65 wireMockServer.stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid))
66 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
67 .withBodyFile(responseFile)));
70 public static void MockGetVfModuleByModelNameCatalogData(WireMockServer wireMockServer, String vfModuleModelName,
71 String responseFile) {
72 wireMockServer.stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName)).willReturn(
73 aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBodyFile(responseFile)));
76 public static void MockGetServiceResourcesCatalogData(WireMockServer wireMockServer,
77 String serviceModelInvariantUuid, String serviceModelVersion, String responseFile) {
78 wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid="
79 + serviceModelInvariantUuid + "&serviceModelVersion=" + serviceModelVersion))
80 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
81 .withBodyFile(responseFile)));
84 public static void MockGetServiceResourcesCatalogData(WireMockServer wireMockServer,
85 String serviceModelInvariantUuid, String responseFile) {
86 wireMockServer.stubFor(get(urlEqualTo(
87 "/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid))
88 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
89 .withBodyFile(responseFile)));
92 public static void MockGetServiceResourcesCatalogDataByModelUuid(WireMockServer wireMockServer,
93 String serviceModelUuid, String responseFile) {
94 wireMockServer.stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=" + serviceModelUuid)).willReturn(
95 aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBodyFile(responseFile)));
98 public static void MockPostRequestDB(WireMockServer wireMockServer) {
99 wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
100 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")));