aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParameters.java16
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java170
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java4
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java5
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java5
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java239
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java39
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java91
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java82
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java58
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java32
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java10
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java21
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParametersTest.java7
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java3
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java10
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java80
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java58
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java236
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java116
-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
25 files changed, 451 insertions, 900 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParameters.java
index 6f352599c..635597548 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParameters.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -21,7 +22,6 @@
package org.onap.policy.apex.service.engine.event.impl.eventrequestor;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
-import org.onap.policy.common.parameters.GroupValidationResult;
/**
* This class holds the parameters that allows an output event to to be sent back into APEX as one
@@ -60,14 +60,6 @@ public class EventRequestorCarrierTechnologyParameters extends CarrierTechnology
* {@inheritDoc}.
*/
@Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public String getName() {
return this.getLabel();
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java
index 5071824ce..eceb0b4f9 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -21,12 +22,18 @@
package org.onap.policy.apex.service.engine.event.impl.filecarrierplugin;
import java.io.File;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.ApexFileEventConsumer;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.producer.ApexFileEventProducer;
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.ObjectValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.parameters.annotations.Min;
import org.onap.policy.common.utils.validation.ParameterValidationUtils;
+import org.onap.policy.models.base.Validated;
/**
* This class holds the parameters that allows transport of events into and out of Apex using files and standard input
@@ -42,6 +49,8 @@ import org.onap.policy.common.utils.validation.ParameterValidationUtils;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@Getter
+@Setter
public class FileCarrierTechnologyParameters extends CarrierTechnologyParameters {
// @formatter:off
/** The label of this carrier technology. */
@@ -60,7 +69,7 @@ public class FileCarrierTechnologyParameters extends CarrierTechnologyParameters
private boolean standardIo = false;
private boolean standardError = false;
private boolean streamingMode = false;
- private long startDelay = 0;
+ private @Min(0) long startDelay = 0;
// @formatter:on
/**
@@ -77,96 +86,6 @@ public class FileCarrierTechnologyParameters extends CarrierTechnologyParameters
}
/**
- * Gets the file name from which to read or to which to write events.
- *
- * @return the file name from which to read or to which to write events
- */
- public String getFileName() {
- return fileName;
- }
-
- /**
- * Checks if is standard IO should be used for input or output.
- *
- * @return true, if standard IO should be used for input or output
- */
- public boolean isStandardIo() {
- return standardIo;
- }
-
- /**
- * Checks if is standard error should be used for output.
- *
- * @return true, if standard error should be used for output
- */
- public boolean isStandardError() {
- return standardError;
- }
-
- /**
- * Checks if is streaming mode is on.
- *
- * @return true, if streaming mode is on
- */
- public boolean isStreamingMode() {
- return streamingMode;
- }
-
- /**
- * Sets the file name from which to read or to which to write events.
- *
- * @param fileName the file name from which to read or to which to write events
- */
- public void setFileName(final String fileName) {
- this.fileName = fileName;
- }
-
- /**
- * Sets if standard IO should be used for event input or output.
- *
- * @param standardIo if standard IO should be used for event input or output
- */
- public void setStandardIo(final boolean standardIo) {
- this.standardIo = standardIo;
- }
-
- /**
- * Sets if standard error should be used for event output.
- *
- * @param standardError if standard error should be used for event output
- */
- public void setStandardError(final boolean standardError) {
- this.standardError = standardError;
- }
-
- /**
- * Sets streaming mode.
- *
- * @param streamingMode the streaming mode value
- */
- public void setStreamingMode(final boolean streamingMode) {
- this.streamingMode = streamingMode;
- }
-
- /**
- * Gets the delay in milliseconds before the plugin starts processing.
- *
- * @return the delay
- */
- public long getStartDelay() {
- return startDelay;
- }
-
- /**
- * Sets the delay in milliseconds before the plugin starts processing.
- *
- * @param startDelay the delay
- */
- public void setStartDelay(final long startDelay) {
- this.startDelay = startDelay;
- }
-
- /**
* {@inheritDoc}.
*/
@Override
@@ -188,36 +107,29 @@ public class FileCarrierTechnologyParameters extends CarrierTechnologyParameters
* {@inheritDoc}.
*/
@Override
- public GroupValidationResult validate() {
- final GroupValidationResult result = super.validate();
+ public BeanValidationResult validate() {
+ final BeanValidationResult result = super.validate();
if (!standardIo && !standardError) {
- validateFileName(result);
+ result.addResult(validateFileName());
}
if (standardIo || standardError) {
streamingMode = true;
}
- if (startDelay < 0) {
- result.setResult("startDelay", ValidationStatus.INVALID,
- "startDelay must be zero or a positive number of milliseconds");
- }
-
return result;
}
-
+
/**
* Validate the file name parameter.
- *
- * @param result the variable in which to store the result of the validation
+ *
+ * @return the result of the validation
*/
- private void validateFileName(final GroupValidationResult result) {
+ private ValidationResult validateFileName() {
if (!ParameterValidationUtils.validateStringParameter(fileName)) {
- result.setResult(FILE_NAME_TOKEN, ValidationStatus.INVALID,
- "\"" + fileName + "\" invalid, must be specified as a non-empty string");
- return;
+ return new ObjectValidationResult(FILE_NAME_TOKEN, fileName, ValidationStatus.INVALID, Validated.IS_BLANK);
}
String absoluteFileName = null;
@@ -233,53 +145,65 @@ public class FileCarrierTechnologyParameters extends CarrierTechnologyParameters
// Check if the file exists, the file should be a regular file and should be readable
if (theFile.exists()) {
- validateExistingFile(result, absoluteFileName, theFile);
+ return validateExistingFile(absoluteFileName, theFile);
} else {
// The path to the file should exist and should be writable
- validateNewFileParent(result, absoluteFileName, theFile);
+ return validateNewFileParent(absoluteFileName, theFile);
}
}
/**
* Validate an existing file is OK.
- *
- * @param result the result of the validation
+ *
* @param absoluteFileName the absolute file name of the file
* @param theFile the file that exists
+ * @return the result of the validation
*/
- private void validateExistingFile(final GroupValidationResult result, String absoluteFileName, File theFile) {
+ private ValidationResult validateExistingFile(String absoluteFileName, File theFile) {
// Check that the file is a regular file
if (!theFile.isFile()) {
- result.setResult(FILE_NAME_TOKEN, ValidationStatus.INVALID, "is not a plain file");
+ return new ObjectValidationResult(FILE_NAME_TOKEN, absoluteFileName, ValidationStatus.INVALID,
+ "is not a plain file");
+
} else {
fileName = absoluteFileName;
if (!theFile.canRead()) {
- result.setResult(FILE_NAME_TOKEN, ValidationStatus.INVALID, "is not readable");
+ return new ObjectValidationResult(FILE_NAME_TOKEN, absoluteFileName, ValidationStatus.INVALID,
+ "is not readable");
}
+
+ return null;
}
}
/**
* Validate the parent of a new file is OK.
- *
- * @param result the result of the validation
+ *
* @param absoluteFileName the absolute file name of the file
* @param theFile the file that exists
+ * @return the result of the validation
*/
- private void validateNewFileParent(final GroupValidationResult result, String absoluteFileName, File theFile) {
+ private ValidationResult validateNewFileParent(String absoluteFileName, File theFile) {
// Check that the parent of the file is a directory
if (!theFile.getParentFile().exists()) {
- result.setResult(FILE_NAME_TOKEN, ValidationStatus.INVALID, "parent of file does not exist");
+ return new ObjectValidationResult(FILE_NAME_TOKEN, absoluteFileName, ValidationStatus.INVALID,
+ "parent of file does not exist");
+
} else if (!theFile.getParentFile().isDirectory()) {
// Check that the parent of the file is a directory
- result.setResult(FILE_NAME_TOKEN, ValidationStatus.INVALID, "parent of file is not directory");
+ return new ObjectValidationResult(FILE_NAME_TOKEN, absoluteFileName, ValidationStatus.INVALID,
+ "parent of file is not directory");
+
} else {
fileName = absoluteFileName;
if (!theFile.getParentFile().canRead()) {
- result.setResult(FILE_NAME_TOKEN, ValidationStatus.INVALID, "is not readable");
+ return new ObjectValidationResult(FILE_NAME_TOKEN, absoluteFileName, ValidationStatus.INVALID,
+ "is not readable");
}
+
+ return null;
}
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java
index 9757c57e8..80974af31 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
+ * 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.
@@ -106,14 +107,12 @@ public class ApexMain {
// The arguments return a string if there is a message to print and we should exit
final String argumentMessage = arguments.parse(args);
if (argumentMessage != null) {
- LOGGER.info(argumentMessage);
throw new ApexException(argumentMessage);
}
// Validate that the arguments are sane
arguments.validateInputFiles();
} catch (final ApexException | CommandLineException e) {
- LOGGER.error("Arguments validation failed.", e);
throw new ApexException("Arguments validation failed.", e);
}
@@ -122,7 +121,6 @@ public class ApexMain {
try {
axParameters = apexParameterHandler.getParameters(arguments);
} catch (final Exception e) {
- LOGGER.error("Cannot create APEX Parameters from the arguments provided.", e);
throw new ApexException("Cannot create APEX Parameters from the arguments provided.", e);
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java
index a558b9946..3deb234c6 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications 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.
@@ -48,7 +49,7 @@ import org.onap.policy.apex.service.engine.runtime.ApexEventListener;
import org.onap.policy.apex.service.engine.runtime.EngineService;
import org.onap.policy.apex.service.engine.runtime.EngineServiceEventInterface;
import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -138,7 +139,7 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven
throw new ApexException("engine service configuration parameters are null");
}
- final GroupValidationResult validation = config.validate();
+ final ValidationResult validation = config.validate();
if (!validation.isValid()) {
LOGGER.warn("Invalid engine service configuration parameters: {}" + validation.getResult());
throw new ApexException("Invalid engine service configuration parameters: " + validation);
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java
index 673d9cab5..0a317d600 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
+ * 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.
@@ -38,9 +39,9 @@ import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnolo
import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParametersJsonAdapter;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParametersJsonAdapter;
-import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterException;
import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.ext.XLogger;
@@ -107,7 +108,7 @@ public class ApexParameterHandler {
}
// Validate the parameters
- final GroupValidationResult validationResult = parameters.validate();
+ final ValidationResult validationResult = parameters.validate();
if (!validationResult.isValid()) {
String returnMessage = "validation error(s) on parameters from \"" + toscaPolicyFilePath + "\"\n";
returnMessage += validationResult.getResult();
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java
index 692d5aee3..1302661b9 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -24,20 +25,30 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.common.parameters.BeanValidator;
import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Size;
+import org.onap.policy.common.parameters.annotations.Valid;
import org.onap.policy.common.utils.validation.ParameterValidationUtils;
+import org.onap.policy.models.base.Validated;
/**
* The main container parameter class for an Apex service.
- *
+ *
* <p>The following parameters are defined: <ol> <li>engineServiceParameters: The parameters for the Apex engine service
* itself, such as the number of engine threads to run and the deployment port number to use. <li>eventOutputParameters:
* A map of parameters for event outputs that Apex will use to emit events. Apex emits events on all outputs
@@ -48,6 +59,8 @@ import org.onap.policy.common.utils.validation.ParameterValidationUtils;
*/
public class ApexParameters implements ParameterGroup {
// Parameter group name
+ @Getter
+ @Setter
private String name;
// Constants for recurring strings
@@ -58,16 +71,27 @@ public class ApexParameters implements ParameterGroup {
private static final String FOR_PEERED_MODE_STRING = " for peered mode ";
// Properties for the Java JVM
+ @Getter
private String[][] javaProperties = null;
// Parameters for the engine service and the engine threads in the engine service
- private EngineServiceParameters engineServiceParameters;
+ @Getter
+ @Setter
+ private @NotNull @Valid EngineServiceParameters engineServiceParameters;
// Parameters for the event outputs that Apex will use to send events on its outputs
- private Map<String, EventHandlerParameters> eventOutputParameters = new LinkedHashMap<>();
+ @Getter
+ @Setter
+ @Size(min = 1)
+ private Map<@NotNull @NotBlank String, @NotNull @Valid EventHandlerParameters> eventOutputParameters =
+ new LinkedHashMap<>();
// Parameters for the event inputs that Apex will use to receive events on its inputs
- private Map<String, EventHandlerParameters> eventInputParameters = new LinkedHashMap<>();
+ @Getter
+ @Setter
+ @Size(min = 1)
+ private Map<@NotNull @NotBlank String, @NotNull @Valid EventHandlerParameters> eventInputParameters =
+ new LinkedHashMap<>();
/**
* Constructor to create an apex parameters instance and register the instance with the parameter service.
@@ -80,70 +104,6 @@ public class ApexParameters implements ParameterGroup {
}
/**
- * Gets the parameters for the Apex engine service.
- *
- * @return the engine service parameters
- */
- public EngineServiceParameters getEngineServiceParameters() {
- return engineServiceParameters;
- }
-
- /**
- * Sets the engine service parameters.
- *
- * @param engineServiceParameters the engine service parameters
- */
- public void setEngineServiceParameters(final EngineServiceParameters engineServiceParameters) {
- this.engineServiceParameters = engineServiceParameters;
- }
-
- /**
- * Gets the event output parameter map.
- *
- * @return the parameters for all event outputs
- */
- public Map<String, EventHandlerParameters> getEventOutputParameters() {
- return eventOutputParameters;
- }
-
- /**
- * Sets the event output parameters.
- *
- * @param eventOutputParameters the event outputs parameters
- */
- public void setEventOutputParameters(final Map<String, EventHandlerParameters> eventOutputParameters) {
- this.eventOutputParameters = eventOutputParameters;
- }
-
- /**
- * Gets the event input parameter map.
- *
- * @return the parameters for all event inputs
- */
- public Map<String, EventHandlerParameters> getEventInputParameters() {
- return eventInputParameters;
- }
-
- /**
- * Sets the event input parameters.
- *
- * @param eventInputParameters the event input parameters
- */
- public void setEventInputParameters(final Map<String, EventHandlerParameters> eventInputParameters) {
- this.eventInputParameters = eventInputParameters;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- /**
* Check if Java properties have been specified.
*
* @return true if Java properties have been specified
@@ -152,38 +112,11 @@ public class ApexParameters implements ParameterGroup {
return javaProperties != null && javaProperties.length > 0;
}
- /**
- * Gets the Java properties that have been specified.
- *
- * @return the Java properties that have been specified
- */
- public String[][] getJavaProperties() {
- return javaProperties;
- }
-
@Override
- public GroupValidationResult validate() {
- GroupValidationResult result = new GroupValidationResult(this);
+ public BeanValidationResult validate() {
+ BeanValidationResult result = new BeanValidator().validateTop(getClass().getSimpleName(), this);
- validateJavaProperties(result);
-
- if (engineServiceParameters == null) {
- result.setResult("engineServiceParameters", ValidationStatus.INVALID,
- "engine service parameters are not specified");
- } else {
- result.setResult("engineServiceParameters", engineServiceParameters.validate());
- }
-
- // Sanity check, we must have an entry in both output and input maps
- if (eventInputParameters.isEmpty()) {
- result.setResult(EVENT_INPUT_PARAMETERS_STRING, ValidationStatus.INVALID,
- "at least one event input must be specified");
- }
-
- if (eventOutputParameters.isEmpty()) {
- result.setResult(EVENT_OUTPUT_PARAMETERS_STRING, ValidationStatus.INVALID,
- "at least one event output must be specified");
- }
+ result.addResult(validateJavaProperties());
// Validate that the values of all parameters are ok
validateEventHandlerMap(EVENT_INPUT_PARAMETERS_STRING, result, eventInputParameters);
@@ -201,56 +134,50 @@ public class ApexParameters implements ParameterGroup {
/**
* This method validates the java properties variable if it is present.
- *
- * @param result the result of the validation
*/
- private void validateJavaProperties(GroupValidationResult result) {
+ private ValidationResult validateJavaProperties() {
if (javaProperties == null) {
- return;
+ return null;
}
- StringBuilder errorMessageBuilder = new StringBuilder();
+ BeanValidationResult result = new BeanValidationResult(JAVA_PROPERTIES, javaProperties);
+ int item = 0;
for (String[] javaProperty : javaProperties) {
+ final String label = "entry " + (item++);
+ final List<String> value = (javaProperty == null ? null : Arrays.asList(javaProperty));
+ BeanValidationResult result2 = new BeanValidationResult(label, value);
+
if (javaProperty == null) {
- errorMessageBuilder.append("java properties array entry is null\n");
+ // note: add to result, not result2
+ result.addResult(label, null, ValidationStatus.INVALID, Validated.IS_NULL);
+
} else if (javaProperty.length != 2) {
- errorMessageBuilder.append("java properties array entries must have one key and one value: "
- + Arrays.deepToString(javaProperty) + "\n");
+ // note: add to result, not result2
+ result.addResult(label, value, ValidationStatus.INVALID, "must have one key and one value");
+
} else if (!ParameterValidationUtils.validateStringParameter(javaProperty[0])) {
- errorMessageBuilder
- .append("java properties key is null or blank: " + Arrays.deepToString(javaProperty) + "\n");
+ result2.addResult("key", javaProperty[0], ValidationStatus.INVALID, Validated.IS_BLANK);
+
} else if (!ParameterValidationUtils.validateStringParameter(javaProperty[1])) {
- errorMessageBuilder
- .append("java properties value is null or blank: " + Arrays.deepToString(javaProperty) + "\n");
+ result2.addResult("value", javaProperty[1], ValidationStatus.INVALID, Validated.IS_BLANK);
}
- }
- if (errorMessageBuilder.length() > 0) {
- result.setResult(JAVA_PROPERTIES, ValidationStatus.INVALID, errorMessageBuilder.toString());
+ result.addResult(result2);
}
+
+ return result;
}
/**
* This method validates the parameters in an event handler map.
- *
+ *
* @param eventHandlerType the type of the event handler to use on error messages
* @param result the result object to use to return validation messages
* @param parsForValidation The event handler parameters to validate (input or output)
*/
- private void validateEventHandlerMap(final String eventHandlerType, final GroupValidationResult result,
+ private void validateEventHandlerMap(final String eventHandlerType, final BeanValidationResult result,
final Map<String, EventHandlerParameters> parsForValidation) {
for (final Entry<String, EventHandlerParameters> parameterEntry : parsForValidation.entrySet()) {
- if (parameterEntry.getKey() == null || parameterEntry.getKey().trim().isEmpty()) {
- result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID,
- "invalid " + eventHandlerType + " name \"" + parameterEntry.getKey() + "\"");
- } else if (parameterEntry.getValue() == null) {
- result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID,
- "invalid/Null event input prameters specified for " + eventHandlerType + " name \""
- + parameterEntry.getKey() + "\" ");
- } else {
- result.setResult(eventHandlerType, parameterEntry.getKey(), parameterEntry.getValue().validate());
- }
-
parameterEntry.getValue().setName(parameterEntry.getKey());
// Validate parameters for peered mode settings
@@ -262,46 +189,46 @@ public class ApexParameters implements ParameterGroup {
/**
* Validate parameter values for event handlers in a peered mode.
- *
+ *
* @param eventHandlerType The event handler type we are checking
* @param result The result object to which to append any error messages
* @param parameterEntry The entry to check the peered mode on
* @param peeredMode The mode to check
*/
- private void validatePeeredModeParameters(final String eventHandlerType, final GroupValidationResult result,
+ private void validatePeeredModeParameters(final String eventHandlerType, final BeanValidationResult result,
final Entry<String, EventHandlerParameters> parameterEntry, final EventHandlerPeeredMode peeredMode) {
final String messagePreamble = "specified peered mode \"" + peeredMode + "\"";
final String peer = parameterEntry.getValue().getPeer(peeredMode);
if (parameterEntry.getValue().isPeeredMode(peeredMode)) {
if (peer == null || peer.trim().isEmpty()) {
- result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID,
+ result.addResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID,
messagePreamble + " mandatory parameter not specified or is null");
}
if (parameterEntry.getValue().getPeerTimeout(peeredMode) < 0) {
- result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID,
+ result.addResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID,
messagePreamble + " timeout value \"" + parameterEntry.getValue().getPeerTimeout(peeredMode)
+ "\" is illegal, specify a non-negative timeout value in milliseconds");
}
} else {
if (peer != null) {
- result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID, messagePreamble
- + " peer is illegal on " + eventHandlerType + " \"" + parameterEntry.getKey() + "\" ");
+ result.addResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID, messagePreamble
+ + " peer is illegal");
}
if (parameterEntry.getValue().getPeerTimeout(peeredMode) != 0) {
- result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID, messagePreamble
- + " timeout is illegal on " + eventHandlerType + " \"" + parameterEntry.getKey() + "\"");
+ result.addResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID, messagePreamble
+ + " timeout is illegal");
}
}
}
/**
* This method validates that the settings are valid for the given peered mode.
- *
+ *
* @param result The result object to which to append any error messages
* @param peeredMode The peered mode to check
*/
- private void validatePeeredMode(final GroupValidationResult result, final EventHandlerPeeredMode peeredMode) {
+ private void validatePeeredMode(final BeanValidationResult result, final EventHandlerPeeredMode peeredMode) {
// Find the input and output event handlers that use this peered mode
final Map<String, EventHandlerParameters> inputParametersUsingMode = new HashMap<>();
final Map<String, EventHandlerParameters> outputParametersUsingMode = new HashMap<>();
@@ -327,13 +254,13 @@ public class ApexParameters implements ParameterGroup {
/**
* This method validates that the settings are valid for the event handlers on one.
- *
+ *
* @param handlerMapVariableName the variable name of the map on which the paired parameters are being checked
* @param result The result object to which to append any error messages
* @param leftModeParameters The mode parameters being checked
* @param rightModeParameters The mode parameters being referenced by the checked parameters
*/
- private void validatePeeredModePeers(final String handlerMapVariableName, final GroupValidationResult result,
+ private void validatePeeredModePeers(final String handlerMapVariableName, final BeanValidationResult result,
final EventHandlerPeeredMode peeredMode, final Map<String, EventHandlerParameters> leftModeParameterMap,
final Map<String, EventHandlerParameters> rightModeParameterMap) {
@@ -351,7 +278,7 @@ public class ApexParameters implements ParameterGroup {
// Check that the peer reference is OK
if (rightModeParameters == null) {
- result.setResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
+ result.addResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING + peeredMode
+ " does not exist or is not defined with the same peered mode");
continue;
@@ -360,20 +287,20 @@ public class ApexParameters implements ParameterGroup {
// Now check that the right side peer is the left side event handler
final String rightSidePeer = rightModeParameters.getPeer(peeredMode);
if (!rightSidePeer.equals(leftModeParameterEntry.getKey())) {
- result.setResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
- PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING + peeredMode
- + ", value \"" + rightSidePeer + "\" on peer \"" + leftSidePeer
- + "\" does not equal event handler \"" + leftModeParameterEntry.getKey() + "\"");
+ result.addResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
+ PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + '"'
+ + FOR_PEERED_MODE_STRING + peeredMode + ", value \"" + rightSidePeer
+ + "\" on peer does not equal event handler");
} else {
// Check for duplicates
if (!leftCheckDuplicateSet.add(leftSidePeer)) {
- result.setResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
+ result.addResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING + peeredMode
+ ", peer value \"" + leftSidePeer + "\" on event handler \""
+ leftModeParameterEntry.getKey() + "\" is used more than once");
}
if (!rightCheckDuplicateSet.add(rightSidePeer)) {
- result.setResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
+ result.addResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING + peeredMode
+ ", peer value \"" + rightSidePeer + "\" on peer \"" + leftSidePeer
+ "\" on event handler \"" + leftModeParameterEntry.getKey() + "\" is used more than once");
@@ -381,12 +308,12 @@ public class ApexParameters implements ParameterGroup {
}
if (!crossCheckPeeredTimeoutValues(leftModeParameters, rightModeParameters, peeredMode)) {
- result.setResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
- PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING + peeredMode
- + " timeout " + leftModeParameters.getPeerTimeout(peeredMode) + " on event handler \""
- + leftModeParameters.getName() + "\" does not equal timeout "
- + rightModeParameters.getPeerTimeout(peeredMode) + " on event handler \""
- + rightModeParameters.getName() + "\"");
+ result.addResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
+ PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + '"'
+ + FOR_PEERED_MODE_STRING + peeredMode + " timeout "
+ + leftModeParameters.getPeerTimeout(peeredMode)
+ + " does not equal peer timeout "
+ + rightModeParameters.getPeerTimeout(peeredMode));
}
}
@@ -394,7 +321,7 @@ public class ApexParameters implements ParameterGroup {
/**
* Validate the timeout values on two peers.
- *
+ *
* @param leftModeParameters The parameters of the left hand peer
* @param peeredMode The peered mode being checked
* @return true if the timeout values are cross checked as being OK
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java
index e688aad17..503d4c5d7 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java
@@ -21,10 +21,11 @@
package org.onap.policy.apex.service.parameters.carriertechnology;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.ParameterRuntimeException;
-import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.parameters.annotations.ClassName;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
/**
* The default carrier technology parameter class that may be specialized by carrier technology plugins that require
@@ -37,15 +38,17 @@ import org.onap.policy.common.parameters.ValidationStatus;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public abstract class CarrierTechnologyParameters implements ParameterGroup {
+@NotNull
+@NotBlank
+public abstract class CarrierTechnologyParameters extends ParameterGroupImpl {
// The carrier technology label
private String label = null;
// Producer and Consumer plugin classes for the event producer and consumer for this carrier
// technology
- private String eventProducerPluginClass = null;
- private String eventConsumerPluginClass = null;
+ private @ClassName String eventProducerPluginClass = null;
+ private @ClassName String eventConsumerPluginClass = null;
/**
* Constructor to create a carrier technology parameters instance with the name of a sub class of this class and
@@ -130,30 +133,6 @@ public abstract class CarrierTechnologyParameters implements ParameterGroup {
+ ", eventConsumerPluginClass=" + eventConsumerPluginClass + "]";
}
- /**
- * {@inheritDoc}.
- */
- @Override
- public GroupValidationResult validate() {
- final GroupValidationResult result = new GroupValidationResult(this);
-
- if (label == null || label.length() == 0) {
- result.setResult("label", ValidationStatus.INVALID, "carrier technology label not specified or is blank");
- }
-
- if (eventProducerPluginClass == null || eventProducerPluginClass.length() == 0) {
- result.setResult("eventProducerPluginClass", ValidationStatus.INVALID,
- "carrier technology eventProducerPluginClass not specified or is blank");
- }
-
- if (eventConsumerPluginClass == null || eventConsumerPluginClass.length() == 0) {
- result.setResult("eventConsumerPluginClass", ValidationStatus.INVALID,
- "carrier technology eventConsumerPluginClass not specified or is blank");
- }
-
- return result;
- }
-
@Override
public String getName() {
return this.getLabel();
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java
index eab936edc..4e086e809 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications 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,6 +24,7 @@ package org.onap.policy.apex.service.parameters.carriertechnology;
import java.util.Arrays;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -32,9 +34,12 @@ import javax.ws.rs.core.MultivaluedMap;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
-import org.onap.policy.common.parameters.GroupValidationResult;
+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.validation.ParameterValidationUtils;
+import org.onap.policy.models.base.Validated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -155,42 +160,42 @@ public class RestPluginCarrierTechnologyParameters extends CarrierTechnologyPara
* {@inheritDoc}.
*/
@Override
- public GroupValidationResult validate() {
- GroupValidationResult result = super.validate();
+ public BeanValidationResult validate() {
+ BeanValidationResult result = super.validate();
- validateUrl(result);
- validateHttpHeaders(result);
+ result.addResult(validateUrl());
+ result.addResult(validateHttpHeaders());
+ result.addResult(validateHttpCodeFilter());
- return validateHttpCodeFilter(result);
+ return result;
}
// @formatter:off
/**
* Validate the URL.
*
- * <p>Checks:
- * http://www.blah.com/{par1/somethingelse (Missing end tag) use {[^\\{}]*$
- * http://www.blah.com/{par1/{some}thingelse (Nested tag) use {[^}]*{
- * http://www.blah.com/{par1}/some}thingelse (Missing start tag1) use }[^{}]*.}
- * http://www.blah.com/par1}/somethingelse (Missing start tag2) use }[^{}]*}
- * http://www.blah.com/{}/somethingelse (Empty tag) use {[\s]*}
- * @param result the result of the validation
+ * <p/>Checks:
+ * <br/>http://www.blah.com/{par1/somethingelse (Missing end tag) use {[^\\{}]*$
+ * <br/>http://www.blah.com/{par1/{some}thingelse (Nested tag) use {[^}]*{
+ * <br/>http://www.blah.com/{par1}/some}thingelse (Missing start tag1) use }[^{}]*.}
+ * <br/>http://www.blah.com/par1}/somethingelse (Missing start tag2) use }[^{}]*}
+ * <br/>http://www.blah.com/{}/somethingelse (Empty tag) use {[\s]*}
*/
// @formatter:on
- public GroupValidationResult validateUrl(final GroupValidationResult result) {
+ public ValidationResult validateUrl() {
// The URL may be optional so existence must be checked in the plugin code
- if (getUrl() == null) {
- return result;
+ String url2 = getUrl();
+ if (url2 == null) {
+ return null;
}
- Matcher matcher = patternErrorKey.matcher(getUrl());
+ Matcher matcher = patternErrorKey.matcher(url2);
if (matcher.find()) {
- final String urlInvalidMessage = "invalid URL " + getUrl() + " has been set for event sending on "
- + getLabel();
- result.setResult("url", ValidationStatus.INVALID, urlInvalidMessage);
+ final String urlInvalidMessage = "invalid URL has been set for event sending on " + getLabel();
+ return new ObjectValidationResult("url", url2, ValidationStatus.INVALID, urlInvalidMessage);
}
- return result;
+ return null;
}
/**
@@ -198,24 +203,35 @@ public class RestPluginCarrierTechnologyParameters extends CarrierTechnologyPara
*
* @param result the result of the validation
*/
- private GroupValidationResult validateHttpHeaders(final GroupValidationResult result) {
+ private ValidationResult validateHttpHeaders() {
if (httpHeaders == null) {
- return result;
+ return null;
}
+ BeanValidationResult result = new BeanValidationResult(HTTP_HEADERS, httpHeaders);
+
+ int item = 0;
for (String[] httpHeader : httpHeaders) {
+ final String label = "entry " + (item++);
+ final List<String> value = (httpHeader == null ? null : Arrays.asList(httpHeader));
+ BeanValidationResult result2 = new BeanValidationResult(label, value);
+
if (httpHeader == null) {
- result.setResult(HTTP_HEADERS, ValidationStatus.INVALID, "HTTP header array entry is null");
+ // note: add to result, not result2
+ result.addResult(label, null, ValidationStatus.INVALID, Validated.IS_NULL);
+
} else if (httpHeader.length != 2) {
- result.setResult(HTTP_HEADERS, ValidationStatus.INVALID,
- "HTTP header array entries must have one key and one value: " + Arrays.deepToString(httpHeader));
+ // note: add to result, not result2
+ result.addResult(label, value, ValidationStatus.INVALID, "must have one key and one value");
+
} else if (!ParameterValidationUtils.validateStringParameter(httpHeader[0])) {
- result.setResult(HTTP_HEADERS, ValidationStatus.INVALID,
- "HTTP header key is null or blank: " + Arrays.deepToString(httpHeader));
+ result2.addResult("key", httpHeader[0], ValidationStatus.INVALID, Validated.IS_BLANK);
+
} else if (!ParameterValidationUtils.validateStringParameter(httpHeader[1])) {
- result.setResult(HTTP_HEADERS, ValidationStatus.INVALID,
- "HTTP header value is null or blank: " + Arrays.deepToString(httpHeader));
+ result2.addResult("value", httpHeader[1], ValidationStatus.INVALID, Validated.IS_BLANK);
}
+
+ result.addResult(result2);
}
return result;
@@ -223,28 +239,27 @@ public class RestPluginCarrierTechnologyParameters extends CarrierTechnologyPara
/**
* Validate the HTTP code filter.
- *
- * @param result the result of the validation
*/
- public GroupValidationResult validateHttpCodeFilter(final GroupValidationResult result) {
+ public ValidationResult validateHttpCodeFilter() {
if (httpCodeFilter == null) {
httpCodeFilter = DEFAULT_HTTP_CODE_FILTER;
} else if (StringUtils.isBlank(httpCodeFilter)) {
- result.setResult(HTTP_CODE_FILTER, ValidationStatus.INVALID,
- "HTTP code filter must be specified as a three digit regular expression");
+ return new ObjectValidationResult(HTTP_CODE_FILTER, httpCodeFilter, ValidationStatus.INVALID,
+ "must be a three digit regular expression");
} else {
try {
Pattern.compile(httpCodeFilter);
} catch (PatternSyntaxException pse) {
+ LOGGER.debug("Invalid HTTP code filter", pse);
String message = "Invalid HTTP code filter, the filter must be specified as a three digit "
+ "regular expression: " + pse.getMessage();
- result.setResult(HTTP_CODE_FILTER, ValidationStatus.INVALID, message);
- LOGGER.debug(message, pse);
+ return new ObjectValidationResult(HTTP_CODE_FILTER, httpCodeFilter, ValidationStatus.INVALID,
+ message);
}
}
- return result;
+ return null;
}
/**
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java
index afede627e..d33ae1697 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * 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,16 +22,21 @@
package org.onap.policy.apex.service.parameters.engineservice;
+import javax.validation.Valid;
import lombok.Getter;
import lombok.Setter;
-import org.apache.commons.lang3.StringUtils;
import org.onap.policy.apex.core.engine.EngineParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.service.parameters.ApexParameterConstants;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.common.parameters.BeanValidator;
import org.onap.policy.common.parameters.ParameterGroup;
-import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.parameters.annotations.Max;
+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.Pattern;
// @formatter:off
/**
@@ -58,6 +64,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
// @formatter:on
@Getter
@Setter
+@NotNull
public class EngineServiceParameters implements ParameterGroup {
private static final int MAX_PORT = 65535;
@@ -80,17 +87,25 @@ public class EngineServiceParameters implements ParameterGroup {
// Constants for repeated strings
// Apex engine service parameters
+ @Pattern(regexp = AxKey.NAME_REGEXP)
private String name = DEFAULT_NAME;
+ @Pattern(regexp = AxKey.VERSION_REGEXP)
private String version = DEFAULT_VERSION;
+ @Min(0)
private int id = DEFAULT_ID;
+ @Min(1)
private int instanceCount = DEFAULT_INSTANCE_COUNT;
+ @Min(1)
+ @Max(MAX_PORT)
private int deploymentPort = DEFAULT_DEPLOYMENT_PORT;
+ @NotBlank
private String policyModel = null;
+ @Min(0)
private long periodicEventPeriod = 0;
// @formatter:on
// Apex engine internal parameters
- private EngineParameters engineParameters = new EngineParameters();
+ private @Valid EngineParameters engineParameters = new EngineParameters();
/**
* Constructor to create an apex engine service parameters instance and register the instance with the parameter
@@ -126,63 +141,8 @@ public class EngineServiceParameters implements ParameterGroup {
* {@inheritDoc}.
*/
@Override
- public GroupValidationResult validate() {
- final GroupValidationResult result = new GroupValidationResult(this);
-
- validateStringParameters(result);
-
- validateNumericParameters(result);
-
- if (StringUtils.isBlank(policyModel)) {
- result.setResult("policyModel", ValidationStatus.INVALID, "must be specified");
- }
- result.setResult("engineParameters", engineParameters.validate());
-
- return result;
- }
-
- /**
- * Validate string parameters.
- *
- * @param result the result of string parameter validation
- */
- private void validateStringParameters(final GroupValidationResult result) {
- if (name == null || !name.matches(AxKey.NAME_REGEXP)) {
- result.setResult("name", ValidationStatus.INVALID,
- "name is invalid, it must match regular expression" + AxKey.NAME_REGEXP);
- }
-
- if (version == null || !version.matches(AxKey.VERSION_REGEXP)) {
- result.setResult("version", ValidationStatus.INVALID,
- "version is invalid, it must match regular expression" + AxKey.VERSION_REGEXP);
- }
- }
-
- /**
- * Validate numeric parameters.
- *
- * @param result the result of numeric parameter validation
- */
- private void validateNumericParameters(final GroupValidationResult result) {
- if (id < 0) {
- result.setResult("id", ValidationStatus.INVALID,
- "id not specified or specified value [" + id + "] invalid, must be specified as id >= 0");
- }
-
- if (instanceCount < 1) {
- result.setResult("instanceCount", ValidationStatus.INVALID,
- "instanceCount [" + instanceCount + "] invalid, must be specified as instanceCount >= 1");
- }
-
- if (deploymentPort < 1 || deploymentPort > MAX_PORT) {
- result.setResult("deploymentPort", ValidationStatus.INVALID, "deploymentPort [" + deploymentPort
- + "] invalid, must be specified as 1024 <= port <= 65535");
- }
-
- if (periodicEventPeriod < 0) {
- result.setResult("periodicEventPeriod", ValidationStatus.INVALID, "periodicEventPeriod ["
- + periodicEventPeriod + "] invalid, must be specified in milliseconds as >=0");
- }
+ public BeanValidationResult validate() {
+ return new BeanValidator().validateTop(getClass().getSimpleName(), this);
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java
index 72eb58b0f..7fb4584fe 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -25,18 +26,21 @@ import java.util.regex.PatternSyntaxException;
import org.onap.policy.apex.service.parameters.ApexParameterConstants;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.common.parameters.BeanValidator;
import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The parameters for a single event producer, event consumer or synchronous event handler.
- *
+ *
* <p>Event producers, consumers, and synchronous event handlers all use a carrier technology and an event protocol so
* the actual parameters for each one are the same. Therefore, we use the same class for the parameters of each one.
- *
+ *
* <p>The following parameters are defined: <ol> <li>carrierTechnologyParameters: The carrier technology is the type of
* messaging infrastructure used to carry events. Examples are File, Kafka or REST. <li>eventProtocolParameters: The
* format that the events are in when being carried. Examples are JSON, XML, or Java Beans. carrier technology
@@ -56,8 +60,8 @@ public class EventHandlerParameters implements ParameterGroup {
private static final Logger LOGGER = LoggerFactory.getLogger(EventHandlerParameters.class);
private String name = null;
- private CarrierTechnologyParameters carrierTechnologyParameters = null;
- private EventProtocolParameters eventProtocolParameters = null;
+ private @NotNull @Valid CarrierTechnologyParameters carrierTechnologyParameters = null;
+ private @NotNull @Valid EventProtocolParameters eventProtocolParameters = null;
private boolean synchronousMode = false;
private String synchronousPeer = null;
private long synchronousTimeout = 0;
@@ -97,7 +101,7 @@ public class EventHandlerParameters implements ParameterGroup {
/**
* Checks if the name of the event handler is set.
- *
+ *
* @return true if the name is set
*/
public boolean checkSetName() {
@@ -214,7 +218,7 @@ public class EventHandlerParameters implements ParameterGroup {
/**
* Get the timeout value for the event handler in peered mode.
- *
+ *
* @param peeredMode the peered mode to get the timeout for
* @return the timeout value
*/
@@ -231,7 +235,7 @@ public class EventHandlerParameters implements ParameterGroup {
/**
* Set the timeout value for the event handler in peered mode.
- *
+ *
* @param peeredMode the peered mode to set the timeout for
* @param timeout the timeout value
*/
@@ -306,22 +310,8 @@ public class EventHandlerParameters implements ParameterGroup {
* {@inheritDoc}.
*/
@Override
- public GroupValidationResult validate() {
- final GroupValidationResult result = new GroupValidationResult(this);
-
- if (eventProtocolParameters == null) {
- result.setResult("eventProtocolParameters", ValidationStatus.INVALID,
- "event handler eventProtocolParameters not specified or blank");
- } else {
- result.setResult("eventProtocolParameters", eventProtocolParameters.validate());
- }
-
- if (carrierTechnologyParameters == null) {
- result.setResult("carrierTechnologyParameters", ValidationStatus.INVALID,
- "event handler carrierTechnologyParameters not specified or blank");
- } else {
- result.setResult("carrierTechnologyParameters", carrierTechnologyParameters.validate());
- }
+ public BeanValidationResult validate() {
+ final BeanValidationResult result = new BeanValidator().validateTop(getClass().getSimpleName(), this);
if (eventNameFilter != null) {
try {
@@ -329,7 +319,7 @@ public class EventHandlerParameters implements ParameterGroup {
} catch (final PatternSyntaxException pse) {
String message = "event handler eventNameFilter is not a valid regular expression: " + pse.getMessage();
LOGGER.trace(message, pse);
- result.setResult("eventNameFilter", ValidationStatus.INVALID, message);
+ result.addResult("eventNameFilter", eventNameFilter, ValidationStatus.INVALID, message);
}
}
@@ -338,7 +328,7 @@ public class EventHandlerParameters implements ParameterGroup {
/**
* Check if we're using synchronous mode.
- *
+ *
* @return true if if we're using synchronous mode
*/
public boolean isSynchronousMode() {
@@ -347,7 +337,7 @@ public class EventHandlerParameters implements ParameterGroup {
/**
* The synchronous peer for this event handler.
- *
+ *
* @return the synchronous peer for this event handler
*/
public String getSynchronousPeer() {
@@ -356,7 +346,7 @@ public class EventHandlerParameters implements ParameterGroup {
/**
* Get the timeout for synchronous operations.
- *
+ *
* @return the timeout for synchronous operations
*/
public long getSynchronousTimeout() {
@@ -365,7 +355,7 @@ public class EventHandlerParameters implements ParameterGroup {
/**
* Check if this event handler will use requestor mode.
- *
+ *
* @return true if this event handler will use requestor mode
*/
public boolean isRequestorMode() {
@@ -374,7 +364,7 @@ public class EventHandlerParameters implements ParameterGroup {
/**
* The requestor peer for this event handler.
- *
+ *
* @return the requestor peer for this event handler
*/
public String getRequestorPeer() {
@@ -383,7 +373,7 @@ public class EventHandlerParameters implements ParameterGroup {
/**
* Get the requestor timeout.
- *
+ *
* @return the requestorTimeout.
*/
public long getRequestorTimeout() {
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java
index 68d5f8a56..1fd8e7489 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java
@@ -21,10 +21,11 @@
package org.onap.policy.apex.service.parameters.eventprotocol;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.ParameterRuntimeException;
-import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.parameters.annotations.ClassName;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
/**
* A default event protocol parameter class that may be specialized by event protocol plugins that require plugin
@@ -39,12 +40,14 @@ import org.onap.policy.common.parameters.ValidationStatus;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public abstract class EventProtocolParameters implements ParameterGroup {
+@NotNull
+@NotBlank
+public abstract class EventProtocolParameters extends ParameterGroupImpl {
// The event protocol label
private String label = null;
// Event protocol converter plugin class for this event protocol
- private String eventProtocolPluginClass;
+ private @ClassName String eventProtocolPluginClass;
/**
* Constructor to create an event protocol parameters instance with the name of a sub class of this class and
@@ -99,25 +102,6 @@ public abstract class EventProtocolParameters implements ParameterGroup {
+ "]";
}
- /**
- * {@inheritDoc}.
- */
- @Override
- public GroupValidationResult validate() {
- final GroupValidationResult result = new GroupValidationResult(this);
-
- if (label == null || label.length() == 0) {
- result.setResult("label", ValidationStatus.INVALID, "event protocol label not specified or is blank");
- }
-
- if (eventProtocolPluginClass == null || eventProtocolPluginClass.length() == 0) {
- result.setResult("eventProtocolPluginClass", ValidationStatus.INVALID,
- "event protocol eventProtocolPluginClass not specified or is blank");
- }
-
- return result;
- }
-
@Override
public String getName() {
return this.getLabel();
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java
index d15d7ed47..3875d4a14 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java
@@ -21,7 +21,7 @@
package org.onap.policy.apex.service.parameters.eventprotocol;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
/**
@@ -97,16 +97,16 @@ public abstract class EventProtocolTextCharDelimitedParameters extends EventProt
* {@inheritDoc}.
*/
@Override
- public GroupValidationResult validate() {
- final GroupValidationResult result = super.validate();
+ public BeanValidationResult validate() {
+ final BeanValidationResult result = super.validate();
if (startChar == '\0') {
- result.setResult("startChar", ValidationStatus.INVALID,
+ result.addResult("startChar", null, ValidationStatus.INVALID,
"text character delimited start character has not been specified");
}
if (endChar == '\0') {
- result.setResult("endChar", ValidationStatus.INVALID,
+ result.addResult("endChar", null, ValidationStatus.INVALID,
"text character delimited end character has not been specified\n");
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java
index ff363aff6..32883301e 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java
@@ -21,8 +21,8 @@
package org.onap.policy.apex.service.parameters.eventprotocol;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
/**
* An event protocol parameter class for token delimited textual event protocols that may be specialized by event
@@ -42,7 +42,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
*/
public abstract class EventProtocolTextTokenDelimitedParameters extends EventProtocolParameters {
// The delimiter token for text blocks
- private String startDelimiterToken = null;
+ private @NotNull @NotBlank String startDelimiterToken = null;
private String endDelimiterToken = null;
private boolean delimiterAtStart = true;
@@ -115,19 +115,4 @@ public abstract class EventProtocolTextTokenDelimitedParameters extends EventPro
return "EventProtocolTextTokenDelimitedParameters [startDelimiterToken=" + startDelimiterToken
+ ", endDelimiterToken=" + endDelimiterToken + ", delimiterAtStart=" + delimiterAtStart + "]";
}
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public GroupValidationResult validate() {
- final GroupValidationResult result = super.validate();
-
- if (startDelimiterToken == null || startDelimiterToken.length() == 0) {
- result.setResult("startDelimiterToken", ValidationStatus.INVALID,
- "text start delimiter token not specified or is blank\n");
- }
-
- return result;
- }
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParametersTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParametersTest.java
index c0da81625..878756383 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParametersTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParametersTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 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.
@@ -23,7 +24,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
public class EventRequestorCarrierTechnologyParametersTest {
@@ -37,7 +38,7 @@ public class EventRequestorCarrierTechnologyParametersTest {
@Test
public void validate() {
final EventRequestorCarrierTechnologyParameters parameters = new EventRequestorCarrierTechnologyParameters();
- final GroupValidationResult actual = parameters.validate();
+ final ValidationResult actual = parameters.validate();
assertNotNull(actual);
}
-} \ No newline at end of file
+}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java
index b7532aba2..29a3e0f00 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java
@@ -3,6 +3,7 @@
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
+ * 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.
@@ -109,7 +110,7 @@ public class ApexMainTest {
apexMain1 = new ApexMain(args);
await().atMost(200, TimeUnit.MILLISECONDS).until(() -> outContent.toString()
- .contains("parameter group has status INVALID"));
+ .contains("item has status INVALID"));
assertNotNull(apexMain1);
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java
index 9557ca8f9..a0169d7e3 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java
@@ -3,6 +3,7 @@
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * 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.
@@ -70,10 +71,11 @@ public class ApexParametersTest {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessageContaining("java properties array entries must have one key and one value")
- .hasMessageContaining("java properties key is null or blank")
- .hasMessageContaining("java properties value is null or blank")
- .hasMessageContaining("java properties array entry is null");
+ .hasMessageContaining("\"javaProperties\"")
+ .hasMessageContaining("entry 0", "entry 1", "entry 2", "entry 3", "entry 4", "entry 5")
+ .hasMessageContaining("must have one key and one value")
+ .hasMessageContaining("\"key\" value \"null\" INVALID, is blank")
+ .hasMessageContaining("\"value\" value \"null\" INVALID, is blank");
}
@Test
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java
index da4ceaa12..e37da3540 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * 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.
@@ -72,15 +73,11 @@ public class ParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from \"src/test/resources/parameters/noParams.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n" + " parameter group \"UNDEFINED\" INVALID, "
- + "engine service parameters are not specified\n"
- + " parameter group map \"eventOutputParameters\" INVALID, "
- + "at least one event output must be specified\n"
- + " parameter group map \"eventInputParameters\" INVALID, "
- + "at least one event input must be specified\n");
+ .hasMessageContaining("src/test/resources/parameters/noParams.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("\"engineServiceParameters\" value \"null\" INVALID, is null")
+ .hasMessageContaining("\"eventOutputParameters\" value \"{}\" INVALID, minimum number of elements: 1")
+ .hasMessageContaining("\"eventInputParameters\" value \"{}\" INVALID, minimum number of elements: 1");
}
@Test
@@ -89,19 +86,13 @@ public class ParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from \"src/test/resources/parameters/blankParams.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n" + " parameter group \"ENGINE_SERVICE_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters\" "
- + "INVALID, parameter group has status INVALID\n"
- + " field \"id\" type \"int\" value \"-1\" INVALID, "
- + "id not specified or specified value [-1] invalid, must be specified as id >= 0\n"
- + " field \"policyModel\" type \"java.lang.String\" value \"null\" INVALID, must be specified\n"
- + " parameter group map \"eventOutputParameters\" INVALID, "
- + "at least one event output must be specified\n"
- + " parameter group map \"eventInputParameters\" INVALID, "
- + "at least one event input must be specified\n");
+ .hasMessageContaining("src/test/resources/parameters/blankParams.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("EngineServiceParameters")
+ .hasMessageContaining("\"id\" value \"-1\" INVALID, is below the minimum")
+ .hasMessageContaining("\"policyModel\" value \"null\" INVALID, is null")
+ .hasMessageContaining("\"eventOutputParameters\" value \"{}\" INVALID, minimum number of elements")
+ .hasMessageContaining("\"eventInputParameters\" value \"{}\" INVALID, minimum number of elements");
}
@Test
@@ -110,38 +101,19 @@ public class ParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from \"src/test/resources/parameters/badParams.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n" + " parameter group \"hello there\" type "
- + "\"org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters\" "
- + "INVALID, parameter group has status INVALID\n"
- + " field \"name\" type \"java.lang.String\" value \"hello there\" INVALID, "
- + "name is invalid, it must match regular expression[A-Za-z0-9\\-_\\.]+\n"
- + " field \"id\" type \"int\" value \"-45\" INVALID, id not specified or "
- + "specified value [-45] invalid, must be specified as id >= 0\n"
- + " field \"instanceCount\" type \"int\" value \"-345\" INVALID, "
- + "instanceCount [-345] invalid, must be specified as instanceCount >= 1\n"
- + " field \"deploymentPort\" type \"int\" value \"65536\" INVALID, "
- + "deploymentPort [65536] invalid, must be specified as 1024 <= port <= 65535\n"
- + " parameter group map \"eventOutputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"FirstProducer\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", parameter group has status INVALID\n" + " parameter group \"FILE\" type "
- + "\"org.onap.policy.apex.service.engine.event.impl."
- + "filecarrierplugin.FileCarrierTechnologyParameters\" INVALID, "
- + "parameter group has status INVALID\n"
- + " field \"fileName\" type \"java.lang.String\" value \"null\" INVALID, "
- + "\"null\" invalid, must be specified as a non-empty string\n"
- + " parameter group map \"eventInputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"TheFileConsumer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", parameter group has status INVALID\n" + " parameter group \"FILE\" type "
- + "\"org.onap.policy.apex.service.engine.event.impl."
- + "filecarrierplugin.FileCarrierTechnologyParameters\" INVALID, "
- + "parameter group has status INVALID\n"
- + " field \"fileName\" type \"java.lang.String\" value \"null\" INVALID, "
- + "\"null\" invalid, must be specified as a non-empty string\n");
+ .hasMessageContaining("src/test/resources/parameters/badParams.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("EngineServiceParameters")
+ .hasMessageContaining("\"name\" value \"hello there\" INVALID, does not match")
+ .hasMessageContaining("\"id\" value \"-45\" INVALID, is below the minimum")
+ .hasMessageContaining("\"instanceCount\" value \"-345\" INVALID, is below the minimum")
+ .hasMessageContaining("\"deploymentPort\" value \"65536\" INVALID, exceeds the maximum")
+ .hasMessageContaining("eventOutputParameters", "FirstProducer", "EventHandlerParameters",
+ "FileCarrierTechnologyParameters")
+ .hasMessageContaining("\"fileName\" value \"null\" INVALID, is blank")
+ .hasMessageContaining("eventInputParameters", "TheFileConsumer1", "EventHandlerParameters",
+ "FileCarrierTechnologyParameters")
+ .hasMessageContaining("\"fileName\" value \"null\" INVALID, is blank");
}
@Test
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java
index 0ef4fa252..0b05eac63 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * 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.
@@ -75,14 +76,11 @@ public class ProducerConsumerTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from \"src/test/resources/parameters/prodConsNoCT.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n" + " parameter group map \"eventInputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"aConsumer\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
- + " parameter group has status INVALID\n" + " parameter group \"UNDEFINED\" INVALID, "
- + "event handler carrierTechnologyParameters not specified or blank\n");
+ .hasMessageContaining("src/test/resources/parameters/prodConsNoCT.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("eventInputParameters", "aConsumer", "EventHandlerParameters",
+ "carrierTechnologyParameters")
+ .hasMessageContaining("is null");
}
@Test
@@ -91,23 +89,14 @@ public class ProducerConsumerTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from \"src/test/resources/parameters/prodConsNoEP.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n" + " parameter group map \"eventOutputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"aProducer\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", parameter group has status INVALID\n" + " parameter group \"UNDEFINED\" INVALID, "
- + "event handler eventProtocolParameters not specified or blank\n"
- + " parameter group map \"eventInputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"aConsumer\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", parameter group has status INVALID\n" + " parameter group \"FILE\" type "
- + "\"org.onap.policy.apex.service.engine.event.impl."
- + "filecarrierplugin.FileCarrierTechnologyParameters\" INVALID, "
- + "parameter group has status INVALID\n"
- + " field \"fileName\" type \"java.lang.String\" value \"null\" INVALID, "
- + "\"null\" invalid, must be specified as a non-empty string\n");
+ .hasMessageContaining("src/test/resources/parameters/prodConsNoEP.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("eventOutputParameters", "aProducer", "EventHandlerParameters",
+ "eventProtocolParameters")
+ .hasMessageContaining("eventInputParameters", "aConsumer", "EventHandlerParameters",
+ "FileCarrierTechnologyParameters", "fileName")
+ .hasMessageContaining("is null")
+ .hasMessageContaining("is blank");
}
@Test
@@ -170,19 +159,12 @@ public class ProducerConsumerTests {
final String[] args = {"-p", "src/test/resources/parameters/prodConsBadFileName.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
- assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage(
- "validation error(s) on parameters from " + "\"src/test/resources/parameters/prodConsBadFileName.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n" + " parameter group map \"eventOutputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"aProducer\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
- + "INVALID, parameter group has status INVALID\n" + " parameter group \"FILE\" type "
- + "\"org.onap.policy.apex.service.engine.event.impl."
- + "filecarrierplugin.FileCarrierTechnologyParameters\" INVALID, "
- + "parameter group has status INVALID\n" + " field \"fileName\" type "
- + "\"java.lang.String\" value \"null\" INVALID, "
- + "\"null\" invalid, must be specified as a non-empty string\n");
+ assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
+ .hasMessageContaining("src/test/resources/parameters/prodConsBadFileName.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("eventOutputParameters", "aProducer", "EventHandlerParameters",
+ "FileCarrierTechnologyParameters", "fileName")
+ .hasMessageContaining("is blank");
}
@Test
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java
index 71ff28877..aaa98fd47 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java
@@ -51,16 +51,10 @@ public class SyncParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n"
- + " parameter group map \"eventOutputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncProducer0\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", specified peered mode \"SYNCHRONOUS\" "
- + "peer is illegal on eventOutputParameters \"SyncProducer0\" \n");
+ .hasMessageContaining("src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer0\" INVALID")
+ .hasMessageContaining("peer is illegal");
}
@Test
@@ -69,16 +63,10 @@ public class SyncParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n"
- + " parameter group map \"eventOutputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncProducer0\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", specified peered mode \"SYNCHRONOUS\" peer is illegal "
- + "on eventOutputParameters \"SyncProducer0\" \n");
+ .hasMessageContaining("src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer0\" INVALID")
+ .hasMessageContaining("peer is illegal");
}
@Test
@@ -87,27 +75,13 @@ public class SyncParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsBadPeers.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n"
- + " parameter group map \"eventOutputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncProducer0\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS does not exist "
- + "or is not defined with the same peered mode\n" + " parameter group \"SyncProducer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncProducer0 for peered mode SYNCHRONOUS does not exist "
- + "or is not defined with the same peered mode\n"
- + " parameter group map \"eventInputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncConsumer0\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncConsumer1 for peered mode SYNCHRONOUS does not exist "
- + "or is not defined with the same peered mode\n" + " parameter group \"SyncConsumer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS does not exist "
- + "or is not defined with the same peered mode\n");
+ .hasMessageContaining("src/test/resources/parameters/syncBadParamsBadPeers.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer0\" INVALID")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer1\" INVALID")
+ .hasMessageContaining("\"eventInputParameters\" value \"SyncConsumer0\" INVALID")
+ .hasMessageContaining("\"eventInputParameters\" value \"SyncConsumer1\" INVALID")
+ .hasMessageContaining("does not exist or is not defined");
}
@Test
@@ -116,29 +90,16 @@ public class SyncParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsInvalidTimeout.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n"
- + " parameter group map \"eventOutputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncProducer0\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
- + " specified peered mode \"SYNCHRONOUS\" timeout value \"-10\" is illegal, "
- + "specify a non-negative timeout value in milliseconds\n"
- + " parameter group \"SyncProducer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
- + "INVALID, specified peered mode \"SYNCHRONOUS\" timeout value \"-3\" is illegal, "
- + "specify a non-negative timeout value in milliseconds\n"
- + " parameter group map \"eventInputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncConsumer0\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
- + "INVALID, specified peered mode \"SYNCHRONOUS\" timeout value \"-1\" is illegal, "
- + "specify a non-negative timeout value in milliseconds\n"
- + " parameter group \"SyncConsumer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
- + " specified peered mode \"SYNCHRONOUS\" timeout value \"-99999999\" is illegal, "
- + "specify a non-negative timeout value in milliseconds\n");
+ .hasMessageContaining("src/test/resources/parameters/syncBadParamsInvalidTimeout.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer0\" INVALID")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer1\" INVALID")
+ .hasMessageContaining("\"eventInputParameters\" value \"SyncConsumer0\" INVALID")
+ .hasMessageContaining("\"eventInputParameters\" value \"SyncConsumer1\" INVALID")
+ .hasMessageContaining("timeout value \"-10\" is illegal")
+ .hasMessageContaining("timeout value \"-3\" is illegal")
+ .hasMessageContaining("timeout value \"-1\" is illegal")
+ .hasMessageContaining("timeout value \"-99999999\" is illegal");
}
@Test
@@ -147,16 +108,10 @@ public class SyncParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsBadTimeout.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" "
- + "INVALID, parameter group has status INVALID\n"
- + " parameter group map \"eventOutputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"MyOtherProducer\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
- + "INVALID, specified peered mode \"SYNCHRONOUS\" "
- + "timeout is illegal on eventOutputParameters \"MyOtherProducer\"\n");
+ .hasMessageContaining("src/test/resources/parameters/syncBadParamsBadTimeout.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("\"eventOutputParameters\" value \"MyOtherProducer\" INVALID, "
+ + "specified peered mode \"SYNCHRONOUS\" timeout is illegal");
}
@Test
@@ -165,29 +120,16 @@ public class SyncParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsUnpairedTimeout.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n"
- + " parameter group map \"eventOutputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncProducer0\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS timeout 10 on event handler "
- + "\"SyncProducer0\" does not equal timeout 1 on event handler \"SyncConsumer0\"\n"
- + " parameter group \"SyncProducer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncConsumer1 for peered mode SYNCHRONOUS timeout 3 on event handler "
- + "\"SyncProducer1\" does not equal timeout 99999999 on event handler \"SyncConsumer1\"\n"
- + " parameter group map \"eventInputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncConsumer0\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncProducer0 for peered mode SYNCHRONOUS timeout 1 on event handler "
- + "\"SyncConsumer0\" does not equal timeout 10 on event handler \"SyncProducer0\"\n"
- + " parameter group \"SyncConsumer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS timeout 99999999 on event handler "
- + "\"SyncConsumer1\" does not equal timeout 3 on event handler \"SyncProducer1\"\n" + "");
+ .hasMessageContaining("src/test/resources/parameters/syncBadParamsUnpairedTimeout.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer0\" INVALID, peer \"SyncConsumer0\"")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer1\" INVALID, peer \"SyncConsumer1\"")
+ .hasMessageContaining("\"eventInputParameters\" value \"SyncConsumer0\" INVALID, peer \"SyncProducer0\"")
+ .hasMessageContaining("\"eventInputParameters\" value \"SyncConsumer1\" INVALID, peer \"SyncProducer1\"")
+ .hasMessageContaining("timeout 10 does not equal peer timeout 1")
+ .hasMessageContaining("timeout 3 does not equal peer timeout 99999999")
+ .hasMessageContaining("timeout 1 does not equal peer timeout 10")
+ .hasMessageContaining("timeout 99999999 does not equal peer timeout 3");
}
@Test
@@ -226,23 +168,12 @@ public class SyncParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncUnusedConsumerPeers.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n"
- + " parameter group map \"eventOutputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncProducer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
- + "INVALID, peer \"SyncConsumer0 for peered mode SYNCHRONOUS, "
- + "value \"SyncProducer0\" on peer \"SyncConsumer0\" "
- + "does not equal event handler \"SyncProducer1\"\n"
- + " parameter group map \"eventInputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncConsumer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
- + "INVALID, peer \"SyncProducer1 for peered mode SYNCHRONOUS, "
- + "value \"SyncConsumer0\" on peer \"SyncProducer1\" "
- + "does not equal event handler \"SyncConsumer1\"\n");
+ .hasMessageContaining("src/test/resources/parameters/syncUnusedConsumerPeers.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer1\" INVALID, peer \"SyncConsumer0\"")
+ .hasMessageContaining("\"eventInputParameters\" value \"SyncConsumer1\" INVALID, peer \"SyncProducer1\"")
+ .hasMessageContaining("value \"SyncProducer0\" on peer does not equal event handler")
+ .hasMessageContaining("value \"SyncConsumer0\" on peer does not equal event handler");
}
@Test
@@ -251,29 +182,16 @@ public class SyncParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncMismatchedPeers.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n"
- + " parameter group map \"eventOutputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncProducer0\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncConsumer1 for peered mode SYNCHRONOUS, value \"SyncProducer1\" "
- + "on peer \"SyncConsumer1\" does not equal event handler \"SyncProducer0\"\n"
- + " parameter group \"SyncProducer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS, value \"SyncProducer0\" "
- + "on peer \"SyncConsumer0\" does not equal event handler \"SyncProducer1\"\n"
- + " parameter group map \"eventInputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncConsumer0\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncProducer0 for peered mode SYNCHRONOUS, value \"SyncConsumer1\" "
- + "on peer \"SyncProducer0\" does not equal event handler \"SyncConsumer0\"\n"
- + " parameter group \"SyncConsumer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS, value \"SyncConsumer0\" "
- + "on peer \"SyncProducer1\" does not equal event handler \"SyncConsumer1\"\n");
+ .hasMessageContaining("src/test/resources/parameters/syncMismatchedPeers.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer0\" INVALID, peer \"SyncConsumer1\"")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer1\" INVALID, peer \"SyncConsumer0\"")
+ .hasMessageContaining("\"eventInputParameters\" value \"SyncConsumer0\" INVALID, peer \"SyncProducer0\"")
+ .hasMessageContaining("\"eventInputParameters\" value \"SyncConsumer1\" INVALID, peer \"SyncProducer1\"")
+ .hasMessageContaining("value \"SyncProducer1\" on peer does not equal event handler")
+ .hasMessageContaining("value \"SyncProducer0\" on peer does not equal event handler")
+ .hasMessageContaining("value \"SyncConsumer1\" on peer does not equal event handler")
+ .hasMessageContaining("value \"SyncConsumer0\" on peer does not equal event handler");
}
@Test
@@ -282,21 +200,12 @@ public class SyncParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncUnusedProducerPeers.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n"
- + " parameter group map \"eventOutputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncProducer0\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS, value \"SyncProducer1\" on peer "
- + "\"SyncConsumer0\" does not equal event handler \"SyncProducer0\"\n"
- + " parameter group map \"eventInputParameters\" INVALID, parameter group map has status "
- + "INVALID\n parameter group \"SyncConsumer0\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
- + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS, value \"SyncConsumer1\" on peer "
- + "\"SyncProducer1\" does not equal event handler \"SyncConsumer0\"\n");
+ .hasMessageContaining("src/test/resources/parameters/syncUnusedProducerPeers.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer0\" INVALID, peer \"SyncConsumer0\"")
+ .hasMessageContaining("\"eventInputParameters\" value \"SyncConsumer0\" INVALID, peer \"SyncProducer1\"")
+ .hasMessageContaining("value \"SyncProducer1\" on peer does not equal event handler")
+ .hasMessageContaining("value \"SyncConsumer1\" on peer does not equal event handler");
}
@Test
@@ -305,23 +214,12 @@ public class SyncParameterTests {
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments))
- .hasMessage("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncMismatchedTimeout.json\"\n"
- + "parameter group \"APEX_PARAMETERS\" type "
- + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
- + "parameter group has status INVALID\n" + " parameter group map \"eventOutputParameters\" "
- + "INVALID, parameter group map has status INVALID\n"
- + " parameter group \"SyncProducer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
- + " peer \"SyncConsumer1 for peered mode SYNCHRONOUS timeout 456 "
- + "on event handler \"SyncProducer1\" does not equal timeout 123 "
- + "on event handler \"SyncConsumer1\"\n"
- + " parameter group map \"eventInputParameters\" INVALID, "
- + "parameter group map has status INVALID\n" + " parameter group \"SyncConsumer1\" type "
- + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
- + " peer \"SyncProducer1 for peered mode SYNCHRONOUS timeout 123 "
- + "on event handler \"SyncConsumer1\" does not equal timeout 456 "
- + "on event handler \"SyncProducer1\"\n");
+ .hasMessageContaining("src/test/resources/parameters/syncMismatchedTimeout.json")
+ .hasMessageContaining("ApexParameters")
+ .hasMessageContaining("\"eventOutputParameters\" value \"SyncProducer1\" INVALID, peer \"SyncConsumer1\"")
+ .hasMessageContaining("\"eventInputParameters\" value \"SyncConsumer1\" INVALID, peer \"SyncProducer1\"")
+ .hasMessageContaining("timeout 123 does not equal peer timeout 456")
+ .hasMessageContaining("timeout 456 does not equal peer timeout 123");
}
@Test
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java
index 6805a3d84..d7a502c7f 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * 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,15 +24,22 @@ package org.onap.policy.apex.service.engine.parameters.dummyclasses;
import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
+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.common.parameters.annotations.Min;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.models.base.Validated;
/**
* Apex parameters for SuperDooper as an event carrier technology.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@NotNull
+@NotBlank
public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyParameters {
// Default parameter values
private static final String DEFAULT_ACKS = "all";
@@ -71,16 +79,16 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar
// superDooper carrier parameters
private String bootstrapServers = DEFAULT_BOOTSTRAP_SERVERS;
private String acks = DEFAULT_ACKS;
- private int retries = DEFAULT_RETRIES;
- private int batchSize = DEFAULT_BATCH_SIZE;
- private int lingerTime = DEFAULT_LINGER_TIME;
- private long bufferMemory = DEFAULT_BUFFER_MEMORY;
+ private @Min(0) int retries = DEFAULT_RETRIES;
+ private @Min(0) int batchSize = DEFAULT_BATCH_SIZE;
+ private @Min(0) int lingerTime = DEFAULT_LINGER_TIME;
+ private @Min(0) long bufferMemory = DEFAULT_BUFFER_MEMORY;
private String groupId = DEFAULT_GROUP_ID;
private boolean enableAutoCommit = DEFAULT_ENABLE_AUTO_COMMIT;
- private int autoCommitTime = DEFAULT_AUTO_COMMIT_TIME;
+ private @Min(0) int autoCommitTime = DEFAULT_AUTO_COMMIT_TIME;
private int sessionTimeout = DEFAULT_SESSION_TIMEOUT;
private String producerTopic = DEFAULT_PRODUCER_TOPIC;
- private int consumerPollTime = DEFAULT_CONSUMER_POLL_TIME;
+ private @Min(0) int consumerPollTime = DEFAULT_CONSUMER_POLL_TIME;
private String[] consumerTopicList = DEFAULT_CONSUMER_TOPIC_LIST;
private String keySerializer = DEFAULT_KEYSERZER;
private String valueSerializer = DEFAULT_VALSERZER;
@@ -459,98 +467,30 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar
* {@inheritDoc}.
*/
@Override
- public GroupValidationResult validate() {
- final GroupValidationResult result = super.validate();
+ public BeanValidationResult validate() {
+ final BeanValidationResult result = super.validate();
- if (bootstrapServers == null || bootstrapServers.trim().length() == 0) {
- result.setResult("bootstrapServers", ValidationStatus.INVALID,
- "bootstrapServers not specified, must be specified as a string of form host:port");
+ if (consumerTopicList == null) {
+ return result;
}
- if (acks == null || acks.trim().length() == 0) {
- result.setResult("acks", ValidationStatus.INVALID,
- "acks not specified, must be specified as a string with values [0|1|all]");
- }
-
- if (retries < 0) {
- result.setResult("retries", ValidationStatus.INVALID,
- "[" + retries + "] invalid, must be specified as retries >= 0");
- }
-
- if (batchSize < 0) {
- result.setResult("batchSize", ValidationStatus.INVALID,
- "[" + batchSize + "] invalid, must be specified as batchSize >= 0");
- }
-
- if (lingerTime < 0) {
- result.setResult("lingerTime", ValidationStatus.INVALID,
- "[" + lingerTime + "] invalid, must be specified as lingerTime >= 0");
- }
-
- if (bufferMemory < 0) {
- result.setResult("bufferMemory", ValidationStatus.INVALID,
- "[" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0");
- }
-
- if (groupId == null || groupId.trim().length() == 0) {
- result.setResult("groupId", ValidationStatus.INVALID, "not specified, must be specified as a string");
- }
-
- if (autoCommitTime < 0) {
- result.setResult("autoCommitTime", ValidationStatus.INVALID,
- "[" + autoCommitTime + "] invalid, must be specified as autoCommitTime >= 0");
- }
-
- if (sessionTimeout < 0) {
- result.setResult("sessionTimeout", ValidationStatus.INVALID,
- "sessionTimeout [" + sessionTimeout + "] invalid, must be specified as sessionTimeout >= 0");
- }
-
- if (producerTopic == null || producerTopic.trim().length() == 0) {
- result.setResult("producerTopic", ValidationStatus.INVALID,
- "producerTopic not specified, must be specified as a string");
- }
-
- if (consumerPollTime < 0) {
- result.setResult("consumerPollTime", ValidationStatus.INVALID,
- "[" + consumerPollTime + "] invalid, must be specified as consumerPollTime >= 0");
- }
-
- if (consumerTopicList == null || consumerTopicList.length == 0) {
- result.setResult("consumerTopicList", ValidationStatus.INVALID,
+ if (consumerTopicList.length == 0) {
+ result.addResult("consumerTopicList", consumerTopicList, ValidationStatus.INVALID,
"not specified, must be specified as a list of strings");
+ return result;
}
- StringBuilder consumerTopicMessageBuilder = new StringBuilder();
+ BeanValidationResult result2 = new BeanValidationResult("consumerTopicList", consumerTopicList);
+ int item = 0;
for (final String consumerTopic : consumerTopicList) {
- if (consumerTopic == null || consumerTopic.trim().length() == 0) {
- consumerTopicMessageBuilder.append(" invalid consumer topic \"" + consumerTopic
- + "\" specified on consumerTopicList, consumer topics must be specified as strings");
+ if (StringUtils.isBlank(consumerTopic)) {
+ result2.addResult("entry " + item, consumerTopic, ValidationStatus.INVALID, Validated.IS_BLANK);
}
- }
- if (consumerTopicMessageBuilder.length() > 0) {
- result.setResult("consumerTopicList", ValidationStatus.INVALID, consumerTopicMessageBuilder.toString());
+ ++item;
}
- if (keySerializer == null || keySerializer.trim().length() == 0) {
- result.setResult("keySerializer", ValidationStatus.INVALID, "not specified, must be specified as a string");
- }
-
- if (valueSerializer == null || valueSerializer.trim().length() == 0) {
- result.setResult("valueSerializer", ValidationStatus.INVALID,
- "not specified, must be specified as a string");
- }
-
- if (keyDeserializer == null || keyDeserializer.trim().length() == 0) {
- result.setResult("keyDeserializer", ValidationStatus.INVALID,
- "not specified, must be specified as a string");
- }
-
- if (valueDeserializer == null || valueDeserializer.trim().length() == 0) {
- result.setResult("valueDeserializer", ValidationStatus.INVALID,
- "not specified, must be specified as a string");
- }
+ result.addResult(result2);
return result;
}
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");
}
}