2 * ============LICENSE_START=======================================================
3 * org.onap.dcaegen2.collectors.ves
4 * ================================================================================
5 * Copyright (C) 2018 Nokia. All rights reserved.
6 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.dcae;
24 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
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;
28 import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
29 import static io.vavr.API.Map;
31 import com.github.tomakehurst.wiremock.junit.WireMockRule;
32 import io.vavr.collection.Map;
33 import org.junit.Rule;
36 * @author Pawel Szalapski (pawel.szalapski@nokia.com)
38 public class WiremockBasedTest {
41 public WireMockRule wireMockRule = new WireMockRule(
42 wireMockConfig().dynamicPort().dynamicHttpsPort().keystorePath(null));
44 protected void stubConsulToReturnLocalAddressOfCBS() {
45 stubFor(get(urlEqualTo("/v1/catalog/service/CBSName"))
46 .willReturn(aResponse().withBody(validLocalCBSConf())));
49 protected void stubCBSToReturnAppConfig(String sampleConfigForVES) {
50 stubFor(get(urlEqualTo("/service_component/VESCollector"))
51 .willReturn(aResponse().withBody(sampleConfigForVES)));
54 protected Map<String, String> wiremockBasedEnvProps() {
56 "CONSUL_HOST", "localhost",
57 "CONSUL_PORT", "" + wireMockRule.port(),
58 "HOSTNAME", "VESCollector",
59 "CONFIG_BINDING_SERVICE", "CBSName"
63 protected String validLocalCBSConf() {
66 + "\"ServiceAddress\": \"localhost\","
67 + "\"ServicePort\":" + wireMockRule.port()