aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-04-27 10:30:14 -0400
committerJim Hahn <jrh3@att.com>2021-04-28 16:37:35 -0400
commit532e25ad45ba6bab39aa7442fbb8c675fad6264e (patch)
tree2a29e51d60f64b6112b6f3dbf3a650cf6111f10e /main/src
parentcc6a0ac3a3f76de375aeb04bcc254208c70ce0be (diff)
Remove GroupValidationResult
Removed GroupValidationResult, replacing it with BeanValidationResult. Modified the ParameterGroup subclasses to use BeanValidator, adding annotations where needed to trigger the validations that had been automatically performed by GroupValidationResult. Issue-ID: POLICY-2059 Change-Id: I9597dc84e8a81ac5b8954bb2ce4ad0d7e2a3a4a7 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterGroup.java9
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterHandler.java6
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/parameters/PdpParameters.java5
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java14
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java18
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterGroup.java25
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterHandler.java5
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpParameters.java28
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpRequestParameters.java15
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpStateChangeParameters.java6
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpUpdateParameters.java6
11 files changed, 67 insertions, 70 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterGroup.java b/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterGroup.java
index 9a50cf0f..f7943454 100644
--- a/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterGroup.java
+++ b/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterGroup.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,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;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
/**
@@ -40,12 +41,16 @@ import org.onap.policy.models.provider.PolicyModelsProviderParameters;
@NotBlank
@Getter
public class PapParameterGroup extends ParameterGroupImpl {
+ @Valid
private RestServerParameters restServerParameters;
+ @Valid
private PdpParameters pdpParameters;
+ @Valid
private PolicyModelsProviderParameters databaseProviderParameters;
+ @Valid
private TopicParameterGroup topicParameterGroup;
// API, Distribution Health Check restClient parameters.
- private List<BusTopicParams> healthCheckRestClientParameters;
+ private List<@NotNull @Valid BusTopicParams> healthCheckRestClientParameters;
/**
* Create the pap parameter group.
diff --git a/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterHandler.java b/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterHandler.java
index e730da2e..848ce2cb 100644
--- a/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterHandler.java
+++ b/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterHandler.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
package org.onap.policy.pap.main.parameters;
import java.io.File;
-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;
@@ -71,7 +71,7 @@ public class PapParameterHandler {
}
// validate the parameters
- final GroupValidationResult validationResult = papParameterGroup.validate();
+ final ValidationResult validationResult = papParameterGroup.validate();
if (!validationResult.isValid()) {
String returnMessage =
"validation error(s) on parameters from \"" + arguments.getConfigurationFilePath() + "\"\n";
diff --git a/main/src/main/java/org/onap/policy/pap/main/parameters/PdpParameters.java b/main/src/main/java/org/onap/policy/pap/main/parameters/PdpParameters.java
index 72b11d76..2f89eedd 100644
--- a/main/src/main/java/org/onap/policy/pap/main/parameters/PdpParameters.java
+++ b/main/src/main/java/org/onap/policy/pap/main/parameters/PdpParameters.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-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 +26,7 @@ import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.annotations.Min;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Valid;
/**
* Parameters for communicating with PDPs.
@@ -48,7 +49,9 @@ public class PdpParameters extends ParameterGroupImpl {
@Min(1)
private long maxMessageAgeMs = DEFAULT_MAX_AGE_MS;
+ @Valid
private PdpUpdateParameters updateParameters;
+ @Valid
private PdpStateChangeParameters stateChangeParameters;
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java
index 39608cdd..2ad84dc5 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java
@@ -32,7 +32,6 @@ import java.util.function.Consumer;
import java.util.stream.Collectors;
import javax.ws.rs.core.Response.Status;
import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.utils.services.Registry;
@@ -184,8 +183,8 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
break;
default:
- result.addResult(new ObjectValidationResult("pdpGroupState", group.getPdpGroupState(),
- ValidationStatus.INVALID, "must be null, ACTIVE, or PASSIVE"));
+ result.addResult("pdpGroupState", group.getPdpGroupState(),
+ ValidationStatus.INVALID, "must be null, ACTIVE, or PASSIVE");
break;
}
}
@@ -203,8 +202,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
BeanValidationResult result = new BeanValidationResult(group.getName(), group);
if (!Objects.equals(dbgroup.getProperties(), group.getProperties())) {
- result.addResult(
- new ObjectValidationResult("properties", "", ValidationStatus.INVALID, "cannot change properties"));
+ result.addResult("properties", "", ValidationStatus.INVALID, "cannot change properties");
}
boolean updated = updateField(dbgroup.getDescription(), group.getDescription(), dbgroup::setDescription);
@@ -413,8 +411,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
BeanValidationResult result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
if (!Objects.equals(dbsub.getProperties(), subgrp.getProperties())) {
- result.addResult(
- new ObjectValidationResult("properties", "", ValidationStatus.INVALID, "cannot change properties"));
+ result.addResult("properties", "", ValidationStatus.INVALID, "cannot change properties");
}
container.addResult(result);
@@ -434,8 +431,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
BeanValidationResult result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
for (ToscaConceptIdentifier type : subgrp.getSupportedPolicyTypes()) {
if (!type.getName().endsWith(".*") && data.getPolicyType(type) == null) {
- result.addResult(
- new ObjectValidationResult("policy type", type, ValidationStatus.INVALID, "unknown policy type"));
+ result.addResult("policy type", type, ValidationStatus.INVALID, "unknown policy type");
}
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
index 41f7757b..d400fa11 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
@@ -34,7 +34,6 @@ import javax.ws.rs.core.Response.Status;
import lombok.Getter;
import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.BeanValidator;
-import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.parameters.annotations.NotNull;
@@ -112,8 +111,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
PdpGroup dbgroup = data.getGroup(group.getName());
if (dbgroup == null) {
- result.addResult(new ObjectValidationResult(group.getName(), group,
- ValidationStatus.INVALID, "unknown group"));
+ result.addResult(group.getName(), group, ValidationStatus.INVALID, "unknown group");
} else {
result.addResult(updateGroup(data, dbgroup, group));
@@ -172,8 +170,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
BeanValidationResult subResult = new BeanValidationResult(subgrp.getPdpType(), subgrp);
if (dbsub == null) {
- subResult.addResult(new ObjectValidationResult(subgrp.getPdpType(), subgrp,
- ValidationStatus.INVALID, "unknown subgroup"));
+ subResult.addResult(subgrp.getPdpType(), subgrp, ValidationStatus.INVALID, "unknown subgroup");
} else {
updated = updateSubGroup(data, dbgroup, dbsub, subgrp, subResult) || updated;
@@ -342,12 +339,11 @@ public class PdpGroupDeployProvider extends ProviderBase {
ToscaPolicy policy = data.getPolicy(new ToscaConceptIdentifierOptVersion(ident));
if (policy == null) {
- result.addResult(new ObjectValidationResult(POLICY_RESULT_NAME, ident, ValidationStatus.INVALID,
- "unknown policy"));
+ result.addResult(POLICY_RESULT_NAME, ident, ValidationStatus.INVALID, "unknown policy");
} else if (!isPolicySupported(dbsub.getSupportedPolicyTypes(), policy.getTypeIdentifier())) {
- result.addResult(new ObjectValidationResult(POLICY_RESULT_NAME, ident, ValidationStatus.INVALID,
- "not a supported policy for the subgroup"));
+ result.addResult(POLICY_RESULT_NAME, ident, ValidationStatus.INVALID,
+ "not a supported policy for the subgroup");
} else {
// replace version with the fully qualified version from the policy
@@ -379,8 +375,8 @@ public class PdpGroupDeployProvider extends ProviderBase {
return;
}
- result.addResult(new ObjectValidationResult(POLICY_RESULT_NAME, ident, ValidationStatus.INVALID,
- "different version already deployed: " + dbvers));
+ result.addResult(POLICY_RESULT_NAME, ident, ValidationStatus.INVALID,
+ "different version already deployed: " + dbvers);
}
/**
diff --git a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterGroup.java b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterGroup.java
index c22f5e1f..8962f45b 100644
--- a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterGroup.java
+++ b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterGroup.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
package org.onap.policy.pap.main.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 +29,7 @@ import static org.junit.Assert.assertTrue;
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;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -53,7 +54,7 @@ public class TestPapParameterGroup {
final PapParameterGroup papParameters = commonTestData.getPapParameterGroup(1);
final RestServerParameters restServerParameters = papParameters.getRestServerParameters();
final TopicParameterGroup topicParameterGroup = papParameters.getTopicParameterGroup();
- final GroupValidationResult validationResult = papParameters.validate();
+ final ValidationResult validationResult = papParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(CommonTestData.PAP_GROUP_NAME, papParameters.getName());
assertEquals(restServerParameters.getHost(), papParameters.getRestServerParameters().getHost());
@@ -70,28 +71,27 @@ public class TestPapParameterGroup {
public void testPapParameterGroup_NullName() throws Exception {
String json = commonTestData.getPapParameterGroupAsString(1).replace("\"PapGroup\"", "null");
final PapParameterGroup papParameters = coder.decode(json, PapParameterGroup.class);
- final GroupValidationResult validationResult = papParameters.validate();
+ final ValidationResult validationResult = papParameters.validate();
assertFalse(validationResult.isValid());
assertEquals(null, papParameters.getName());
- assertTrue(validationResult.getResult().contains("is null"));
+ assertThat(validationResult.getResult()).contains("is null");
}
@Test
public void testPapParameterGroup_EmptyName() throws Exception {
String json = commonTestData.getPapParameterGroupAsString(1).replace(CommonTestData.PAP_GROUP_NAME, "");
final PapParameterGroup papParameters = coder.decode(json, PapParameterGroup.class);
- final GroupValidationResult validationResult = papParameters.validate();
+ final ValidationResult validationResult = papParameters.validate();
assertFalse(validationResult.isValid());
assertEquals("", papParameters.getName());
- assertTrue(validationResult.getResult().contains(
- "field \"name\" type \"java.lang.String\" value \"\" INVALID, " + "must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains("\"name\" value \"\" INVALID, " + "is blank");
}
@Test
public void testPapParameterGroup_SetName() {
final PapParameterGroup papParameters = commonTestData.getPapParameterGroup(1);
papParameters.setName("PapNewGroup");
- final GroupValidationResult validationResult = papParameters.validate();
+ final ValidationResult validationResult = papParameters.validate();
assertTrue(validationResult.isValid());
assertEquals("PapNewGroup", papParameters.getName());
}
@@ -101,10 +101,9 @@ public class TestPapParameterGroup {
String json = commonTestData.getPapParameterGroupAsString(1);
json = commonTestData.nullifyField(json, "restServerParameters");
final PapParameterGroup papParameters = commonTestData.getPapParameterGroup(0);
- final GroupValidationResult validationResult = papParameters.validate();
+ final ValidationResult validationResult = papParameters.validate();
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("\"org.onap.policy.common.endpoints.parameters.RestServerParameters\" INVALID, "
- + "parameter group has status INVALID"));
+ assertThat(validationResult.getResult())
+ .contains("\"RestServerParameters\" INVALID, item has status INVALID");
}
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterHandler.java b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterHandler.java
index 1761a7d1..6b6431fa 100644
--- a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterHandler.java
+++ b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterHandler.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -116,8 +116,7 @@ public class TestPapParameterHandler {
arguments.parse(papConfigParameters);
assertThatThrownBy(() -> new PapParameterHandler().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/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpParameters.java b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpParameters.java
index c47b5301..6f398c6f 100644
--- a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpParameters.java
+++ b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpParameters.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-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 +20,7 @@
package org.onap.policy.pap.main.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.assertNotNull;
@@ -27,7 +28,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-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.StandardCoder;
@@ -61,7 +62,7 @@ public class TestPdpParameters {
// valid
String json2 = json;
- GroupValidationResult result = coder.decode(json2, PapParameterGroup.class).getPdpParameters().validate();
+ ValidationResult result = coder.decode(json2, PapParameterGroup.class).getPdpParameters().validate();
assertNull(result.getResult());
assertTrue(result.isValid());
@@ -69,30 +70,28 @@ public class TestPdpParameters {
json2 = json.replaceFirst(": 6", ": 0");
result = coder.decode(json2, PapParameterGroup.class).getPdpParameters().validate();
assertFalse(result.isValid());
- assertTrue(result.getResult().contains(
- "field 'heartBeatMs' type 'long' value '0' INVALID, must be >= 1".replace('\'', '"')));
+ assertThat(result.getResult()).contains(
+ "'heartBeatMs' value '0' INVALID, is below the minimum value: 1".replace('\'', '"'));
// invalid max message age
json2 = json.replaceFirst(": 20000", ": 0");
result = coder.decode(json2, PapParameterGroup.class).getPdpParameters().validate();
assertFalse(result.isValid());
- assertTrue(result.getResult().contains(
- "field 'maxMessageAgeMs' type 'long' value '0' INVALID, must be >= 1".replace('\'', '"')));
+ assertThat(result.getResult()).contains(
+ "'maxMessageAgeMs' value '0' INVALID, is below the minimum value: 1".replace('\'', '"'));
// no update params
json2 = testData.nullifyField(json, "updateParameters");
result = coder.decode(json2, PapParameterGroup.class).getPdpParameters().validate();
assertFalse(result.isValid());
- assertTrue(result.getResult().contains("field 'updateParameters'".replace('\'', '"')));
- assertTrue(result.getResult().contains("is null"));
+ assertThat(result.getResult()).contains("\"updateParameters\"", "is null");
// invalid update params
json2 = json.replaceFirst(": 2", ": -2");
result = coder.decode(json2, PapParameterGroup.class).getPdpParameters().validate();
assertFalse(result.isValid());
- assertTrue(result.getResult().contains("parameter group 'PdpUpdateParameters'".replace('\'', '"')));
- assertTrue(result.getResult().contains(
- "field 'maxWaitMs' type 'long' value '-2' INVALID, must be >= 0".replace('\'', '"')));
+ assertThat(result.getResult()).contains("\"PdpUpdateParameters\"",
+ "'maxWaitMs' value '-2' INVALID, is below the minimum value: 0".replace('\'', '"'));
// no state-change params
json2 = testData.nullifyField(json, "stateChangeParameters");
@@ -103,9 +102,8 @@ public class TestPdpParameters {
json2 = json.replaceFirst(": 5", ": -5");
result = coder.decode(json2, PapParameterGroup.class).getPdpParameters().validate();
assertFalse(result.isValid());
- assertTrue(result.getResult().contains("parameter group 'PdpStateChangeParameters'".replace('\'', '"')));
- assertTrue(result.getResult().contains(
- "field 'maxWaitMs' type 'long' value '-5' INVALID, must be >= 0".replace('\'', '"')));
+ assertThat(result.getResult()).contains("\"PdpStateChangeParameters\"",
+ "'maxWaitMs' value '-5' INVALID, is below the minimum value: 0".replace('\'', '"'));
}
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpRequestParameters.java b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpRequestParameters.java
index e852442f..810bc448 100644
--- a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpRequestParameters.java
+++ b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpRequestParameters.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 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,13 +20,14 @@
package org.onap.policy.pap.main.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;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-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.StandardCoder;
@@ -44,7 +45,7 @@ public class TestPdpRequestParameters {
public void testValidate() throws Exception {
// valid, zeroes
PdpRequestParameters params = makeParams(0, 0);
- GroupValidationResult result = params.validate();
+ ValidationResult result = params.validate();
assertNull(result.getResult());
assertTrue(result.isValid());
@@ -58,15 +59,15 @@ public class TestPdpRequestParameters {
params = makeParams(-1, 120);
result = params.validate();
assertFalse(result.isValid());
- assertTrue(result.getResult().contains(
- "field 'maxRetryCount' type 'int' value '-1' INVALID, must be >= 0".replace('\'', '"')));
+ assertThat(result.getResult()).contains(
+ "'maxRetryCount' value '-1' INVALID, is below the minimum value: 0".replace('\'', '"'));
// invalid wait time
params = makeParams(130, -1);
result = params.validate();
assertFalse(result.isValid());
- assertTrue(result.getResult()
- .contains("field 'maxWaitMs' type 'long' value '-1' INVALID, must be >= 0".replace('\'', '"')));
+ assertThat(result.getResult()).contains(
+ "'maxWaitMs' value '-1' INVALID, is below the minimum value: 0".replace('\'', '"'));
}
private PdpRequestParameters makeParams(int maxRetry, long maxWait) throws Exception {
diff --git a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpStateChangeParameters.java b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpStateChangeParameters.java
index 5744303f..45cbe372 100644
--- a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpStateChangeParameters.java
+++ b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpStateChangeParameters.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 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.
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-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.StandardCoder;
@@ -39,7 +39,7 @@ public class TestPdpStateChangeParameters {
public void testValidate() throws Exception {
// valid, zeroes
PdpStateChangeParameters params = makeParams(10, 20);
- GroupValidationResult result = params.validate();
+ ValidationResult result = params.validate();
assertNull(result.getResult());
assertTrue(result.isValid());
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpUpdateParameters.java b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpUpdateParameters.java
index 6866c401..814894c6 100644
--- a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpUpdateParameters.java
+++ b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPdpUpdateParameters.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 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.
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-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.StandardCoder;
@@ -39,7 +39,7 @@ public class TestPdpUpdateParameters {
public void testValidate() throws Exception {
// valid, zeroes
PdpUpdateParameters params = makeParams(10, 20);
- GroupValidationResult result = params.validate();
+ ValidationResult result = params.validate();
assertNull(result.getResult());
assertTrue(result.isValid());
}