summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorPawel <pawel.kasperkiewicz@nokia.com>2020-07-30 16:30:39 +0200
committerPawel <pawel.kasperkiewicz@nokia.com>2020-08-26 08:42:44 +0200
commit50592c30fed4908bbf860f9018cc5f94f8bd2303 (patch)
tree151aefb0b21e3fbabc89c39a5731643bbbdd4edb /src/test
parent79efedef7af08038b49821c410db1b11e038f653 (diff)
Config fetch for VESCollector through DCAE-SDK (CBS Client)
Issue-ID: DCAEGEN2-2212 Signed-off-by: Pawel <pawel.kasperkiewicz@nokia.com> Change-Id: I25072b340b5c9f2f538d39e5befb1331804b7bba Signed-off-by: Pawel <pawel.kasperkiewicz@nokia.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/dcae/TLSTestBase.java10
-rw-r--r--src/test/java/org/onap/dcae/TestingUtilities.java27
-rw-r--r--src/test/java/org/onap/dcae/WiremockBasedTest.java70
-rw-r--r--src/test/java/org/onap/dcae/common/EventSenderTest.java6
-rw-r--r--src/test/java/org/onap/dcae/common/publishing/DMaaPEventPublisherTest.java4
-rw-r--r--src/test/java/org/onap/dcae/configuration/ConfigFilesFacadeTest.java (renamed from src/test/java/org/onap/dcae/controller/ConfigFilesFacadeTest.java)8
-rw-r--r--src/test/java/org/onap/dcae/configuration/ConfigLoaderFactoryTest.java (renamed from src/test/java/org/onap/dcae/controller/EnvPropsTest.java)36
-rw-r--r--src/test/java/org/onap/dcae/configuration/ConfigLoaderTest.java294
-rw-r--r--src/test/java/org/onap/dcae/configuration/ConfigParsingTest.java (renamed from src/test/java/org/onap/dcae/controller/ConfigParsingTest.java)16
-rw-r--r--src/test/java/org/onap/dcae/configuration/cbs/CbsClientConfigurationResolverTest.java47
-rw-r--r--src/test/java/org/onap/dcae/configuration/cbs/CbsClientFactoryTest.java36
-rw-r--r--src/test/java/org/onap/dcae/configuration/cbs/CbsConfigResolverTest.java74
-rw-r--r--src/test/java/org/onap/dcae/controller/ConfigCBSSourceTest.java153
-rw-r--r--src/test/java/org/onap/dcae/controller/ConfigLoaderIntegrationE2ETest.java93
-rw-r--r--src/test/java/org/onap/dcae/controller/EnvPropertiesReaderTest.java69
-rw-r--r--src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java6
16 files changed, 501 insertions, 448 deletions
diff --git a/src/test/java/org/onap/dcae/TLSTestBase.java b/src/test/java/org/onap/dcae/TLSTestBase.java
index 1eb5728e..1026e759 100644
--- a/src/test/java/org/onap/dcae/TLSTestBase.java
+++ b/src/test/java/org/onap/dcae/TLSTestBase.java
@@ -2,9 +2,8 @@
* ============LICENSE_START=======================================================
* org.onap.dcaegen2.collectors.ves
* ================================================================================
- * Copyright (C) 2018 Nokia. All rights reserved.
+ * Copyright (C) 2018-2020 Nokia. All rights reserved.
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2019 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -136,13 +135,6 @@ public class TLSTestBase {
return createHttpsRestTemplate().getForEntity(createHttpsURL("/"), String.class);
}
-
- public ResponseEntity<String> makeHttpsRequestWithBasicAuth(final String username, final String password) {
- return addBasicAuth(createHttpsRestTemplate(), username, password)
- .getForEntity(createHttpsURL("/"), String.class);
-
- }
-
public ResponseEntity<String> makeHttpsRequestWithClientCert() {
return createHttpsRestTemplateWithKeyStore().getForEntity(createHttpsURL("/"), String.class);
}
diff --git a/src/test/java/org/onap/dcae/TestingUtilities.java b/src/test/java/org/onap/dcae/TestingUtilities.java
index 4c0d5382..8fb89154 100644
--- a/src/test/java/org/onap/dcae/TestingUtilities.java
+++ b/src/test/java/org/onap/dcae/TestingUtilities.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.dcaegen2.collectors.ves
* ================================================================================
- * Copyright (C) 2018 Nokia. All rights reserved.
+ * Copyright (C) 2018,2020 Nokia. All rights reserved.
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,23 +20,7 @@
*/
package org.onap.dcae;
-import static java.nio.file.Files.readAllBytes;
-import static org.assertj.core.api.Assertions.assertThat;
-
import io.vavr.control.Try;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
-
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.HttpClients;
@@ -48,6 +32,15 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext;
+import java.io.File;
+import java.io.FileInputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.KeyStore;
+
+import static java.nio.file.Files.readAllBytes;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Pawel Szalapski (pawel.szalapski@nokia.com)
diff --git a/src/test/java/org/onap/dcae/WiremockBasedTest.java b/src/test/java/org/onap/dcae/WiremockBasedTest.java
deleted file mode 100644
index 3b4bdc39..00000000
--- a/src/test/java/org/onap/dcae/WiremockBasedTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.onap.dcaegen2.collectors.ves
- * ================================================================================
- * Copyright (C) 2018 Nokia. All rights reserved.
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.dcae;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import static io.vavr.API.Map;
-
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import io.vavr.collection.Map;
-import org.junit.Rule;
-
-/**
- * @author Pawel Szalapski (pawel.szalapski@nokia.com)
- */
-public class WiremockBasedTest {
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(
- wireMockConfig().dynamicPort().dynamicHttpsPort().keystorePath(null));
-
- protected void stubConsulToReturnLocalAddressOfCBS() {
- stubFor(get(urlEqualTo("/v1/catalog/service/CBSName"))
- .willReturn(aResponse().withBody(validLocalCBSConf())));
- }
-
- protected void stubCBSToReturnAppConfig(String sampleConfigForVES) {
- stubFor(get(urlEqualTo("/service_component/VESCollector"))
- .willReturn(aResponse().withBody(sampleConfigForVES)));
- }
-
- protected Map<String, String> wiremockBasedEnvProps() {
- return Map(
- "CONSUL_HOST", "localhost",
- "CONSUL_PORT", "" + wireMockRule.port(),
- "HOSTNAME", "VESCollector",
- "CONFIG_BINDING_SERVICE", "CBSName"
- );
- }
-
- protected String validLocalCBSConf() {
- return ""
- + "[{ "
- + "\"ServiceAddress\": \"localhost\","
- + "\"ServicePort\":" + wireMockRule.port()
- + "}]";
- }
-}
diff --git a/src/test/java/org/onap/dcae/common/EventSenderTest.java b/src/test/java/org/onap/dcae/common/EventSenderTest.java
index e20fa993..454cfb52 100644
--- a/src/test/java/org/onap/dcae/common/EventSenderTest.java
+++ b/src/test/java/org/onap/dcae/common/EventSenderTest.java
@@ -3,7 +3,7 @@
* PROJECT
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2020 Nokia. All rights reserved.s
+ * Copyright (C) 2018,2020 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.dcae.common.model.StndDefinedNamespaceParameterNotDefinedException;
import org.onap.dcae.common.model.VesEvent;
-import org.onap.dcae.common.publishing.EventPublisher;
+import org.onap.dcae.common.publishing.DMaaPEventPublisher;
import java.io.IOException;
import java.util.List;
@@ -43,7 +43,7 @@ import static org.mockito.Mockito.verify;
public class EventSenderTest {
@Mock
- private EventPublisher eventPublisher;
+ private DMaaPEventPublisher eventPublisher;
@Test
diff --git a/src/test/java/org/onap/dcae/common/publishing/DMaaPEventPublisherTest.java b/src/test/java/org/onap/dcae/common/publishing/DMaaPEventPublisherTest.java
index 45cdf282..99505bfd 100644
--- a/src/test/java/org/onap/dcae/common/publishing/DMaaPEventPublisherTest.java
+++ b/src/test/java/org/onap/dcae/common/publishing/DMaaPEventPublisherTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.dcaegen2.collectors.ves
* ================================================================================
- * Copyright (C) 2018 Nokia. All rights reserved.
+ * Copyright (C) 2018,2020 Nokia. All rights reserved.
* Copyright (C) 2020 AT&T. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -47,7 +47,7 @@ public class DMaaPEventPublisherTest {
cambriaPublisher = mock(CambriaBatchingPublisher.class);
DMaaPPublishersCache = mock(DMaaPPublishersCache.class);
when(DMaaPPublishersCache.getPublisher(anyString())).thenReturn(Option(cambriaPublisher));
- eventPublisher = new DMaaPEventPublisher(DMaaPPublishersCache, mock(Logger.class));
+ eventPublisher = new DMaaPEventPublisher(DMaaPPublishersCache);
}
@Test
diff --git a/src/test/java/org/onap/dcae/controller/ConfigFilesFacadeTest.java b/src/test/java/org/onap/dcae/configuration/ConfigFilesFacadeTest.java
index 474a77c5..8849369a 100644
--- a/src/test/java/org/onap/dcae/controller/ConfigFilesFacadeTest.java
+++ b/src/test/java/org/onap/dcae/configuration/ConfigFilesFacadeTest.java
@@ -3,7 +3,7 @@
* org.onap.dcaegen2.collectors.ves
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2018 Nokia. All rights reserved.
+ * Copyright (C) 2018,2020 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.dcae.controller;
+package org.onap.dcae.configuration;
import static io.vavr.API.Map;
import static io.vavr.API.Some;
@@ -134,6 +134,4 @@ public class ConfigFilesFacadeTest {
assertThat(result.isFailure()).isTrue();
assertFailureHasInfo(result, NON_EXISTENT.toString());
}
-
-}
-
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dcae/controller/EnvPropsTest.java b/src/test/java/org/onap/dcae/configuration/ConfigLoaderFactoryTest.java
index ccc083e2..e9421909 100644
--- a/src/test/java/org/onap/dcae/controller/EnvPropsTest.java
+++ b/src/test/java/org/onap/dcae/configuration/ConfigLoaderFactoryTest.java
@@ -1,4 +1,3 @@
-package org.onap.dcae.controller;
/*-
* ============LICENSE_START=======================================================
* org.onap.dcaegen2.collectors.ves
@@ -18,22 +17,27 @@ package org.onap.dcae.controller;
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-import org.jetbrains.annotations.NotNull;
-import org.junit.Test;
+package org.onap.dcae.configuration;
+
import static org.assertj.core.api.Assertions.assertThat;
-public class EnvPropsTest {
+
+import java.nio.file.Path;
+import org.junit.Test;
+
+public class ConfigLoaderFactoryTest {
+
@Test
- public void shouldBeEquals() {
+ public void createsCbsConfigLoaderSuccessfully() {
// given
- EnvProps envPropsOriginal = givenEnvProps();
- EnvProps envPropsCopy = givenEnvProps();
- // when/then
- assertThat(envPropsOriginal).isEqualTo(envPropsCopy);
- assertThat(envPropsOriginal.hashCode()).isEqualTo(envPropsCopy.hashCode());
- }
- @NotNull
- private EnvProps givenEnvProps() {
- return new EnvProps("https", "localhost", 443,
- "https", "cbsName", "appName");
+ Path testPropertiesPath = Path.of("src/test/resources/testcollector.properties");
+ Path testDmaapConfigPath = Path.of("src/test/resources/testParseDMaaPCredentialsGen2.json");
+
+ // when
+ ConfigLoader configLoader = ConfigLoaderFactory.create(
+ testPropertiesPath,
+ testDmaapConfigPath);
+
+ // then
+ assertThat(configLoader).isNotNull();
}
-}
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dcae/configuration/ConfigLoaderTest.java b/src/test/java/org/onap/dcae/configuration/ConfigLoaderTest.java
new file mode 100644
index 00000000..46d864a0
--- /dev/null
+++ b/src/test/java/org/onap/dcae/configuration/ConfigLoaderTest.java
@@ -0,0 +1,294 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dcaegen2.collectors.ves
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.configuration;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.dcae.TestingUtilities.readJSONFromFile;
+import static org.onap.dcae.common.publishing.VavrUtils.f;
+
+import io.vavr.collection.HashMap;
+import io.vavr.collection.Map;
+import io.vavr.control.Try;
+import java.nio.file.Paths;
+import io.vavr.control.Option;
+import org.json.JSONObject;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.dcae.configuration.cbs.CbsConfigResolver;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class ConfigLoaderTest {
+
+ private static final String COLLECTOR_PORT = "collector.port";
+ private static final String PORT_8080 = "8080";
+ private static final String PORT_8081 = "8081";
+ private static final String COLLECTOR_KEYSTORE_FILE_LOCATION = "collector.keystore.file.location";
+ private static final String SOME_PATH = "some/path";
+ private static final String COLLECTOR_SCHEMA_FILE = "collector.schema.file";
+ private static final String SOME_SCHEMA = "some schema";
+
+ @Mock
+ private CbsConfigResolver cbsConfigResolverMock;
+
+ @Mock
+ private ConfigFilesFacade configFilesFacadeMock;
+
+ @InjectMocks
+ private ConfigLoader configLoader;
+
+ @Mock
+ private Runnable applicationRestarter;
+
+
+ @Before
+ public void setup() {
+ when(configFilesFacadeMock.readCollectorProperties()).thenReturn(Try.of(HashMap::empty));
+ when(configFilesFacadeMock.readDMaaPConfiguration()).thenReturn(Try.of(JSONObject::new));
+ }
+
+ @Test
+ public void shouldCallConfigSourceForData() {
+ // given
+ HashMap<String, String> properties = HashMap.of(COLLECTOR_PORT, PORT_8080);
+ mockVesInitialProperties(properties);
+ mockVesConfigInCbs(properties);
+
+ // when
+ configLoader.updateConfig();
+
+ // then
+ verify(cbsConfigResolverMock).getAppConfig();
+ }
+
+ @Test
+ public void shouldNotUpdatePropertiesWhenSameKeySetAndSameValues() {
+ // given
+ HashMap<String, String> properties = HashMap.of(COLLECTOR_PORT, PORT_8080);
+ mockVesInitialProperties(properties);
+ mockVesConfigInCbs(properties);
+
+ // when
+ configLoader.updateConfig();
+
+ // then
+ verify(configFilesFacadeMock, never()).writeProperties(any());
+ verify(applicationRestarter, never()).run();
+ }
+
+ @Test
+ public void shouldUpdatePropertiesWhenSameKeySetButDifferentValues() {
+ // given
+ HashMap<String, String> initialProperties = HashMap.of(COLLECTOR_PORT, PORT_8080);
+ HashMap<String, String> cbsProperties = HashMap.of(COLLECTOR_PORT, PORT_8081);
+ mockVesInitialProperties(initialProperties);
+ mockVesConfigInCbs(cbsProperties);
+
+ // when
+ configLoader.updateConfig();
+
+ // then
+ verify(configFilesFacadeMock, times(1)).writeProperties(cbsProperties);
+ verify(applicationRestarter, times(1)).run();
+ }
+
+ @Test
+ public void shouldUpdatePropertiesWhenVesKeysAreSubsetOfCbsKeysAndSubsetHasSameValues() {
+ // given
+ HashMap<String, String> initialProperties = HashMap.of(
+ COLLECTOR_PORT, PORT_8080);
+ HashMap<String, String> cbsProperties = HashMap.of(
+ COLLECTOR_PORT, PORT_8080,
+ COLLECTOR_KEYSTORE_FILE_LOCATION, SOME_PATH);
+ mockVesInitialProperties(initialProperties);
+ mockVesConfigInCbs(cbsProperties);
+
+ // when
+ configLoader.updateConfig();
+
+ // then
+ verify(configFilesFacadeMock, times(1)).writeProperties(cbsProperties);
+ verify(applicationRestarter, times(1)).run();
+ }
+
+ @Test
+ public void shouldUpdatePropertiesWhenVesKeysAreSubsetOfCbsKeysAndSubsetHasDifferentValues() {
+ HashMap<String, String> initialProperties = HashMap.of(
+ COLLECTOR_PORT, PORT_8080);
+ HashMap<String, String> cbsProperties = HashMap.of(
+ COLLECTOR_PORT, PORT_8081,
+ COLLECTOR_KEYSTORE_FILE_LOCATION, SOME_PATH);
+ mockVesInitialProperties(initialProperties);
+ mockVesConfigInCbs(cbsProperties);
+
+ // when
+ configLoader.updateConfig();
+
+ // then
+ verify(configFilesFacadeMock, times(1)).writeProperties(cbsProperties);
+ verify(applicationRestarter, times(1)).run();
+ }
+
+ @Test
+ public void shouldNotUpdatePropertiesWhenCbsKeysAreSubsetOfVesKeysAndSubsetHasSameValues() {
+ HashMap<String, String> initialProperties = HashMap.of(
+ COLLECTOR_PORT, PORT_8080,
+ COLLECTOR_KEYSTORE_FILE_LOCATION, SOME_PATH);
+ HashMap<String, String> cbsProperties = HashMap.of(
+ COLLECTOR_PORT, PORT_8080);
+ mockVesInitialProperties(initialProperties);
+ mockVesConfigInCbs(cbsProperties);
+
+ // when
+ configLoader.updateConfig();
+
+ // then
+ verify(configFilesFacadeMock, never()).writeProperties(any());
+ verify(applicationRestarter, never()).run();
+ }
+
+ @Test
+ public void shouldUpdatePropertiesWhenCbsKeysAreSubsetOfVesKeysAndSubsetHasDifferentValues() {
+ HashMap<String, String> initialProperties = HashMap.of(
+ COLLECTOR_PORT, PORT_8080,
+ COLLECTOR_KEYSTORE_FILE_LOCATION, SOME_PATH);
+ HashMap<String, String> cbsProperties = HashMap.of(
+ COLLECTOR_PORT, PORT_8081);
+ mockVesInitialProperties(initialProperties);
+ mockVesConfigInCbs(cbsProperties);
+
+ // when
+ configLoader.updateConfig();
+
+ // then
+ verify(configFilesFacadeMock, times(1)).writeProperties(cbsProperties);
+ verify(applicationRestarter, times(1)).run();
+ }
+
+ @Test
+ public void shouldUpdatePropertiesWhenVesAndCbsKeySetsIntersectAndIntersectingKeysHaveSameValues() {
+ HashMap<String, String> initialProperties = HashMap.of(
+ COLLECTOR_PORT, PORT_8080,
+ COLLECTOR_KEYSTORE_FILE_LOCATION, SOME_PATH);
+ HashMap<String, String> cbsProperties = HashMap.of(
+ COLLECTOR_PORT, PORT_8080,
+ COLLECTOR_SCHEMA_FILE, SOME_SCHEMA
+ );
+ mockVesInitialProperties(initialProperties);
+ mockVesConfigInCbs(cbsProperties);
+
+ // when
+ configLoader.updateConfig();
+
+ // then
+ verify(configFilesFacadeMock, times(1)).writeProperties(cbsProperties);
+ verify(applicationRestarter, times(1)).run();
+ }
+
+ @Test
+ public void shouldUpdatePropertiesWhenVesAndCbsKeySetsIntersectAndIntersectingKeysHaveDifferentValues() {
+ HashMap<String, String> initialProperties = HashMap.of(
+ COLLECTOR_PORT, PORT_8080,
+ COLLECTOR_KEYSTORE_FILE_LOCATION, SOME_PATH);
+ HashMap<String, String> cbsProperties = HashMap.of(
+ COLLECTOR_PORT, PORT_8081,
+ COLLECTOR_SCHEMA_FILE, SOME_SCHEMA
+ );
+ mockVesInitialProperties(initialProperties);
+ mockVesConfigInCbs(cbsProperties);
+
+ // when
+ configLoader.updateConfig();
+
+ // then
+ verify(configFilesFacadeMock, times(1)).writeProperties(cbsProperties);
+ verify(applicationRestarter, times(1)).run();
+ }
+
+ @Test
+ public void shouldUpdateDmaapConfigWhenConfigurationChanged() {
+ // given
+ JSONObject emptyDmaapConfig = new JSONObject();
+ JSONObject dmaapConfig = loadSampleDmaapConfig();
+ mockVesInitialDmaapConfig(emptyDmaapConfig);
+ mockVesDmaapConfigInCbs(dmaapConfig);
+
+ // when
+ configLoader.updateConfig();
+
+ // then
+ verify(configFilesFacadeMock).writeDMaaPConfiguration(argThat(dmaapConfig::similar));
+ verify(applicationRestarter, times(1)).run();
+ }
+
+ @Test
+ public void shouldNotUpdateDmaapConfigWhenConfigurationNotChanged() {
+ // given
+ JSONObject dmaapConf = loadSampleDmaapConfig();
+ mockVesInitialDmaapConfig(dmaapConf);
+ mockVesDmaapConfigInCbs(dmaapConf);
+
+ // when
+ configLoader.updateConfig();
+
+ // then
+ verify(configFilesFacadeMock, never()).writeDMaaPConfiguration(any());
+ verify(applicationRestarter, never()).run();
+ }
+
+ private void mockVesInitialDmaapConfig(JSONObject dmaapConf) {
+ when(configFilesFacadeMock.readDMaaPConfiguration()).thenReturn(Try.of(() -> dmaapConf));
+ }
+
+ private void mockVesDmaapConfigInCbs(JSONObject dmaapConf) {
+ JSONObject jsonObject = new JSONObject(f("{\"streams_publishes\": %s}}", dmaapConf));
+ when(cbsConfigResolverMock.getAppConfig()).thenReturn(Option.of(jsonObject));
+ }
+
+ private void mockVesConfigInCbs(HashMap<String, String> properties) {
+ when(cbsConfigResolverMock.getAppConfig()).thenReturn(Option.of(prepareConfigurationJson(properties)));
+ }
+
+ private void mockVesInitialProperties(HashMap<String, String> properties) {
+ when(configFilesFacadeMock.readCollectorProperties()).thenReturn(Try.of(() -> properties));
+ }
+
+
+ private JSONObject loadSampleDmaapConfig() {
+ return readJSONFromFile(Paths.get("src/test/resources/testParseDMaaPCredentialsGen2.json"));
+ }
+
+ private JSONObject prepareConfigurationJson(Map<String, String> properties) {
+ String template = "{%s, \"streams_publishes\": {}}";
+ String customProperties = properties
+ .map(property -> "\"" + property._1 + "\": \"" + property._2 + "\"")
+ .mkString(", ");
+ String jsonBody = f(template, customProperties);
+ return new JSONObject(jsonBody);
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dcae/controller/ConfigParsingTest.java b/src/test/java/org/onap/dcae/configuration/ConfigParsingTest.java
index 5d8d4efa..248d3c5a 100644
--- a/src/test/java/org/onap/dcae/controller/ConfigParsingTest.java
+++ b/src/test/java/org/onap/dcae/configuration/ConfigParsingTest.java
@@ -3,7 +3,7 @@
* org.onap.dcaegen2.collectors.ves
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2018 Nokia. All rights reserved.
+ * Copyright (C) 2018,2020 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,20 +19,20 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.dcae.controller;
+package org.onap.dcae.configuration;
+import io.vavr.collection.Map;
+import io.vavr.control.Option;
+import org.json.JSONObject;
+import org.junit.Test;
+
+import java.nio.file.Paths;
import static io.vavr.API.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.onap.dcae.TestingUtilities.assertJSONObjectsEqual;
import static org.onap.dcae.TestingUtilities.readJSONFromFile;
-import io.vavr.collection.Map;
-import io.vavr.control.Option;
-import java.nio.file.Paths;
-import org.json.JSONObject;
-import org.junit.Test;
-
public class ConfigParsingTest {
@Test
diff --git a/src/test/java/org/onap/dcae/configuration/cbs/CbsClientConfigurationResolverTest.java b/src/test/java/org/onap/dcae/configuration/cbs/CbsClientConfigurationResolverTest.java
new file mode 100644
index 00000000..57824595
--- /dev/null
+++ b/src/test/java/org/onap/dcae/configuration/cbs/CbsClientConfigurationResolverTest.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dcaegen2.collectors.ves
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.configuration.cbs;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsClientConfiguration;
+
+public class CbsClientConfigurationResolverTest {
+
+ private static final String DEFAULT_PROTOCOL = "http";
+ private static final String DEFAULT_HOSTNAME = "config-binding-service";
+ private static final int DEFAULT_PORT = 10000;
+ private static final String DEFAULT_APP_NAME = "dcae-ves-collector";
+
+ @Test
+ @DisabledIfEnvironmentVariable(named = "CONFIG_BINDING_SERVICE", matches = ".+")
+ public void shouldLoadDefaultConfigWhenEnvNotPresent() {
+ // when
+ CbsClientConfiguration configuration = new CbsClientConfigurationResolver().resolveCbsClientConfiguration();
+
+ // then
+ assertThat(configuration.protocol()).isEqualTo(DEFAULT_PROTOCOL);
+ assertThat(configuration.hostname()).isEqualTo(DEFAULT_HOSTNAME);
+ assertThat(configuration.port()).isEqualTo(DEFAULT_PORT);
+ assertThat(configuration.appName()).isEqualTo(DEFAULT_APP_NAME);
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dcae/configuration/cbs/CbsClientFactoryTest.java b/src/test/java/org/onap/dcae/configuration/cbs/CbsClientFactoryTest.java
new file mode 100644
index 00000000..4b17f68d
--- /dev/null
+++ b/src/test/java/org/onap/dcae/configuration/cbs/CbsClientFactoryTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dcaegen2.collectors.ves
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.configuration.cbs;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+
+public class CbsClientFactoryTest {
+
+ @Test
+ public void createsClientSuccessfully() {
+ // when
+ CbsConfigResolver cbsConfigResolver = new CbsConfigResolverFactory().create();
+
+ // then
+ assertThat(cbsConfigResolver).isNotNull();
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dcae/configuration/cbs/CbsConfigResolverTest.java b/src/test/java/org/onap/dcae/configuration/cbs/CbsConfigResolverTest.java
new file mode 100644
index 00000000..b413a64d
--- /dev/null
+++ b/src/test/java/org/onap/dcae/configuration/cbs/CbsConfigResolverTest.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dcaegen2.collectors.ves
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.configuration.cbs;
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+import org.json.JSONObject;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsClientConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.ImmutableCbsClientConfiguration;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import static org.assertj.core.api.Assertions.assertThat;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class CbsConfigResolverTest {
+
+ private static final String VES_CONFIG = "{\"collector.port\": 8081}";
+ private static final String HOSTNAME = "localhost";
+ private static final String PROTOCOL = "http";
+ private static final String APP_NAME = "VESCollector";
+
+ @Rule
+ public final WireMockRule wireMockRule = new WireMockRule(
+ wireMockConfig().dynamicPort().dynamicPort());
+
+ @Test
+ public void shouldFetchConfigurationFromCBS() {
+ // given
+ final int PORT = wireMockRule.port();
+ stubCBSToReturnAppConfig();
+
+ // when
+ CbsClientConfiguration cbsClientConfiguration = ImmutableCbsClientConfiguration.builder()
+ .protocol(PROTOCOL)
+ .hostname(HOSTNAME)
+ .port(PORT)
+ .appName(APP_NAME)
+ .build();
+ JSONObject appConfig = new CbsConfigResolver(cbsClientConfiguration).getAppConfig().get();
+
+ // then
+ assertThat(appConfig).isNotNull();
+ assertThat(appConfig.toString()).isEqualTo(new JSONObject(VES_CONFIG).toString());
+ }
+
+ private void stubCBSToReturnAppConfig() {
+ stubFor(get(urlEqualTo("/service_component/VESCollector"))
+ .willReturn(aResponse().withBody(CbsConfigResolverTest.VES_CONFIG)));
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dcae/controller/ConfigCBSSourceTest.java b/src/test/java/org/onap/dcae/controller/ConfigCBSSourceTest.java
deleted file mode 100644
index bfec3d97..00000000
--- a/src/test/java/org/onap/dcae/controller/ConfigCBSSourceTest.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.onap.dcaegen2.collectors.ves
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2018 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.dcae.controller;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.onap.dcae.TestingUtilities.assertFailureHasInfo;
-import static org.onap.dcae.controller.ConfigSource.getAppConfig;
-
-import io.vavr.control.Try;
-import org.json.JSONObject;
-import org.junit.Test;
-import org.onap.dcae.WiremockBasedTest;
-
-
-public class ConfigCBSSourceTest extends WiremockBasedTest {
-
- @Test
- public void shouldReturnValidAppConfiguration() {
- // given
- String sampleConfigForVES = "{\"collector.port\": 8080}";
-
- stubConsulToReturnLocalAddressOfCBS();
- stubCBSToReturnAppConfig(sampleConfigForVES);
-
- // when
- Try<JSONObject> actual = tryToGetConfig();
-
- // then
- assertThat(actual.get().toString()).isEqualTo(new JSONObject(sampleConfigForVES).toString());
- }
-
- @Test
- public void shouldReturnFailureOnFailureToCommunicateWithConsul() {
- // given
- stubFor(get(urlEqualTo("/v1/catalog/service/CBSName"))
- .willReturn(aResponse().withStatus(400)));
-
- // when
- Try<JSONObject> actual = tryToGetConfig();
-
- // then
- assertFailureHasInfo(actual, "HTTP", "Consul", "400",
- "http://localhost:" + wireMockRule.port() + "/v1/catalog/service/CBSName");
- }
-
- @Test
- public void shouldReturnFailureOnBadJsonFromConsul() {
- // given
- stubFor(get(urlEqualTo("/v1/catalog/service/CBSName"))
- .willReturn(aResponse().withStatus(200).withBody("[{")));
-
- // when
- Try<JSONObject> actual = tryToGetConfig();
-
- // then
- assertFailureHasInfo(actual, "JSON", "array", "[{");
- }
-
- @Test
- public void shouldReturnFailureOnInvalidCatalogFormat() {
- // given
- String notAListCatalog = ""
- + "{"
- + "\"ServiceAddress\":\"localhost\","
- + "\"ServicePort\":" + wireMockRule.port()
- + "}";
-
- stubFor(get(urlEqualTo("/v1/catalog/service/CBSName"))
- .willReturn(aResponse().withStatus(200).withBody(notAListCatalog)));
-
- // when
- Try<JSONObject> actual = tryToGetConfig();
-
- // then
- assertFailureHasInfo(actual, "JSON", "array", notAListCatalog);
- }
-
-
- @Test
- public void shouldReturnFailureIfConfigIsMissingRequiredProperties() {
- // given
- String actualConf = "{\"ServicePort\":" + wireMockRule.port() + "}";
- String asCatalog = "[" + actualConf + "]";
-
- stubFor(get(urlEqualTo("/v1/catalog/service/CBSName"))
- .willReturn(aResponse().withStatus(200).withBody(asCatalog)));
-
- // when
- Try<JSONObject> actual = tryToGetConfig();
-
- // then
- assertFailureHasInfo(actual, "ServiceAddress", "ServicePort", "missing", actualConf);
- }
-
-
- @Test
- public void shouldReturnFailureOnFailureToCommunicateWithCBS() {
- // given
- stubFor(get(urlEqualTo("/v1/catalog/service/CBSName"))
- .willReturn(aResponse().withStatus(200).withBody(validLocalCBSConf())));
- stubFor(get(urlEqualTo("/service_component/VESCollector"))
- .willReturn(aResponse().withStatus(400)));
-
- // when
- Try<JSONObject> actual = tryToGetConfig();
-
- // then
- assertFailureHasInfo(actual, "HTTP", "CBS", "400",
- "http://localhost:" + wireMockRule.port() + "/service_component/VESCollector");
- }
-
- @Test
- public void shouldReturnFailureIfAppIsInvalidJsonDocument() {
- // given
- String invalidAppConf = "[$";
- stubConsulToReturnLocalAddressOfCBS();
- stubCBSToReturnAppConfig(invalidAppConf);
-
- // when
- Try<JSONObject> actual = tryToGetConfig();
-
- // then
- assertFailureHasInfo(actual, "JSON", "document", invalidAppConf);
- }
-
- private Try<JSONObject> tryToGetConfig() {
- return getAppConfig(new EnvProps("http", "localhost", wireMockRule.port(), "http", "CBSName", "VESCollector"));
- }
-}
-
diff --git a/src/test/java/org/onap/dcae/controller/ConfigLoaderIntegrationE2ETest.java b/src/test/java/org/onap/dcae/controller/ConfigLoaderIntegrationE2ETest.java
deleted file mode 100644
index 90c8a9c8..00000000
--- a/src/test/java/org/onap/dcae/controller/ConfigLoaderIntegrationE2ETest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.onap.dcaegen2.collectors.ves
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2018 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.dcae.controller;
-
-import static io.vavr.API.Map;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-import static org.onap.dcae.TestingUtilities.createTemporaryFile;
-import static org.onap.dcae.TestingUtilities.readFile;
-import static org.onap.dcae.TestingUtilities.readJSONFromFile;
-import static org.onap.dcae.common.publishing.VavrUtils.f;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import org.json.JSONObject;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.dcae.ApplicationSettings;
-import org.onap.dcae.WiremockBasedTest;
-import org.onap.dcae.common.publishing.DMaaPConfigurationParser;
-import org.onap.dcae.common.publishing.EventPublisher;
-
-@RunWith(MockitoJUnitRunner.Silent.class)
-public class ConfigLoaderIntegrationE2ETest extends WiremockBasedTest {
-
- @Test
- public void testSuccessfulE2EFlow() {
- // given
- Path dMaaPConfigFile = createTemporaryFile("{}");
- Path collectorPropertiesFile = createTemporaryFile("");
- Path dMaaPConfigSource = Paths.get("src/test/resources/testParseDMaaPCredentialsGen2.json");
- JSONObject dMaaPConf = readJSONFromFile(dMaaPConfigSource);
- stubConsulToReturnLocalAddressOfCBS();
- stubCBSToReturnAppConfig(f("{\"collector.port\": 8080, \"streams_publishes\": %s}}", dMaaPConf));
-
- EventPublisher eventPublisherMock = mock(EventPublisher.class);
- ConfigFilesFacade configFilesFacade = new ConfigFilesFacade(dMaaPConfigFile, collectorPropertiesFile);
- ConfigLoader configLoader = new ConfigLoader(eventPublisherMock::reconfigure, configFilesFacade, ConfigSource::getAppConfig, () -> wiremockBasedEnvProps());
- configLoader.updateConfig();
- // then
- assertThat(readJSONFromFile(dMaaPConfigSource).toString()).isEqualTo(dMaaPConf.toString());
- assertThat(readFile(collectorPropertiesFile).trim()).isEqualTo("collector.port = 8080");
- verify(eventPublisherMock, times(1)).reconfigure(
- DMaaPConfigurationParser.parseToDomainMapping(dMaaPConf).get()
- );
- }
-
- @Test
- public void shouldNotReconfigureNotOverwriteIfConfigurationHasNotChanged() {
- // given
- Path dMaaPConfigFile = createTemporaryFile("{}");
- Path collectorPropertiesFile = createTemporaryFile("");
- JSONObject dMaaPConf = readJSONFromFile(Paths.get("src/test/resources/testParseDMaaPCredentialsGen2.json"));
- stubConsulToReturnLocalAddressOfCBS();
- stubCBSToReturnAppConfig(f("{\"collector.port\": 8080, \"streams_publishes\": %s}}", dMaaPConf));
- EventPublisher eventPublisherMock = mock(EventPublisher.class);
- ConfigFilesFacade configFilesFacade = new ConfigFilesFacade(dMaaPConfigFile, collectorPropertiesFile);
- configFilesFacade.writeProperties(Map("collector.port", "8080"));
- configFilesFacade.writeDMaaPConfiguration(dMaaPConf);
-
- // when
- ConfigLoader configLoader = new ConfigLoader(eventPublisherMock::reconfigure, configFilesFacade, ConfigSource::getAppConfig, () -> wiremockBasedEnvProps());
- configLoader.updateConfig();
-
- // then
- verifyZeroInteractions(eventPublisherMock);
- }
-
-} \ No newline at end of file
diff --git a/src/test/java/org/onap/dcae/controller/EnvPropertiesReaderTest.java b/src/test/java/org/onap/dcae/controller/EnvPropertiesReaderTest.java
deleted file mode 100644
index 6c358024..00000000
--- a/src/test/java/org/onap/dcae/controller/EnvPropertiesReaderTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.onap.dcaegen2.collectors.ves
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2018 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.dcae.controller;
-
-import static io.vavr.API.Map;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.onap.dcae.controller.EnvPropertiesReader.readEnvProps;
-
-import io.vavr.collection.Map;
-import org.junit.Test;
-
-
-public class EnvPropertiesReaderTest {
-
- @Test
- public void shouldReturnEmptyOnMissingConsulHost() {
- Map<String, String> envs = Map(
- "CONFIG_BINDING_SERVICE", "doesNotMatter",
- "HOSTNAME", "doesNotMatter");
- assertTrue(readEnvProps(envs).isEmpty());
- }
-
- @Test
- public void shouldReturnEmptyOnMissingCBSName() {
- Map<String, String> envs = Map(
- "CONSUL_HOST", "doesNotMatter",
- "HOSTNAME", "doesNotMatter");
- assertTrue(readEnvProps(envs).isEmpty());
- }
-
- @Test
- public void shouldReturnEmptyOnMissingVESAppName() {
- Map<String, String> envs = Map(
- "CONSUL_HOST", "doesNotMatter",
- "CONFIG_BINDING_SERVICE", "doesNotMatter");
- assertTrue(readEnvProps(envs).isEmpty());
- }
-
- @Test
- public void shouldReturnSomeOfAllProperties() {
- Map<String, String> envs = Map(
- "CONSUL_HOST", "doesNotMatter",
- "HOSTNAME", "doesNotMatter",
- "CONFIG_BINDING_SERVICE", "doesNotMatter");
- assertFalse(readEnvProps(envs).isEmpty());
- }
-
-}
-
diff --git a/src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java b/src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java
index 765f2b43..0a03c1a4 100644
--- a/src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java
+++ b/src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java
@@ -41,7 +41,7 @@ import org.onap.dcae.common.EventTransformation;
import org.onap.dcae.common.HeaderUtils;
import org.onap.dcae.common.JsonDataLoader;
import org.onap.dcae.common.validator.StndDefinedDataValidator;
-import org.onap.dcae.common.publishing.EventPublisher;
+import org.onap.dcae.common.publishing.DMaaPEventPublisher;
import org.slf4j.Logger;
import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockHttpServletRequest;
@@ -84,7 +84,7 @@ public class VesRestControllerTest {
private HeaderUtils headerUtils;
@Mock
- private EventPublisher eventPublisher;
+ private DMaaPEventPublisher eventPublisher;
@Mock
private StndDefinedDataValidator stndDefinedDataValidator;
@@ -320,7 +320,7 @@ public class VesRestControllerTest {
);
}
- private void verifyThatTransformedEventWasSend(EventPublisher eventPublisher, String eventBeforeTransformation) {
+ private void verifyThatTransformedEventWasSend(DMaaPEventPublisher eventPublisher, String eventBeforeTransformation) {
// event before transformation
assertThat(eventBeforeTransformation).contains("\"version\": \"4.0.1\"");
assertThat(eventBeforeTransformation).contains("\"faultFieldsVersion\": \"4.0\"");