summaryrefslogtreecommitdiffstats
path: root/testsuites/integration/integration-common/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/integration/integration-common/src/main/java/org/onap')
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java39
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/testclasses/PingTestClass.java97
2 files changed, 27 insertions, 109 deletions
diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java
index c1c656490..3730bba47 100644
--- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java
@@ -21,8 +21,7 @@
package org.onap.policy.apex.testsuites.integration.common.model.java;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
+import java.util.Random;
import org.onap.policy.apex.core.engine.executor.context.TaskExecutionContext;
@@ -36,7 +35,7 @@ public class DefaultTaskLogic {
* Gets the event.
*
* @param executor the executor
- * @return true , if the event exists
+ * @return the event
*/
public boolean getEvent(final TaskExecutionContext executor) {
String idString = executor.subject.getId();
@@ -47,26 +46,20 @@ public class DefaultTaskLogic {
String inFieldsString = executor.inFields.toString();
executor.logger.debug(inFieldsString);
-
- try {
- SecureRandom rand = SecureRandom.getInstanceStrong();
- if (executor.inFields.containsKey("TestDecideCaseSelected")) {
- executor.outFields.put("TestActCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
- executor.outFields.put("TestActStateTime", System.nanoTime());
- } else if (executor.inFields.containsKey("TestEstablishCaseSelected")) {
- executor.outFields.put("TestDecideCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
- executor.outFields.put("TestDecideStateTime", System.nanoTime());
- } else if (executor.inFields.containsKey("TestMatchCaseSelected")) {
- executor.outFields.put("TestEstablishCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
- executor.outFields.put("TestEstablishStateTime", System.nanoTime());
- } else {
- executor.outFields.put("TestMatchCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
- executor.outFields.put("TestMatchStateTime", System.nanoTime());
- }
- } catch (NoSuchAlgorithmException e) {
- executor.logger.error("Exception during Random number generation ", e);
- return false;
+ final Random rand = new Random();
+ if (executor.inFields.containsKey("TestDecideCaseSelected")) {
+ executor.outFields.put("TestActCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
+ executor.outFields.put("TestActStateTime", System.nanoTime());
+ } else if (executor.inFields.containsKey("TestEstablishCaseSelected")) {
+ executor.outFields.put("TestDecideCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
+ executor.outFields.put("TestDecideStateTime", System.nanoTime());
+ } else if (executor.inFields.containsKey("TestMatchCaseSelected")) {
+ executor.outFields.put("TestEstablishCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
+ executor.outFields.put("TestEstablishStateTime", System.nanoTime());
+ } else {
+ executor.outFields.put("TestMatchCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
+ executor.outFields.put("TestMatchStateTime", System.nanoTime());
}
- return true;
+ return true;
}
}
diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/testclasses/PingTestClass.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/testclasses/PingTestClass.java
index b64f76b93..1ed5d20f5 100644
--- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/testclasses/PingTestClass.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/testclasses/PingTestClass.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
@@ -22,6 +23,8 @@ package org.onap.policy.apex.testsuites.integration.common.testclasses;
import java.io.Serializable;
+import lombok.Data;
+
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
/**
@@ -29,96 +32,17 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@Data
public class PingTestClass implements Serializable {
private static final long serialVersionUID = -3400711508992955886L;
+ private int id = 0;
private String name = "Rose";
private String description = "A rose by any other name would smell as sweet";
private long pingTime = System.currentTimeMillis();
private long pongTime = -1;
/**
- * Gets the name.
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the name.
- *
- * @param name the new name
- */
- public void setName(final String name) {
- this.name = name;
- }
-
- /**
- * Gets the description.
- *
- * @return the description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Sets the description.
- *
- * @param description the new description
- */
- public void setDescription(final String description) {
- this.description = description;
- }
-
- /**
- * Gets the ping time.
- *
- * @return the ping time
- */
- public long getPingTime() {
- return pingTime;
- }
-
- /**
- * Sets the ping time.
- *
- * @param pingTime the new ping time
- */
- public void setPingTime(final long pingTime) {
- this.pingTime = pingTime;
- }
-
- /**
- * Gets the pong time.
- *
- * @return the pong time
- */
- public long getPongTime() {
- return pongTime;
- }
-
- /**
- * Sets the pong time.
- *
- * @param pongTime the new pong time
- */
- public void setPongTime(final long pongTime) {
- this.pongTime = pongTime;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- return "TestPing [name=" + name + ", description=" + description + ", pingTime=" + pingTime + ", pongTime="
- + pongTime + "]";
- }
-
- /**
* Verify the class.
*
* @throws ApexException the apex event exception
@@ -140,8 +64,9 @@ public class PingTestClass implements Serializable {
throw new ApexException("TestPing is not valid, description is incorrect");
}
- if (pongTime <= pingTime) {
- throw new ApexException("TestPing is not valid, pong time is not greater than ping time");
+ if (pongTime < pingTime) {
+ throw new ApexException(
+ "TestPing is not valid, pong time " + pongTime + " is less than ping time " + pingTime);
}
}
}