From 7f0114721e5bc2f54cc49243ee8d1cf9c98dd451 Mon Sep 17 00:00:00 2001 From: "a.sreekumar" Date: Tue, 19 Nov 2019 17:00:59 +0000 Subject: Apex PDP change to add PDP group Change-Id: I6cff921bdc65fe505c0b5e7dba94a6cf9aa3ba91 Issue-ID: POLICY-2234 Signed-off-by: a.sreekumar --- .../services/onappf/parameters/CommonTestData.java | 2 ++ .../onappf/parameters/TestPdpStatusParameters.java | 28 +++++++++++++++++++++- .../resources/ApexStarterConfigParameters.json | 1 + .../resources/ApexStarterConfigParametersNoop.json | 1 + .../resources/ApexStarterConfigParameters_sim.json | 1 + .../src/test/resources/TestConfigParameters.json | 1 + 6 files changed, 33 insertions(+), 1 deletion(-) (limited to 'services/services-onappf/src/test') diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/CommonTestData.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/CommonTestData.java index c8d61f539..b26a1f1a2 100644 --- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/CommonTestData.java +++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/CommonTestData.java @@ -42,6 +42,7 @@ public class CommonTestData { public static final String PDP_NAME = "apex-pdp"; public static final String VERSION = "0.0.1"; public static final String PDP_TYPE = "apex"; + public static final String PDP_GROUP = "defaultGroup"; public static final String DESCRIPTION = "Pdp status for HealthCheck"; public static final String POLICY_NAME = "onap.controllloop.operational.apex.BBS"; public static final String POLICY_VERSION = "0.0.1"; @@ -145,6 +146,7 @@ public class CommonTestData { public Map getPdpStatusParametersMap(final boolean isEmpty) { final Map map = new TreeMap<>(); if (!isEmpty) { + map.put("pdpGroup", PDP_GROUP); map.put("timeIntervalMs", TIME_INTERVAL); map.put("pdpName", PDP_NAME); map.put("version", VERSION); diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestPdpStatusParameters.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestPdpStatusParameters.java index e8a3f7ee0..95cf35093 100644 --- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestPdpStatusParameters.java +++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestPdpStatusParameters.java @@ -21,11 +21,12 @@ package org.onap.policy.apex.services.onappf.parameters; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.util.Map; import org.junit.Test; -import org.onap.policy.apex.services.onappf.parameters.PdpStatusParameters; import org.onap.policy.common.parameters.GroupValidationResult; /** @@ -46,6 +47,7 @@ public class TestPdpStatusParameters { assertEquals(CommonTestData.PDP_TYPE, pdpStatusParameters.getPdpType()); assertEquals(CommonTestData.DESCRIPTION, pdpStatusParameters.getDescription()); assertEquals(CommonTestData.SUPPORTED_POLICY_TYPES, pdpStatusParameters.getSupportedPolicyTypes()); + assertEquals(CommonTestData.PDP_GROUP, pdpStatusParameters.getPdpGroup()); } @Test @@ -56,4 +58,28 @@ public class TestPdpStatusParameters { assertNull(result.getResult()); assertTrue(result.isValid()); } + + @Test + public void testPdpStatusParameters_nullPdpGroup() throws Exception { + Map pdpStatusParametersMap = testData.getPdpStatusParametersMap(false); + pdpStatusParametersMap.remove("pdpGroup"); + final PdpStatusParameters pdpStatusParameters = + testData.toObject(pdpStatusParametersMap, PdpStatusParameters.class); + final GroupValidationResult validationResult = pdpStatusParameters.validate(); + assertFalse(validationResult.isValid()); + assertTrue(validationResult.getResult() + .contains("field \"pdpGroup\" type \"java.lang.String\" value \"null\" INVALID")); + } + + @Test + public void testPdpStatusParameters_emptyPdpGroup() throws Exception { + Map pdpStatusParametersMap = testData.getPdpStatusParametersMap(false); + pdpStatusParametersMap.put("pdpGroup", ""); + final PdpStatusParameters pdpStatusParameters = + testData.toObject(pdpStatusParametersMap, PdpStatusParameters.class); + final GroupValidationResult validationResult = pdpStatusParameters.validate(); + assertFalse(validationResult.isValid()); + assertTrue(validationResult.getResult() + .contains("field \"pdpGroup\" type \"java.lang.String\" value \"\" INVALID, must be a non-blank string")); + } } diff --git a/services/services-onappf/src/test/resources/ApexStarterConfigParameters.json b/services/services-onappf/src/test/resources/ApexStarterConfigParameters.json index 202368589..4e58200a4 100644 --- a/services/services-onappf/src/test/resources/ApexStarterConfigParameters.json +++ b/services/services-onappf/src/test/resources/ApexStarterConfigParameters.json @@ -8,6 +8,7 @@ "https": true }, "pdpStatusParameters":{ + "pdpGroup": "defaultGroup", "timeIntervalMs": 120000, "pdpType":"apex", "description":"Pdp Heartbeat", diff --git a/services/services-onappf/src/test/resources/ApexStarterConfigParametersNoop.json b/services/services-onappf/src/test/resources/ApexStarterConfigParametersNoop.json index bce20da9d..061237ff0 100644 --- a/services/services-onappf/src/test/resources/ApexStarterConfigParametersNoop.json +++ b/services/services-onappf/src/test/resources/ApexStarterConfigParametersNoop.json @@ -8,6 +8,7 @@ "https": true }, "pdpStatusParameters":{ + "pdpGroup": "defaultGroup", "timeIntervalMs": 120000, "pdpType":"apex", "description":"Pdp Heartbeat", diff --git a/services/services-onappf/src/test/resources/ApexStarterConfigParameters_sim.json b/services/services-onappf/src/test/resources/ApexStarterConfigParameters_sim.json index c26a0a654..67e5bcb36 100644 --- a/services/services-onappf/src/test/resources/ApexStarterConfigParameters_sim.json +++ b/services/services-onappf/src/test/resources/ApexStarterConfigParameters_sim.json @@ -8,6 +8,7 @@ "https": true }, "pdpStatusParameters":{ + "pdpGroup": "defaultGroup", "timeIntervalMs": 120000, "pdpType":"apex", "description":"Pdp Heartbeat", diff --git a/services/services-onappf/src/test/resources/TestConfigParameters.json b/services/services-onappf/src/test/resources/TestConfigParameters.json index 202368589..4e58200a4 100644 --- a/services/services-onappf/src/test/resources/TestConfigParameters.json +++ b/services/services-onappf/src/test/resources/TestConfigParameters.json @@ -8,6 +8,7 @@ "https": true }, "pdpStatusParameters":{ + "pdpGroup": "defaultGroup", "timeIntervalMs": 120000, "pdpType":"apex", "description":"Pdp Heartbeat", -- cgit 1.2.3-korg