From a6d476bfa4ae4350f979cc85d71ba98a6b6410b5 Mon Sep 17 00:00:00 2001 From: sebdet Date: Fri, 5 Apr 2019 18:00:51 +0200 Subject: Fix config policy Fix saving of config policy due to refactoring + fix missing model type in config policy Issue-ID: CLAMP-303 Change-Id: I863f3bb6b2acef8ed7bf534e142c1730b1493b67 Signed-off-by: sebdet --- .../onap/clamp/clds/sdc/controller/installer/BlueprintParser.java | 3 ++- .../onap/clamp/policy/microservice/MicroservicePolicyService.java | 7 ++++--- .../clamp/clds/sdc/controller/installer/BlueprintParserTest.java | 6 ++++-- src/test/resources/example/sdc/blueprint-dcae/tca.yaml | 1 + src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml | 1 + src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml | 1 + 6 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java index f3654596c..93374fe11 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java @@ -87,7 +87,8 @@ public class BlueprintParser { } } String msName = theBiggestMicroServiceKey.toLowerCase().contains(HOLMES_PREFIX) ? HOLMES : TCA; - return Collections.singletonList(new MicroService(msName, "", "", "", "")); + return Collections + .singletonList(new MicroService(msName, "onap.policy.monitoring.cdap.tca.hi.lo.ap", "", "", "")); } String getName(Entry entry) { diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java b/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java index b14e14503..59ddaa009 100644 --- a/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java +++ b/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java @@ -65,9 +65,10 @@ public class MicroservicePolicyService implements PolicyService updateMicroservicePolicyProperties(p, policy, loop)) - .orElse(new MicroServicePolicy(policy.getName(), policy.getModelType(), policy.getPolicyTosca(), - policy.getShared(), policy.getJsonRepresentation(), Sets.newHashSet(loop))); + return repository + .save(repository.findById(policy.getName()).map(p -> updateMicroservicePolicyProperties(p, policy, loop)) + .orElse(new MicroServicePolicy(policy.getName(), policy.getModelType(), policy.getPolicyTosca(), + policy.getShared(), policy.getJsonRepresentation(), Sets.newHashSet(loop)))); } private MicroServicePolicy updateMicroservicePolicyProperties(MicroServicePolicy oldPolicy, diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java index fbe6e63ca..93d71663e 100644 --- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java +++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java @@ -163,7 +163,8 @@ public class BlueprintParserTest { @Test public void fallBackToOneMicroServiceTCATest() { - MicroService tcaMS = new MicroService(BlueprintParser.TCA, "", "", "", ""); + MicroService tcaMS = new MicroService(BlueprintParser.TCA, "onap.policy.monitoring.cdap.tca.hi.lo.ap", "", "", + ""); List expected = Collections.singletonList(tcaMS); List actual = new BlueprintParser().fallbackToOneMicroService(microServiceBlueprintOldStyleTCA); @@ -173,7 +174,8 @@ public class BlueprintParserTest { @Test public void fallBackToOneMicroServiceHolmesTest() { - MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, "", "", "", ""); + MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, "onap.policy.monitoring.cdap.tca.hi.lo.ap", "", + "", ""); List expected = Collections.singletonList(holmesMS); List actual = new BlueprintParser() diff --git a/src/test/resources/example/sdc/blueprint-dcae/tca.yaml b/src/test/resources/example/sdc/blueprint-dcae/tca.yaml index 0ab831712..b1659073a 100644 --- a/src/test/resources/example/sdc/blueprint-dcae/tca.yaml +++ b/src/test/resources/example/sdc/blueprint-dcae/tca.yaml @@ -17,6 +17,7 @@ node_templates: properties: policy_id: get_input: policy_id + policy_type_id: onap.policy.monitoring.cdap.tca.hi.lo.ap cdap_host_host: type: dcae.nodes.StreamingAnalytics.SelectedCDAPInfrastructure properties: diff --git a/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml b/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml index f73119fb6..55901368b 100644 --- a/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml +++ b/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml @@ -166,4 +166,5 @@ node_templates: properties: policy_id: get_input: policy_id + policy_type_id: onap.policy.monitoring.cdap.tca.hi.lo.ap diff --git a/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml b/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml index 0ab831712..b1659073a 100644 --- a/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml +++ b/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml @@ -17,6 +17,7 @@ node_templates: properties: policy_id: get_input: policy_id + policy_type_id: onap.policy.monitoring.cdap.tca.hi.lo.ap cdap_host_host: type: dcae.nodes.StreamingAnalytics.SelectedCDAPInfrastructure properties: -- cgit 1.2.3-korg