aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-06-18 15:12:56 +0100
committeradheli.tavares <adheli.tavares@est.tech>2024-06-19 17:25:08 +0100
commita23bd8c218d7044e1d79e240fdb74f00947a3108 (patch)
tree064323adf3c19a5346c108d905495363cce45adf /examples
parent6040233dcbe4a64b977ee750c6d0d12b2d513c4c (diff)
Convert junit4 to junit5
- clean up any references to junit4 - clean up some sonar complaints - remove not used integration tests Issue-ID: POLICY-5041 Change-Id: I67e7a8f00df5b6c5ba514f4ea2ecd96bf942d4c7 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'examples')
-rw-r--r--examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java41
1 files changed, 21 insertions, 20 deletions
diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java
index 317a86349..d1a5970e3 100644
--- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java
+++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (c) 2021 Nordix Foundation.
+ * Modifications Copyright (c) 2021, 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.
@@ -52,11 +52,12 @@ public class AutoLearnPolicyDecideTaskSelectionLogic {
* @return the task
*/
public boolean getTask(final TaskSelectionExecutionContext executor) {
+ var returnValue = true;
var idString = executor.subject.getId();
- executor.logger.debug(idString);
+ TaskSelectionExecutionContext.logger.debug(idString);
var inFieldsString = executor.inFields.toString();
- executor.logger.debug(inFieldsString);
+ TaskSelectionExecutionContext.logger.debug(inFieldsString);
final List<String> tasks = executor.subject.getTaskNames();
size = tasks.size();
@@ -64,8 +65,8 @@ public class AutoLearnPolicyDecideTaskSelectionLogic {
try {
executor.getContextAlbum(AUTO_LEARN_ALBUM).lockForWriting(AUTO_LEARN);
} catch (final ContextException e) {
- executor.logger.error("Failed to acquire write lock on \"autoLearn\" context", e);
- return false;
+ TaskSelectionExecutionContext.logger.error("Failed to acquire write lock on \"autoLearn\" context", e);
+ returnValue = false;
}
// Get the context object
@@ -89,23 +90,23 @@ public class AutoLearnPolicyDecideTaskSelectionLogic {
try {
executor.getContextAlbum(AUTO_LEARN_ALBUM).unlockForWriting(AUTO_LEARN);
} catch (final ContextException e) {
- executor.logger.error("Failed to acquire write lock on \"autoLearn\" context", e);
- return false;
+ TaskSelectionExecutionContext.logger.error("Failed to acquire write lock on \"autoLearn\" context", e);
+ returnValue = false;
}
executor.subject.getTaskKey(tasks.get(option)).copyTo(executor.selectedTask);
- return true;
+ return returnValue;
}
/**
* Gets the option.
*
- * @param diff the diff
+ * @param diff the diff
* @param autoLearn the auto learn
* @return the option
*/
private int getOption(final double diff, final AutoLearn autoLearn) {
- final Double[] avdiffs = autoLearn.getAvDiffs().toArray(new Double[autoLearn.getAvDiffs().size()]);
+ final Double[] avdiffs = autoLearn.getAvDiffs().toArray(new Double[0]);
final var r = RAND.nextInt(size);
int closestupi = -1;
int closestdowni = -1;
@@ -130,13 +131,13 @@ public class AutoLearnPolicyDecideTaskSelectionLogic {
/**
* Learn.
*
- * @param option the option
- * @param diff the diff
+ * @param option the option
+ * @param diff the diff
* @param autoLearn the auto learn
*/
private void learn(final int option, final double diff, final AutoLearn autoLearn) {
- final Double[] avdiffs = autoLearn.getAvDiffs().toArray(new Double[autoLearn.getAvDiffs().size()]);
- final Long[] counts = autoLearn.getCounts().toArray(new Long[autoLearn.getCounts().size()]);
+ final Double[] avdiffs = autoLearn.getAvDiffs().toArray(new Double[0]);
+ final Long[] counts = autoLearn.getCounts().toArray(new Long[0]);
if (option < 0 || option >= avdiffs.length) {
throw new IllegalArgumentException("Error: option" + option);
}
@@ -153,16 +154,16 @@ public class AutoLearnPolicyDecideTaskSelectionLogic {
/**
* Calculate the return value of the learning.
*
- * @param diff the difference
- * @param random the random value
- * @param closestupi closest to i upwards
+ * @param diff the difference
+ * @param random the random value
+ * @param closestupi closest to i upwards
* @param closestdowni closest to i downwards
- * @param closestup closest up value
- * @param closestdown closest down value
+ * @param closestup closest up value
+ * @param closestdown closest down value
* @return the return value
*/
private int calculateReturnValue(final double diff, final int random, int closestupi, int closestdowni,
- double closestup, double closestdown) {
+ double closestup, double closestdown) {
if (closestupi == -1 || closestdowni == -1) {
return random;
}