aboutsummaryrefslogtreecommitdiffstats
path: root/services/services-onappf/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-05-04 11:56:38 +0000
committerGerrit Code Review <gerrit@onap.org>2021-05-04 11:56:38 +0000
commite57a113a469c36f5ca483fe3a8f35bb5fd657691 (patch)
treeb4e9f6e77318e7f8d0ce391e7a5c52f987b31016 /services/services-onappf/src
parente0b224292938634c10aecd17b641a0888065a8b1 (diff)
parente168ce2fad71650ad730519c772a9b093c0a8f43 (diff)
Merge "Remove GroupValidationResult"
Diffstat (limited to 'services/services-onappf/src')
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterGroup.java8
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java5
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterGroup.java34
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterHandler.java4
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestPdpStatusParameters.java18
5 files changed, 34 insertions, 35 deletions
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterGroup.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterGroup.java
index 17550d003..f752348b4 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterGroup.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterGroup.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +27,7 @@ import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Valid;
/**
* Class to hold all parameters needed for apex starter component.
@@ -36,9 +38,9 @@ import org.onap.policy.common.parameters.annotations.NotNull;
@NotBlank
@Getter
public class ApexStarterParameterGroup extends ParameterGroupImpl {
- private RestServerParameters restServerParameters;
- private PdpStatusParameters pdpStatusParameters;
- private TopicParameterGroup topicParameterGroup;
+ private @Valid RestServerParameters restServerParameters;
+ private @Valid PdpStatusParameters pdpStatusParameters;
+ private @Valid TopicParameterGroup topicParameterGroup;
/**
* Create the apex starter parameter group.
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java
index 05ae8fd57..691b30d2d 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +24,7 @@ package org.onap.policy.apex.services.onappf.parameters;
import java.io.File;
import org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments;
import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -70,7 +71,7 @@ public class ApexStarterParameterHandler {
}
// validate the parameters
- final GroupValidationResult validationResult = apexStarterParameterGroup.validate();
+ final ValidationResult validationResult = apexStarterParameterGroup.validate();
if (!validationResult.isValid()) {
String returnMessage =
"validation error(s) on parameters from \"" + arguments.getConfigurationFilePath() + "\"\n";
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterGroup.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterGroup.java
index 00b6cce74..c44964921 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterGroup.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterGroup.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +21,7 @@
package org.onap.policy.apex.services.onappf.parameters;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -28,7 +30,7 @@ import java.util.Map;
import org.junit.Test;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
/**
* Class to perform unit test of {@link ApexStarterParameterGroup}.
@@ -52,7 +54,7 @@ public class TestApexStarterParameterGroup {
final RestServerParameters restServerParameters = apexStarterParameters.getRestServerParameters();
final PdpStatusParameters pdpStatusParameters = apexStarterParameters.getPdpStatusParameters();
final TopicParameterGroup topicParameterGroup = apexStarterParameters.getTopicParameterGroup();
- final GroupValidationResult validationResult = apexStarterParameters.validate();
+ final ValidationResult validationResult = apexStarterParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(CommonTestData.APEX_STARTER_GROUP_NAME, apexStarterParameters.getName());
assertEquals(CommonTestData.TIME_INTERVAL, pdpStatusParameters.getTimeIntervalMs());
@@ -73,7 +75,7 @@ public class TestApexStarterParameterGroup {
public void testApexStarterParameterGroup_NullName() {
final ApexStarterParameterGroup apexStarterParameters = commonTestData
.toObject(commonTestData.getApexStarterParameterGroupMap(null), ApexStarterParameterGroup.class);
- final GroupValidationResult validationResult = apexStarterParameters.validate();
+ final ValidationResult validationResult = apexStarterParameters.validate();
assertFalse(validationResult.isValid());
assertEquals(null, apexStarterParameters.getName());
assertTrue(validationResult.getResult().contains("is null"));
@@ -83,11 +85,10 @@ public class TestApexStarterParameterGroup {
public void testApexStarterParameterGroup_EmptyName() {
final ApexStarterParameterGroup apexStarterParameters = commonTestData
.toObject(commonTestData.getApexStarterParameterGroupMap(""), ApexStarterParameterGroup.class);
- final GroupValidationResult validationResult = apexStarterParameters.validate();
+ final ValidationResult validationResult = apexStarterParameters.validate();
+ assertThat(validationResult.getResult()).contains("\"name\" value \"\" INVALID, is blank");
assertFalse(validationResult.isValid());
assertEquals("", apexStarterParameters.getName());
- assertTrue(validationResult.getResult().contains(
- "field \"name\" type \"java.lang.String\" value \"\" INVALID, " + "must be a non-blank string"));
}
@Test
@@ -96,7 +97,7 @@ public class TestApexStarterParameterGroup {
commonTestData.getApexStarterParameterGroupMap(CommonTestData.APEX_STARTER_GROUP_NAME),
ApexStarterParameterGroup.class);
apexStarterParameters.setName("ApexStarterNewGroup");
- final GroupValidationResult validationResult = apexStarterParameters.validate();
+ final ValidationResult validationResult = apexStarterParameters.validate();
assertTrue(validationResult.isValid());
assertEquals("ApexStarterNewGroup", apexStarterParameters.getName());
}
@@ -108,11 +109,10 @@ public class TestApexStarterParameterGroup {
map.put("pdpStatusParameters", commonTestData.getPdpStatusParametersMap(true));
final ApexStarterParameterGroup apexStarterParameters =
commonTestData.toObject(map, ApexStarterParameterGroup.class);
- final GroupValidationResult validationResult = apexStarterParameters.validate();
+ final ValidationResult validationResult = apexStarterParameters.validate();
+ assertThat(validationResult.getResult())
+ .contains("\"ApexStarterParameterGroup\" INVALID, item has status INVALID");
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("\"org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup\" INVALID, "
- + "parameter group has status INVALID"));
}
@Test
@@ -123,11 +123,9 @@ public class TestApexStarterParameterGroup {
final ApexStarterParameterGroup apexStarterParameters =
commonTestData.toObject(map, ApexStarterParameterGroup.class);
- final GroupValidationResult validationResult = apexStarterParameters.validate();
+ final ValidationResult validationResult = apexStarterParameters.validate();
+ assertThat(validationResult.getResult()).contains("\"RestServerParameters\" INVALID, item has status INVALID");
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("\"org.onap.policy.common.endpoints.parameters.RestServerParameters\" INVALID, "
- + "parameter group has status INVALID"));
}
@@ -139,10 +137,8 @@ public class TestApexStarterParameterGroup {
final ApexStarterParameterGroup apexStarterParameters =
commonTestData.toObject(map, ApexStarterParameterGroup.class);
- final GroupValidationResult validationResult = apexStarterParameters.validate();
+ final ValidationResult validationResult = apexStarterParameters.validate();
+ assertThat(validationResult.getResult()).contains("\"TopicParameterGroup\" INVALID, item has status INVALID");
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("\"org.onap.policy.common.endpoints.parameters.TopicParameterGroup\" INVALID, "
- + "parameter group has status INVALID"));
}
}
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterHandler.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterHandler.java
index dd424c15b..90c2ef743 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterHandler.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -105,8 +106,7 @@ public class TestApexStarterParameterHandler {
arguments.parse(apexStarterConfigParameters);
assertThatThrownBy(() -> new ApexStarterParameterHandler().getParameters(arguments))
- .hasMessageContaining("field \"name\" type \"java.lang.String\" value \" \" INVALID, must be a "
- + "non-blank string");
+ .hasMessageContaining("\"name\" value \" \" INVALID, is blank");
}
@Test
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 95cf35093..765bb70a9 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
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +21,7 @@
package org.onap.policy.apex.services.onappf.parameters;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@@ -27,7 +29,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Map;
import org.junit.Test;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
/**
* Class to perform unit test of {@link PdpStatusParameters}.
@@ -41,7 +43,7 @@ public class TestPdpStatusParameters {
public void test() throws Exception {
final PdpStatusParameters pdpStatusParameters =
testData.toObject(testData.getPdpStatusParametersMap(false), PdpStatusParameters.class);
- final GroupValidationResult validationResult = pdpStatusParameters.validate();
+ final ValidationResult validationResult = pdpStatusParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(CommonTestData.TIME_INTERVAL, pdpStatusParameters.getTimeIntervalMs());
assertEquals(CommonTestData.PDP_TYPE, pdpStatusParameters.getPdpType());
@@ -54,7 +56,7 @@ public class TestPdpStatusParameters {
public void testValidate() throws Exception {
final PdpStatusParameters pdpStatusParameters =
testData.toObject(testData.getPdpStatusParametersMap(false), PdpStatusParameters.class);
- final GroupValidationResult result = pdpStatusParameters.validate();
+ final ValidationResult result = pdpStatusParameters.validate();
assertNull(result.getResult());
assertTrue(result.isValid());
}
@@ -65,10 +67,9 @@ public class TestPdpStatusParameters {
pdpStatusParametersMap.remove("pdpGroup");
final PdpStatusParameters pdpStatusParameters =
testData.toObject(pdpStatusParametersMap, PdpStatusParameters.class);
- final GroupValidationResult validationResult = pdpStatusParameters.validate();
+ final ValidationResult validationResult = pdpStatusParameters.validate();
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("field \"pdpGroup\" type \"java.lang.String\" value \"null\" INVALID"));
+ assertThat(validationResult.getResult()).contains("\"pdpGroup\" value \"null\" INVALID");
}
@Test
@@ -77,9 +78,8 @@ public class TestPdpStatusParameters {
pdpStatusParametersMap.put("pdpGroup", "");
final PdpStatusParameters pdpStatusParameters =
testData.toObject(pdpStatusParametersMap, PdpStatusParameters.class);
- final GroupValidationResult validationResult = pdpStatusParameters.validate();
+ final ValidationResult validationResult = pdpStatusParameters.validate();
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("field \"pdpGroup\" type \"java.lang.String\" value \"\" INVALID, must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains("\"pdpGroup\" value \"\" INVALID");
}
}