aboutsummaryrefslogtreecommitdiffstats
path: root/examples/examples-adaptive/src/test
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-06-18 10:39:27 +0100
committeradheli.tavares <adheli.tavares@est.tech>2024-06-18 10:45:14 +0100
commitc7d878cb8b0cf3146646674ad4bd6cabe6716f46 (patch)
tree427e29277cb2e77d5a63ae05bda5c7da163812e3 /examples/examples-adaptive/src/test
parente9b746340711ddfccee7ac0f669ace626b1b3d46 (diff)
Convert junit4 to junit5
- examples module Issue-ID: POLICY-5041 Change-Id: Ia46a6590149571d31dde918e1ea77753ab330f90 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'examples/examples-adaptive/src/test')
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java32
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java19
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionTslUseCaseTest.java63
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java19
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnTslUseCaseTest.java64
5 files changed, 92 insertions, 105 deletions
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java
index 1237537fd..384d6f912 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (c) 2020 Nordix Foundation.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Copyright (c) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,21 +21,22 @@
package org.onap.policy.apex.examples.adaptive;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.LinkedList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.examples.adaptive.concepts.AnomalyDetection;
-public class AnomalyDetectionConceptTest {
+class AnomalyDetectionConceptTest {
@Test
- public void testToString() {
+ void testToString() {
AnomalyDetection anomalyDetection = new AnomalyDetection();
List<Double> newAnomalyScores = new LinkedList<>();
newAnomalyScores.add((double) 55);
@@ -45,13 +45,13 @@ public class AnomalyDetectionConceptTest {
assertEquals(newAnomalyScores, anomalyDetection.getAnomalyScores());
assertTrue(anomalyDetection.checkSetAnomalyScores());
assertEquals(55, anomalyDetection.getFrequency());
- assertEquals(true, anomalyDetection.isFirstRound());
+ assertTrue(anomalyDetection.isFirstRound());
assertEquals("AnomalyDetection(firstRound=true, frequency=55, anomalyScores=[55.0], frequencyForecasted=null)",
anomalyDetection.toString());
}
@Test
- public void testHashCode() {
+ void testHashCode() {
AnomalyDetection detection = new AnomalyDetection();
AnomalyDetection compareDetection = new AnomalyDetection();
assertEquals(detection.hashCode(), compareDetection.hashCode());
@@ -65,7 +65,7 @@ public class AnomalyDetectionConceptTest {
}
@Test
- public void testEquals() {
+ void testEquals() {
AnomalyDetection anomalyDetection = new AnomalyDetection();
AnomalyDetection comparisonDetection = new AnomalyDetection();
assertEquals(anomalyDetection, comparisonDetection);
@@ -74,7 +74,7 @@ public class AnomalyDetectionConceptTest {
//Compare object to null
assertNotNull(anomalyDetection);
//compare object to string
- assertNotEquals(anomalyDetection, "test");
+ assertNotEquals("test", anomalyDetection);
// Anomaly Scores comparison
anomalyDetection.setAnomalyScores(null);
assertNotEquals(anomalyDetection, comparisonDetection);
@@ -105,7 +105,7 @@ public class AnomalyDetectionConceptTest {
}
@Test
- public void testCheckSets() {
+ void testCheckSets() {
AnomalyDetection anomalyDetection = new AnomalyDetection();
assertFalse(anomalyDetection.checkSetAnomalyScores());
List<Double> anomalyScores = new LinkedList<>();
@@ -116,7 +116,7 @@ public class AnomalyDetectionConceptTest {
assertTrue(anomalyDetection.checkSetAnomalyScores());
anomalyDetection.unsetAnomalyScores();
assertFalse(anomalyDetection.checkSetAnomalyScores());
- assertEquals(null, anomalyDetection.getFrequencyForecasted());
+ assertNull(anomalyDetection.getFrequencyForecasted());
assertFalse(anomalyDetection.checkSetFrequencyForecasted());
List<Double> frequencyForecasted = new LinkedList<>();
anomalyDetection.setFrequencyForecasted(frequencyForecasted);
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java
index 4f9c58cc6..fb5459b40 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,36 +21,35 @@
package org.onap.policy.apex.examples.adaptive;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-public class AnomalyDetectionModelTest {
+class AnomalyDetectionModelTest {
private static final String VALID_MODEL_STRING = "***validation of model successful***";
TestApexModel<AxPolicyModel> testApexModel;
/**
* Sets up embedded Derby database and the Apex anomaly detection model for the tests.
- * @throws Exception exception to be thrown while setting up the database connection
*/
- @Before
- public void setup() throws Exception {
+ @BeforeEach
+ void setup() {
testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAnomalyDetectionModelCreator());
}
@Test
- public void testModelValid() throws Exception {
+ void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
assertEquals(VALID_MODEL_STRING, result.toString());
}
@Test
- public void testModelWriteReadJson() throws Exception {
+ void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
}
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionTslUseCaseTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionTslUseCaseTest.java
index 5beab7724..e4d0c2640 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionTslUseCaseTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionTslUseCaseTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,16 +22,15 @@
package org.onap.policy.apex.examples.adaptive;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.io.IOException;
import java.util.Random;
import java.util.concurrent.TimeUnit;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
@@ -53,13 +52,13 @@ import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * This policy passes, and recieves a Double event context filed called "EVCDouble".<br>
+ * This policy passes, and receives a Double event context filed called "EVCDouble".<br>
* The policy tries to detect anomalies in the pattern of values for EVCDouble<br>
* See the 2 test cases below (1 short, 1 long)
*
* @author John Keeney (John.Keeney@ericsson.com)
*/
-public class AnomalyDetectionTslUseCaseTest {
+class AnomalyDetectionTslUseCaseTest {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(AnomalyDetectionTslUseCaseTest.class);
private static final int MAXITERATIONS = 3660;
@@ -72,8 +71,8 @@ public class AnomalyDetectionTslUseCaseTest {
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
@@ -102,8 +101,8 @@ public class AnomalyDetectionTslUseCaseTest {
/**
* After test.
*/
- @After
- public void afterTest() {
+ @AfterEach
+ void afterTest() {
ParameterService.deregister(engineParameters);
ParameterService.deregister(contextParameters.getDistributorParameters());
@@ -118,12 +117,10 @@ public class AnomalyDetectionTslUseCaseTest {
* Test anomaly detection tsl.
*
* @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- // once through the long running test below
- public void testAnomalyDetectionTsl() throws ApexException, InterruptedException, IOException {
+ // once through the long-running test below
+ void testAnomalyDetectionTsl() throws ApexException {
final AxPolicyModel apexPolicyModel = new AdaptiveDomainModelFactory().getAnomalyDetectionPolicyModel();
assertNotNull(apexPolicyModel);
@@ -140,34 +137,32 @@ public class AnomalyDetectionTslUseCaseTest {
apexEngine1.updateModel(apexPolicyModel, false);
apexEngine1.start();
final EnEvent triggerEvent =
- apexEngine1.createEvent(new AxArtifactKey("AnomalyDetectionTriggerEvent", "0.0.1"));
+ apexEngine1.createEvent(new AxArtifactKey("AnomalyDetectionTriggerEvent", "0.0.1"));
final double rval = RAND.nextGaussian();
triggerEvent.put("Iteration", 0);
triggerEvent.put("MonitoredValue", rval);
- LOGGER.info("Triggering policy in Engine 1 with " + triggerEvent);
+ LOGGER.info("Triggering policy in Engine 1 with {}", triggerEvent);
apexEngine1.handleEvent(triggerEvent);
final EnEvent result = listener1.getResult();
LOGGER.info("Receiving action event {} ", result);
- assertEquals("ExecutionIDs are different", triggerEvent.getExecutionId(), result.getExecutionId());
+ assertEquals(triggerEvent.getExecutionId(), result.getExecutionId(), "ExecutionIDs are different");
triggerEvent.clear();
result.clear();
- await().atLeast(1, TimeUnit.MILLISECONDS).until(() -> result.isEmpty());
+ await().atLeast(1, TimeUnit.MILLISECONDS).until(result::isEmpty);
apexEngine1.stop();
}
/**
- * This policy passes, and recieves a Double event context filed called "EVCDouble"<br>
+ * This policy passes, and receives a Double event context filed called "EVCDouble"<br>
* The policy tries to detect anomalies in the pattern of values for EVCDouble <br>
* This test case generates a SineWave-like pattern for the parameter, repeating every 360 iterations. (These Period
* should probably be set using TaskParameters!) Every 361st value is a random number!, so should be identified as
* an Anomaly. The policy has 3 Decide Tasks, and the Decide TaskSelectionLogic picks one depending on the
* 'Anomaliness' of the input data. <br>
- * To plot the results grep debug results for the string "************", paste into excel and delete non-relevant
+ * To plot the results grep debug results for the string "************", paste into Excel and delete non-relevant
* columns<br>
*
* @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
// Test is disabled by default. uncomment below, or execute using the main() method
// @Test
@@ -175,7 +170,7 @@ public class AnomalyDetectionTslUseCaseTest {
// -Dtest=org.onap.policy.apex.core.engine.ml.TestAnomalyDetectionTslUseCase test | findstr /L /C:"Apex [main] DEBUG
// c.e.a.e.TaskSelectionExecutionLogging -
// TestAnomalyDetectionTSL_Policy0000DecideStateTaskSelectionLogic.getTask():"
- public void testAnomalyDetectionTslmain() throws ApexException, InterruptedException, IOException {
+ void testAnomalyDetectionTslMain() throws ApexException {
final AxPolicyModel apexPolicyModel = new AdaptiveDomainModelFactory().getAnomalyDetectionPolicyModel();
assertNotNull(apexPolicyModel);
@@ -197,23 +192,23 @@ public class AnomalyDetectionTslUseCaseTest {
apexEngine1.start();
final EnEvent triggerEvent =
- apexEngine1.createEvent(new AxArtifactKey("AnomalyDetectionTriggerEvent", "0.0.1"));
+ apexEngine1.createEvent(new AxArtifactKey("AnomalyDetectionTriggerEvent", "0.0.1"));
assertNotNull(triggerEvent);
for (int iteration = 0; iteration < MAXITERATIONS; iteration++) {
// Trigger the policy in engine 1
double value = (Math.sin(Math.toRadians(iteration))) + (RAND.nextGaussian() / 25.0);
- // lets make every 361st number a random value to perhaps flag as an anomaly
+ // let's make every 361st number a random value to perhaps flag as an anomaly
if (((iteration + 45) % 361) == 0) {
value = (RAND.nextGaussian() * 2.0);
}
triggerEvent.put("Iteration", iteration);
triggerEvent.put("MonitoredValue", value);
- LOGGER.info("Iteration " + iteration + ":\tTriggering policy in Engine 1 with " + triggerEvent);
+ LOGGER.info("Iteration {}:\tTriggering policy in Engine 1 with {}", iteration, triggerEvent);
apexEngine1.handleEvent(triggerEvent);
final EnEvent result = listener1.getResult();
- LOGGER.info("Iteration " + iteration + ":\tReceiving action event {} ", result);
+ LOGGER.info("Iteration {}:\tReceiving action event {} ", iteration, result);
triggerEvent.clear();
result.clear();
}
@@ -226,10 +221,8 @@ public class AnomalyDetectionTslUseCaseTest {
*
* @param args the arguments
* @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
- public static void main(final String[] args) throws ApexException, InterruptedException, IOException {
- new AnomalyDetectionTslUseCaseTest().testAnomalyDetectionTslmain();
+ public static void main(final String[] args) throws ApexException {
+ new AnomalyDetectionTslUseCaseTest().testAnomalyDetectionTslMain();
}
}
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java
index c69fa0678..c864de150 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,36 +21,35 @@
package org.onap.policy.apex.examples.adaptive;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-public class AutoLearnModelTest {
+class AutoLearnModelTest {
private static final String VALID_MODEL_STRING = "***validation of model successful***";
TestApexModel<AxPolicyModel> testApexModel;
/**
* Sets up embedded Derby database and the Apex AutoLearn model for the tests.
- * @throws Exception exception to be thrown while setting up the database connection
*/
- @Before
- public void setup() throws Exception {
+ @BeforeEach
+ void setup() {
testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAutoLearnModelCreator());
}
@Test
- public void testModelValid() throws Exception {
+ void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
assertEquals(VALID_MODEL_STRING, result.toString());
}
@Test
- public void testModelWriteReadJson() throws Exception {
+ void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
}
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnTslUseCaseTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnTslUseCaseTest.java
index 52d1b7ff8..bcb953a81 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnTslUseCaseTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnTslUseCaseTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,16 +22,15 @@
package org.onap.policy.apex.examples.adaptive;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.io.IOException;
import java.util.Random;
import java.util.concurrent.TimeUnit;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
@@ -52,34 +51,36 @@ import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
-// TODO: Auto-generated Javadoc
/**
* Test Auto learning in TSL.
*
* @author John Keeney (John.Keeney@ericsson.com)
*/
-public class AutoLearnTslUseCaseTest {
+class AutoLearnTslUseCaseTest {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(AutoLearnTslUseCaseTest.class);
private static final int MAXITERATIONS = 1000;
private static final Random rand = new Random(System.currentTimeMillis());
+ private static final String RECEIVING_ACTION_EVENT = "Receiving action event {} ";
+ private static final String TRIGGER_MESSAGE = "Triggering policy in Engine 1 with {}";
private SchemaParameters schemaParameters;
private ContextParameters contextParameters;
private EngineParameters engineParameters;
+
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
schemaParameters = new SchemaParameters();
-
+
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
ParameterService.register(schemaParameters);
-
+
contextParameters = new ContextParameters();
contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
@@ -91,7 +92,7 @@ public class AutoLearnTslUseCaseTest {
ParameterService.register(contextParameters.getDistributorParameters());
ParameterService.register(contextParameters.getLockManagerParameters());
ParameterService.register(contextParameters.getPersistorParameters());
-
+
engineParameters = new EngineParameters();
engineParameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters());
engineParameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters());
@@ -101,10 +102,10 @@ public class AutoLearnTslUseCaseTest {
/**
* After test.
*/
- @After
- public void afterTest() {
+ @AfterEach
+ void afterTest() {
ParameterService.deregister(engineParameters);
-
+
ParameterService.deregister(contextParameters.getDistributorParameters());
ParameterService.deregister(contextParameters.getLockManagerParameters());
ParameterService.deregister(contextParameters.getPersistorParameters());
@@ -117,12 +118,10 @@ public class AutoLearnTslUseCaseTest {
* Test auto learn tsl.
*
* @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- // once through the long running test below
- public void testAutoLearnTsl() throws ApexException, InterruptedException, IOException {
+ // once through the long-running test below
+ void testAutoLearnTsl() throws ApexException {
final AxPolicyModel apexPolicyModel = new AdaptiveDomainModelFactory().getAutoLearnPolicyModel();
assertNotNull(apexPolicyModel);
@@ -142,11 +141,12 @@ public class AutoLearnTslUseCaseTest {
final double rval = rand.nextGaussian();
triggerEvent.put("MonitoredValue", rval);
triggerEvent.put("LastMonitoredValue", 0D);
- LOGGER.info("Triggering policy in Engine 1 with " + triggerEvent);
+
+ LOGGER.info(TRIGGER_MESSAGE, triggerEvent);
apexEngine1.handleEvent(triggerEvent);
final EnEvent result = listener1.getResult();
- LOGGER.info("Receiving action event {} ", result);
- assertEquals("ExecutionIDs are different", triggerEvent.getExecutionId(), result.getExecutionId());
+ LOGGER.info(RECEIVING_ACTION_EVENT, result);
+ assertEquals(triggerEvent.getExecutionId(), result.getExecutionId(), "ExecutionIDs are different");
triggerEvent.clear();
result.clear();
await().atLeast(10, TimeUnit.MILLISECONDS).until(() -> triggerEvent.isEmpty() && result.isEmpty());
@@ -166,11 +166,9 @@ public class AutoLearnTslUseCaseTest {
* columns<br>
*
* @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
// @Test
- public void testAutoLearnTslMain() throws ApexException, InterruptedException, IOException {
+ void testAutoLearnTslMain() throws ApexException {
final double dwant = 50.0;
final double toleranceTileJump = 3.0;
@@ -209,10 +207,10 @@ public class AutoLearnTslUseCaseTest {
for (int iteration = 0; iteration < MAXITERATIONS; iteration++) {
// Trigger the policy in engine 1
- LOGGER.info("Triggering policy in Engine 1 with " + triggerEvent);
+ LOGGER.info(TRIGGER_MESSAGE, triggerEvent);
apexEngine1.handleEvent(triggerEvent);
final EnEvent result = listener1.getResult();
- LOGGER.info("Receiving action event {} ", result);
+ LOGGER.info(RECEIVING_ACTION_EVENT, result);
triggerEvent.clear();
double val = (Double) result.get("MonitoredValue");
@@ -230,7 +228,7 @@ public class AutoLearnTslUseCaseTest {
val = rval;
triggerEvent.put("MonitoredValue", val);
LOGGER.info("Iteration " + iteration + ": Average " + avval + " has become closer (" + distance
- + ") than " + toleranceTileJump + " to " + dwant + " so reseting val:\t\t\t\t\t\t\t\t" + val);
+ + ") than " + toleranceTileJump + " to " + dwant + " so reseting val:\t\t\t\t\t\t\t\t" + val);
avval = 0;
avcount = 0;
}
@@ -249,10 +247,8 @@ public class AutoLearnTslUseCaseTest {
*
* @param args the arguments
* @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
- public static void main(final String[] args) throws ApexException, InterruptedException, IOException {
+ public static void main(final String[] args) throws ApexException {
new AutoLearnTslUseCaseTest().testAutoLearnTslMain();
}
}