summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-executor/plugins-executor-java/src/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2018-12-03 22:48:10 +0000
committerliamfallon <liam.fallon@est.tech>2018-12-04 09:59:17 +0000
commit259039fa91e3038c41f4a322d81e7ea07a78b96e (patch)
treeb4206cbd4d28d32c33cbe7cda4971d01b68c755a /plugins/plugins-executor/plugins-executor-java/src/main
parentdc2e6900325c0e69e7efb0346602d29ee634fbea (diff)
Add unit test for Java executor
Code coverage in the Apex-PDP plugins is very low. JUnit coverage will be increased for the Plugins over the Dublin design timeline. Issue-ID: POLICY-1379 Change-Id: Ie70ab5a9be650818cb330ec5be2a89a5db6153c5 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'plugins/plugins-executor/plugins-executor-java/src/main')
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java6
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java6
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java30
3 files changed, 16 insertions, 26 deletions
diff --git a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java
index 8577d18fb..ef0a8d178 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java
@@ -98,11 +98,7 @@ public class JavaStateFinalizerExecutor extends StateFinalizerExecutor {
executePost(returnValue);
// Send back the return event
- if (returnValue) {
- return getOutgoing();
- } else {
- return null;
- }
+ return getOutgoing();
}
/**
diff --git a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java
index 829434dc3..e9bf45305 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java
@@ -97,11 +97,7 @@ public class JavaTaskExecutor extends TaskExecutor {
executePost(returnValue);
// Send back the return event
- if (returnValue) {
- return getOutgoing();
- } else {
- return null;
- }
+ return getOutgoing();
}
/**
diff --git a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java
index e642972af..02794cdf6 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java
@@ -58,8 +58,10 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor {
// Create the task logic object from the byte code of the class
taskSelectionLogicObject = Class.forName(getSubject().getTaskSelectionLogic().getLogic()).newInstance();
} catch (final Exception e) {
- LOGGER.error("instantiation error on Java class" + taskSelectionLogicObject, e);
- throw new StateMachineException("instantiation error on Java class" + taskSelectionLogicObject, e);
+ LOGGER.error("instantiation error on Java class \"" + getSubject().getTaskSelectionLogic().getLogic()
+ + "\"", e);
+ throw new StateMachineException("instantiation error on Java class \""
+ + getSubject().getTaskSelectionLogic().getLogic() + "\"", e);
}
}
@@ -74,7 +76,7 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor {
*/
@Override
public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent)
- throws StateMachineException, ContextException {
+ throws StateMachineException, ContextException {
// Do execution pre work
executePre(executionId, incomingEvent);
@@ -84,26 +86,22 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor {
// Find and call the method with the signature "public boolean getTask(final TaskSelectionExecutionContext
// executor)" to invoke the task selection
// logic in the Java class
- final Method method = taskSelectionLogicObject.getClass().getDeclaredMethod("getTask", (Class[])
- new Class[] { TaskSelectionExecutionContext.class });
+ final Method method = taskSelectionLogicObject.getClass().getDeclaredMethod("getTask",
+ (Class[]) new Class[] { TaskSelectionExecutionContext.class });
returnValue = (boolean) method.invoke(taskSelectionLogicObject, getExecutionContext());
} catch (final Exception e) {
- LOGGER.error(
- "execute: task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"",
- e);
+ LOGGER.error("execute: task selection logic failed to run for state \"" + getSubject().getKey().getId()
+ + "\"", e);
throw new StateMachineException(
- "task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"", e);
+ "task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"",
+ e);
}
// Do the execution post work
executePost(returnValue);
// Send back the return event
- if (returnValue) {
- return getOutgoing();
- } else {
- return null;
- }
+ return getOutgoing();
}
/**
@@ -114,7 +112,7 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor {
@Override
public void cleanUp() throws StateMachineException {
LOGGER.debug("cleanUp:" + getSubject().getKey().getId() + ","
- + getSubject().getTaskSelectionLogic().getLogicFlavour() + ","
- + getSubject().getTaskSelectionLogic().getLogic());
+ + getSubject().getTaskSelectionLogic().getLogicFlavour() + ","
+ + getSubject().getTaskSelectionLogic().getLogic());
}
}