diff options
Diffstat (limited to 'services/services-onappf/src/test')
6 files changed, 33 insertions, 1 deletions
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<String, Object> getPdpStatusParametersMap(final boolean isEmpty) { final Map<String, Object> 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<String, Object> 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<String, Object> 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", |