Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / onap / so / bpmn / mock / StubResponseDatabase.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.bpmn.mock;
22
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;
28
29 /**
30  * Stub response class for Database stubs including database adapter, catalog db, and other databases.
31  */
32 public class StubResponseDatabase {
33
34     public static void setupAllMocks() {
35
36     }
37
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)));
41     }
42
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)));
46     }
47
48     public static void MockGetAllottedResourcesByModelInvariantId(WireMockServer wireMockServer,
49             String modelInvariantId, String responseFile) {
50         wireMockServer
51                 .stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
52                         .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
53                                 .withBodyFile(responseFile)));
54     }
55
56     public static void MockGetAllottedResourcesByModelInvariantId_500(WireMockServer wireMockServer,
57             String modelInvariantId, String responseFile) {
58         wireMockServer
59                 .stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
60                         .willReturn(aResponse().withStatus(500)));
61     }
62
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)));
68     }
69
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)));
74     }
75
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)));
82     }
83
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)));
90     }
91
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)));
96     }
97
98     public static void MockPostRequestDB(WireMockServer wireMockServer) {
99         wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
100                 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")));
101     }
102 }