aboutsummaryrefslogtreecommitdiffstats
path: root/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMapTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMapTest.java')
-rw-r--r--rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMapTest.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMapTest.java b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMapTest.java
index 07b44e9e..a9d8407b 100644
--- a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMapTest.java
+++ b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMapTest.java
@@ -22,20 +22,28 @@ package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
+import com.google.gson.stream.JsonReader;
+import org.junit.Rule;
+import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClient;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests;
import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
-import org.onap.dcaegen2.services.sdk.services.common.FileReader;
-import org.yaml.snakeyaml.Yaml;
-import java.util.LinkedHashMap;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
import static org.assertj.core.api.Assertions.assertThat;
public class CbsClientConfigMapTest {
+ private static final String SAMPLE_EXPECTED_CONFIG = "src/test/resources/sample_expected_service_config.json";
+ @Rule
+ public final EnvironmentVariables envs = new EnvironmentVariables();
+
@Test
- void shouldFetchUsingProperConfigMapFile() {
+ void shouldFetchUsingProperConfigMapFile() throws FileNotFoundException {
// given
+ envs.set("AAF_USER", "admin");
+ envs.set("AAF_PASSWORD", "admin_secret");
String configMapFilePath = "src/test/resources/application_config.yaml";
final CbsClient cut = new CbsClientConfigMap(configMapFilePath);
@@ -46,12 +54,11 @@ public class CbsClientConfigMapTest {
// then
assertThat(result).isNotNull();
- assertThat(result).isEqualTo(covertYamlToJson(configMapFilePath));
+ assertThat(result).isEqualTo(convertToJson(new JsonReader(new FileReader(SAMPLE_EXPECTED_CONFIG))));
}
- private JsonObject covertYamlToJson(String configMapFilePath) {
+ private JsonObject convertToJson(JsonReader jsonReader) {
Gson gson = new GsonBuilder().create();
- return gson.fromJson(gson.toJson(new Yaml().load(new FileReader(configMapFilePath).getContent()),
- LinkedHashMap.class), JsonObject.class);
+ return gson.fromJson(jsonReader, JsonObject.class);
}
}