diff options
Diffstat (limited to 'components/kpi-computation-ms')
5 files changed, 34 insertions, 6 deletions
diff --git a/components/kpi-computation-ms/Changelog.md b/components/kpi-computation-ms/Changelog.md new file mode 100644 index 00000000..357ea9d2 --- /dev/null +++ b/components/kpi-computation-ms/Changelog.md @@ -0,0 +1,12 @@ +# Change Log + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +## [1.0.1] +### Changed +* Migrating the kpi.policy from app-config file to separate policy module (DCAEGEN2-2835) + + diff --git a/components/kpi-computation-ms/pom.xml b/components/kpi-computation-ms/pom.xml index d8e8f4d4..a0265c0d 100644 --- a/components/kpi-computation-ms/pom.xml +++ b/components/kpi-computation-ms/pom.xml @@ -36,7 +36,7 @@ <properties> <java.version>11</java.version> - <sdk.version>1.5.0</sdk.version> + <sdk.version>1.8.7</sdk.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> diff --git a/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/controller/ConfigFetchFromCbs.java b/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/controller/ConfigFetchFromCbs.java index ba8e33ea..3ac0ef36 100644 --- a/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/controller/ConfigFetchFromCbs.java +++ b/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/controller/ConfigFetchFromCbs.java @@ -97,6 +97,8 @@ public class ConfigFetchFromCbs implements Runnable { if (jsonObject.getAsJsonObject("policies") != null) { JsonObject policyJson = jsonObject.getAsJsonObject("policies").getAsJsonArray("items").get(0) .getAsJsonObject().getAsJsonObject("config"); + log.info("policy json {}", policyJson); + Configuration.getInstance().updateConfigFromPolicy(policyJson); Map<String, Object> policy = new Gson().fromJson(policyJson, mapType); configPolicy.setConfig(policy); log.info("Config policy {}", configPolicy); diff --git a/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/models/Configuration.java b/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/models/Configuration.java index 930e631c..dbad3925 100644 --- a/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/models/Configuration.java +++ b/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/models/Configuration.java @@ -20,11 +20,6 @@ package org.onap.dcaegen2.kpi.models; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; - import java.lang.reflect.Type; import java.util.List; import java.util.Map; @@ -32,6 +27,11 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; + /** * Model class for the application Configuration. */ @@ -259,6 +259,11 @@ public class Configuration { log.info("configuration from CBS {}", this); } + + public void updateConfigFromPolicy(JsonObject policyconfig) { + kpiConfig = policyconfig.toString(); + log.info("kpi config fetched from policy {}", kpiConfig); + } public String getKpiConfig() { return kpiConfig; diff --git a/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/models/ConfigurationTest.java b/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/models/ConfigurationTest.java index 07ef51d2..efe84983 100644 --- a/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/models/ConfigurationTest.java +++ b/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/models/ConfigurationTest.java @@ -30,10 +30,12 @@ import java.util.List; import java.util.Map; import org.junit.Test; +import org.onap.dcaegen2.kpi.computation.FileUtils; public class ConfigurationTest { Configuration configuration = Configuration.getInstance(); + private static final String KPI_CONFIG_FILE = "kpi/kpi_config.json"; @Test public void configurationTest() { @@ -76,4 +78,11 @@ public class ConfigurationTest { assertEquals("kpi config", configuration.getKpiConfig()); assertEquals(10, configuration.getCbsPollingInterval()); } + + @Test + public void updateConfigFromPolicyTest() { + String strKpiConfig = FileUtils.getFileContents(KPI_CONFIG_FILE); + configuration.setKpiConfig(strKpiConfig); + assertEquals(strKpiConfig, configuration.getKpiConfig()); + } } |