summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java6
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java11
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyCarrierTechnologyParameters.java30
-rw-r--r--testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParameters.java126
-rw-r--r--testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java37
5 files changed, 43 insertions, 167 deletions
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java
index b3f27c52e..8596ceec9 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 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.
@@ -158,8 +159,9 @@ public class TestExecutionPropertyRest {
final String outString = outContent.toString();
LOGGER.info("testReplaceUrlTag-OUTSTRING=\n" + outString + "\nEnd-TagUrl");
- assertThat(outString).contains("invalid URL http://localhost:32801/TestExecutionRest/apex/event/tagId}"
- + " has been set for event sending on RESTCLIENT");
+ assertThat(outString).contains("item \"url\" "
+ + "value \"http://localhost:32801/TestExecutionRest/apex/event/tagId}\" INVALID, "
+ + "invalid URL has been set for event sending on RESTCLIENT");
}
/**
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java
index 0596a65e8..7f460bb15 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 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.
@@ -316,8 +317,7 @@ public class TestRestServer {
final String outString = outContent.toString();
- assertThat(outString)
- .contains("the parameters \"host\", \"port\", and \"standalone\" are illegal on REST Server producer");
+ assertThat(outString).contains("\"host\" value \"null\" INVALID, is blank");
LOGGER.debug("testRestServerProducerStandalone end");
}
@@ -341,7 +341,7 @@ public class TestRestServer {
await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
final String outString = outContent.toString();
- assertThat(outString).contains(" host is specified only in standalone mode");
+ assertThat(outString).contains("\"host\"", "should be specified only in standalone mode");
LOGGER.debug("testRestServerProducerHost end");
}
@@ -365,7 +365,7 @@ public class TestRestServer {
await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
final String outString = outContent.toString();
- assertThat(outString).contains(" port is specified only in standalone mode");
+ assertThat(outString).contains("\"port\"", "should be specified only in standalone mode");
LOGGER.debug("testRestServerProducerPort end");
}
@@ -387,8 +387,7 @@ public class TestRestServer {
await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
final String outString = outContent.toString();
- assertThat(outString).contains("the parameters \"host\" and \"port\" must be defined for REST Server consumer "
- + "(FirstConsumer) in standalone mode");
+ assertThat(outString).contains("\"host\" value \"null\" INVALID, is blank");
LOGGER.debug("testRestServerConsumerStandaloneNoHost end");
}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyCarrierTechnologyParameters.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyCarrierTechnologyParameters.java
index fca676b9b..bf645a1ac 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyCarrierTechnologyParameters.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyCarrierTechnologyParameters.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.
@@ -22,10 +23,9 @@ package org.onap.policy.apex.testsuites.integration.uservice.executionproperties
import lombok.Data;
import lombok.EqualsAndHashCode;
-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.ValidationStatus;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
/**
* Dummy carrier technology parameters.
@@ -48,8 +48,8 @@ public class DummyCarrierTechnologyParameters extends CarrierTechnologyParameter
/** The consumer plugin class for the dummy carrier technology. */
public static final String DUMMY_EVENT_CONSUMER_PLUGIN_CLASS = DummyApexEventConsumer.class.getName();
- private String testToRun = null;
- private String propertyFileName = null;
+ private @NotNull @NotBlank String testToRun = null;
+ private @NotNull @NotBlank String propertyFileName = null;
/**
* Constructor to create a dummy carrier technology parameters instance and register the instance with the parameter
@@ -64,24 +64,4 @@ public class DummyCarrierTechnologyParameters extends CarrierTechnologyParameter
this.setEventConsumerPluginClass(DUMMY_EVENT_CONSUMER_PLUGIN_CLASS);
}
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public GroupValidationResult validate() {
- final GroupValidationResult result = super.validate();
-
- if (StringUtils.isEmpty(testToRun)) {
- result.setResult("testToRun", ValidationStatus.INVALID,
- "no test has been specified on the dummy carrier technology plugin");
- }
-
- if (StringUtils.isEmpty(propertyFileName)) {
- result.setResult("propertyFileName", ValidationStatus.INVALID,
- "no propertyFileName has been specified on the dummy carrier technology plugin");
- }
-
- return result;
- }
}
diff --git a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParameters.java b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParameters.java
index 619100176..9846c0463 100644
--- a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParameters.java
+++ b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParameters.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 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.
@@ -20,14 +21,20 @@
package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
-import org.onap.policy.common.parameters.ValidationStatus;
+import lombok.Getter;
+import lombok.Setter;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
+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;
/**
* This class defines the parameters for event generation.
*/
-public class EventGeneratorParameters implements ParameterGroup {
+@Getter
+@Setter
+public class EventGeneratorParameters extends ParameterGroupImpl {
// @formatter:off
private static final String DEFAULT_NAME = EventGeneratorParameters.class.getSimpleName();
private static final String DEFAULT_HOST = "localhost";
@@ -36,11 +43,16 @@ public class EventGeneratorParameters implements ParameterGroup {
private static final int DEFAULT_BATCH_SIZE = 1;
private static final long DEFAULT_DELAY_BETWEEN_BATCHES = 2000;
- private String name = DEFAULT_NAME;
+ @NotNull @NotBlank
private String host = DEFAULT_HOST;
+ @Min(1024)
+ @Max(65535)
private int port = DEFAULT_PORT;
+ @Min(0)
private int batchCount = DEFAULT_BATCH_COUNT;
+ @Min(1)
private int batchSize = DEFAULT_BATCH_SIZE;
+ @Min(0)
private long delayBetweenBatches = DEFAULT_DELAY_BETWEEN_BATCHES;
private String outFile = null;
// @formatter:on
@@ -49,108 +61,6 @@ public class EventGeneratorParameters implements ParameterGroup {
* Create default parameters.
*/
public EventGeneratorParameters() {
- // Default parameters are generated
+ super(DEFAULT_NAME);
}
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public int getBatchCount() {
- return batchCount;
- }
-
- public void setBatchCount(int batchCount) {
- this.batchCount = batchCount;
- }
-
- public int getBatchSize() {
- return batchSize;
- }
-
- public void setBatchSize(int batchSize) {
- this.batchSize = batchSize;
- }
-
- public long getDelayBetweenBatches() {
- return delayBetweenBatches;
- }
-
- public void setDelayBetweenBatches(long delayBetweenBatches) {
- this.delayBetweenBatches = delayBetweenBatches;
- }
-
- public String getOutFile() {
- return outFile;
- }
-
- public void setOutFile(String outFile) {
- this.outFile = outFile;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public GroupValidationResult validate() {
- GroupValidationResult validationResult = new GroupValidationResult(this);
-
- if (isNullOrBlank(name)) {
- validationResult.setResult("name", ValidationStatus.INVALID, "name must be a non-blank string");
- }
-
- if (isNullOrBlank(host)) {
- validationResult.setResult("host", ValidationStatus.INVALID, "host must be a non-blank string");
- }
-
- if (port < 1024 || port > 65535) {
- validationResult.setResult("port", ValidationStatus.INVALID,
- "port must be an integer between 1024 and 65535 inclusive");
- }
-
- if (batchCount < 0) {
- validationResult.setResult("batchCount", ValidationStatus.INVALID,
- "batchCount must be an integer with a value of zero or more, "
- + "zero means generate batches forever");
- }
-
- if (batchSize < 1) {
- validationResult.setResult("batchSize", ValidationStatus.INVALID,
- "batchSize must be an integer greater than zero");
- }
-
- if (delayBetweenBatches < 0) {
- validationResult.setResult("batchSize", ValidationStatus.INVALID,
- "batchSize must be an integer with a value of zero or more");
- }
-
- return validationResult;
- }
-
- private boolean isNullOrBlank(final String stringValue) {
- return stringValue == null || stringValue.trim().length() == 0;
- }
-
}
diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java
index 6b15ae454..fd41d81e6 100644
--- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java
+++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 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.
@@ -82,12 +83,8 @@ public class EventGeneratorParametersHandlerTest {
assertThatThrownBy(() -> {
String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bc", "-1" };
handler.parse(arguments);
- }).hasMessage("specified parameters are not valid: parameter group \"EventGeneratorParameters\" "
- + "type \"org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator."
- + "EventGeneratorParameters\" INVALID, parameter group has status INVALID\n"
- + " field \"batchCount\" type \"int\" value \"-1\" INVALID, "
- + "batchCount must be an integer with a value of zero or more, "
- + "zero means generate batches forever\n");
+ }).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters",
+ "\"batchCount\" value \"-1\" INVALID, is below the minimum");
args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bs", "12345" };
parameters = handler.parse(args);
assertEquals(12345, parameters.getBatchSize());
@@ -95,11 +92,8 @@ public class EventGeneratorParametersHandlerTest {
assertThatThrownBy(() -> {
String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bs", "0" };
handler.parse(arguments);
- }).hasMessage("specified parameters are not valid: parameter group \"EventGeneratorParameters\" "
- + "type \"org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator."
- + "EventGeneratorParameters\" INVALID, parameter group has status INVALID\n"
- + " field \"batchSize\" type \"int\" value \"0\" INVALID, "
- + "batchSize must be an integer greater than zero\n");
+ }).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters",
+ "\"batchSize\" value \"0\" INVALID, is below the minimum");
args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bd", "1000" };
parameters = handler.parse(args);
assertEquals(1000, parameters.getDelayBetweenBatches());
@@ -107,11 +101,8 @@ public class EventGeneratorParametersHandlerTest {
assertThatThrownBy(() -> {
String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bd", "-1" };
handler.parse(arguments);
- }).hasMessage("specified parameters are not valid: parameter group \"EventGeneratorParameters\" "
- + "type \"org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator."
- + "EventGeneratorParameters\" INVALID, parameter group has status INVALID\n"
- + " field \"batchSize\" type \"int\" value \"1\" INVALID, "
- + "batchSize must be an integer with a value of zero or more\n");
+ }).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters",
+ "\"batchSize\" value \"1\" INVALID, is below the minimum");
args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-o", "Zooby" };
parameters = handler.parse(args);
@@ -181,19 +172,13 @@ public class EventGeneratorParametersHandlerTest {
assertThatThrownBy(() -> {
String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/NullHost.json" };
handler.parse(arguments);
- }).hasMessage("specified parameters are not valid: parameter group \"ValidPars\" "
- + "type \"org.onap.policy.apex.testsuites.performance."
- + "benchmark.eventgenerator.EventGeneratorParameters\" INVALID, "
- + "parameter group has status INVALID\n" + " field \"host\" type \"java.lang.String\" "
- + "value \"null\" INVALID, host must be a non-blank string\n");
+ }).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters",
+ "\"host\" value \"null\" INVALID, is null");
assertThatThrownBy(() -> {
String[] arguments = new String[] { "-p", "1023" };
handler.parse(arguments);
- }).hasMessage("specified parameters are not valid: parameter group \""
- + "EventGeneratorParameters\" type \"org.onap.policy.apex.testsuites.performance.benchmark."
- + "eventgenerator.EventGeneratorParameters\" INVALID, parameter group has status INVALID\n"
- + " field \"port\" type \"int\" value \"1023\" INVALID, "
- + "port must be an integer between 1024 and 65535 inclusive\n" + "");
+ }).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters",
+ "\"port\" value \"1023\" INVALID, is below the minimum");
}
}