aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/main/java
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2024-06-19 09:20:52 +0000
committerGerrit Code Review <gerrit@onap.org>2024-06-19 09:20:52 +0000
commit5a94b55e4f8effbc825b58cbdfd6754b288d39f5 (patch)
treed37bcbfe071b975727045862a6821aee235926cf /core/src/main/java
parentb7fb3565349e769eb9153e2134ab3ba156397ed9 (diff)
parent0ab922a17b570f03df710fce58fd9e2f02bb9986 (diff)
Merge "Convert junit4 to junit5"
Diffstat (limited to 'core/src/main/java')
-rw-r--r--core/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java14
-rw-r--r--core/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java4
-rw-r--r--core/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java4
-rw-r--r--core/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java4
-rw-r--r--core/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java4
-rw-r--r--core/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java18
6 files changed, 24 insertions, 24 deletions
diff --git a/core/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java b/core/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java
index 35139bfe4..773923444 100644
--- a/core/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java
+++ b/core/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.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.
* Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -193,7 +193,8 @@ public class ApexEngineImpl implements ApexEngine {
}
private void updateTaskBasedOnStateOutput(AxPolicyModel apexPolicyModel, Set<AxArtifactKey> updatedTasks,
- AxState state, AxArtifactKey taskKey, AxStateTaskReference taskRef, AxTask task) {
+ AxState state, AxArtifactKey taskKey, AxStateTaskReference taskRef,
+ AxTask task) {
Map<String, AxEvent> outputEvents = new TreeMap<>();
AxStateOutput stateOutput = null;
if (AxStateTaskOutputType.LOGIC.equals(taskRef.getStateTaskOutputType())) {
@@ -279,14 +280,13 @@ public class ApexEngineImpl implements ApexEngine {
}
// Stop the engine if it is in state READY, if it is in state EXECUTING, wait for execution to finish
for (int increment = ApexEngineConstants.STOP_EXECUTION_WAIT_TIMEOUT; increment > 0;
- increment -= ApexEngineConstants.APEX_ENGINE_STOP_EXECUTION_WAIT_INCREMENT) {
+ increment -= ApexEngineConstants.APEX_ENGINE_STOP_EXECUTION_WAIT_INCREMENT) {
ThreadUtilities.sleep(ApexEngineConstants.APEX_ENGINE_STOP_EXECUTION_WAIT_INCREMENT);
synchronized (stateLockObj) {
switch (state) {
// Engine is OK to stop or has been stopped on return of an event
- case READY:
- case STOPPED:
+ case READY, STOPPED:
state = AxEngineState.STOPPED;
updateStatePrometheusMetric();
stateMachineHandler.stop();
@@ -388,7 +388,7 @@ public class ApexEngineImpl implements ApexEngine {
String message = "execute(): triggered by event " + incomingEvent.toString();
LOGGER.debug(message);
- // By default we return a null event on errors
+ // By default, we return a null event on errors
Collection<EnEvent> outgoingEvents = null;
try {
engineStats.executionEnter(incomingEvent.getKey());
@@ -406,7 +406,7 @@ public class ApexEngineImpl implements ApexEngine {
try {
synchronized (eventListeners) {
if (eventListeners.isEmpty()) {
- LOGGER.debug("handleEvent()<-{},{}, There is no listener registered to recieve outgoing event: {}",
+ LOGGER.debug("handleEvent()<-{},{}, There is no listener registered to receive outgoing event: {}",
key.getId(), state, outgoingEvents);
}
for (final EnEventListener axEventListener : eventListeners.values()) {
diff --git a/core/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java b/core/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java
index 6cbc04678..6b8dd43ec 100644
--- a/core/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java
+++ b/core/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -129,7 +129,7 @@ public class StateMachineExecutor implements Executor<EnEvent, Collection<EnEven
public Collection<EnEvent> execute(final long executionId, final Properties executionProperties,
final EnEvent incomingEvent) throws StateMachineException, ContextException {
// Check if there are any states on the state machine
- if (stateExecutorMap.size() == 0) {
+ if (stateExecutorMap.isEmpty()) {
throw new StateMachineException("no states defined on state machine");
}
diff --git a/core/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java b/core/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java
index 12e350390..7cdca18d8 100644
--- a/core/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java
+++ b/core/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
@@ -86,7 +86,7 @@ public class StateFinalizerExecutionContext extends AbstractExecutionContext {
/**
* Logger for state finalizer execution, state finalizer logic can use this field to access and log to Apex logging.
*/
- public final XLogger logger = EXCEUTION_LOGGER;
+ public static final XLogger logger = EXCEUTION_LOGGER;
// CHECKSTYLE:ON: checkstyle:visibilityModifier
diff --git a/core/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java b/core/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java
index a54252e05..d5bb370bc 100644
--- a/core/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java
+++ b/core/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
@@ -83,7 +83,7 @@ public class TaskExecutionContext extends AbstractExecutionContext {
/**
* Logger for task execution, task logic can use this field to access and log to Apex logging.
*/
- public final XLogger logger = EXECUTION_LOGGER;
+ public static final XLogger logger = EXECUTION_LOGGER;
// CHECKSTYLE:ON: checkstyle:VisibilityModifier
diff --git a/core/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java b/core/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java
index c79e907d9..62808dfb6 100644
--- a/core/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java
+++ b/core/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
@@ -73,7 +73,7 @@ public class TaskSelectionExecutionContext extends AbstractExecutionContext {
/**
* Logger for task selection execution, task selection logic can use this field to access and log to Apex logging.
*/
- public final XLogger logger = EXECUTION_LOGGER;
+ public static final XLogger logger = EXECUTION_LOGGER;
// CHECKSTYLE:ON: checkstyle:VisibilityModifier
diff --git a/core/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java b/core/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java
index 9dc841f48..53b041e36 100644
--- a/core/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java
+++ b/core/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.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.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -157,21 +157,21 @@ public class ExecutorFactoryImpl implements ExecutorFactory {
}
// Get the class for the executor using reflection
- Class<? extends Object> executorPluginClass = null;
+ Class<?> executorPluginClass;
try {
executorPluginClass = Class.forName(executorClassName);
} catch (final ClassNotFoundException e) {
- LOGGER.error("Apex executor class not found for executor plugin \"" + executorClassName + "\"", e);
+ LOGGER.error("Apex executor class not found for executor plugin \"{}\"", executorClassName, e);
throw new StateMachineException(
"Apex executor class not found for executor plugin \"" + executorClassName + "\"", e);
}
// Check the class is an executor
if (!Executor.class.isAssignableFrom(executorPluginClass)) {
- LOGGER.error("Specified Apex executor plugin class \"{}\" does not implment the Executor interface",
+ LOGGER.error("Specified Apex executor plugin class \"{}\" does not implement the Executor interface",
executorClassName);
throw new StateMachineException("Specified Apex executor plugin class \"" + executorClassName
- + "\" does not implment the Executor interface");
+ + "\" does not implement the Executor interface");
}
return (Class<Executor<?, ?, ?, ?>>) executorPluginClass;
@@ -181,14 +181,14 @@ public class ExecutorFactoryImpl implements ExecutorFactory {
* Get an instance of an executor plugin class of the specified type and super type.
*
* @param logicFlavour The logic flavour of the logic
- * @param executorClass The sub-class of the executor type to be instantiated
+ * @param executorClass The subclass of the executor type to be instantiated
* @param executorSuperClass The super type of the class of executor to be instantiated
* @return The instantiated class
*/
private Executor<?, ?, ?, ?> createExecutor(final String logicFlavour,
final Class<Executor<?, ?, ?, ?>> executorClass,
final Class<? extends Executor<?, ?, ?, ?>> executorSuperClass) {
- // It's OK for an executor class not to be defined but it's not all right to try and create
+ // It's OK for an executor class not to be defined, but it's not all right to try and create
// a non-defined
// executor class
if (executorClass == null) {
@@ -199,7 +199,7 @@ public class ExecutorFactoryImpl implements ExecutorFactory {
}
// Create an executor for the specified logic flavour
- Object executorObject = null;
+ Executor<?, ?, ?, ?> executorObject;
try {
executorObject = executorClass.getDeclaredConstructor().newInstance();
} catch (final Exception e) {
@@ -218,6 +218,6 @@ public class ExecutorFactoryImpl implements ExecutorFactory {
throw new StateMachineRuntimeException(errorMessage);
}
- return (Executor<?, ?, ?, ?>) executorObject;
+ return executorObject;
}
}