aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-04-28 15:45:22 -0400
committerJim Hahn <jrh3@att.com>2021-05-03 15:44:08 -0400
commite168ce2fad71650ad730519c772a9b093c0a8f43 (patch)
tree8d97f8823eb4f97916b2c19909c6b13e6a008e4a /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src
parentcb09008c4d252dbc9a62f3a1d0b463a74380aa77 (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: I2c0c01fac355e6cde4d8d6998dc42f8a2e2ebb65 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java21
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java9
2 files changed, 16 insertions, 14 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java
index afc07da95..bf24d2260 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications 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.
@@ -24,9 +25,11 @@ package org.onap.policy.apex.plugins.event.carrier.restserver;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
+import org.apache.commons.lang3.StringUtils;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.models.base.Validated;
/**
* Apex parameters for REST as an event carrier technology with Apex as a REST client.
@@ -89,27 +92,25 @@ public class RestServerCarrierTechnologyParameters extends CarrierTechnologyPara
* {@inheritDoc}.
*/
@Override
- public GroupValidationResult validate() {
- final GroupValidationResult result = super.validate();
+ public BeanValidationResult validate() {
+ final BeanValidationResult result = super.validate();
// Check if host is defined, it is only defined on REST server consumers
if (standalone) {
- if (host != null && host.trim().length() == 0) {
- result.setResult("host", ValidationStatus.INVALID,
- "host not specified, host must be specified as a string");
+ if (StringUtils.isBlank(host)) {
+ result.addResult("host", host, ValidationStatus.INVALID, Validated.IS_BLANK);
}
// Check if port is defined, it is only defined on REST server consumers
if (port != -1 && port < MIN_USER_PORT || port > MAX_USER_PORT) {
- result.setResult("port", ValidationStatus.INVALID,
- "[" + port + "] invalid, must be specified as 1024 <= port <= 65535");
+ result.addResult("port", port, ValidationStatus.INVALID, "must be between 1024 and 65535");
}
} else {
if (host != null) {
- result.setResult("host", ValidationStatus.INVALID, "host is specified only in standalone mode");
+ result.addResult("host", host, ValidationStatus.INVALID, "should be specified only in standalone mode");
}
if (port != -1) {
- result.setResult("port", ValidationStatus.INVALID, "port is specified only in standalone mode");
+ result.addResult("port", port, ValidationStatus.INVALID, "should be specified only in standalone mode");
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java
index 2c8a764e8..ef78d3211 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
* Modifications 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.
@@ -21,6 +22,7 @@
package org.onap.policy.apex.plugins.event.carrier.restserver;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -28,12 +30,12 @@ import static org.junit.Assert.assertTrue;
import java.lang.reflect.Field;
import org.junit.Before;
import org.junit.Test;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
public class RestServerCarrierTechnologyParametersTest {
RestServerCarrierTechnologyParameters restServerCarrierTechnologyParameters = null;
- GroupValidationResult result = null;
+ ValidationResult result = null;
/**
* Set up testing.
@@ -144,7 +146,6 @@ public class RestServerCarrierTechnologyParametersTest {
result = restServerCarrierTechnologyParameters.validate();
assertNotNull(result);
assertFalse(result.isValid());
- assertTrue(result.getResult().contains("host is specified only in standalone mode"));
- assertTrue(result.getResult().contains("port is specified only in standalone mode"));
+ assertThat(result.getResult()).contains("host", "port", "should be specified only in standalone mode");
}
}