summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.java21
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml12
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java35
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java16
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java31
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java23
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java5
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java8
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java6
9 files changed, 64 insertions, 93 deletions
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.java
index 21e4d76a8..fba45b22a 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.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=========================================================
*/
@@ -80,7 +81,7 @@ public class AvroObjectMapperFactory {
final Schema nullschema = Schema.create(Schema.Type.NULL);
if (types.size() != 2 || !types.contains(nullschema)) {
final String resultSting = userKey.getId()
- + ": Apex currently only supports UNION schemas with 2 options, one must be NULL";
+ + ": Apex currently only supports UNION schemas with 2 options, one must be NULL";
LOGGER.warn(resultSting);
throw new ContextRuntimeException(resultSting);
}
@@ -91,8 +92,8 @@ public class AvroObjectMapperFactory {
schema = types.get(1);
}
if (Schema.Type.NULL.equals(schema.getType())) {
- final String resultSting = userKey.getId()
- + ": Apex currently only supports UNION schema2 with 2 options, "
+ final String resultSting =
+ userKey.getId() + ": Apex currently only supports UNION schema2 with 2 options, "
+ "only one can be NULL, and the other cannot be another UNION";
LOGGER.warn(resultSting);
throw new ContextRuntimeException(resultSting);
@@ -103,8 +104,8 @@ public class AvroObjectMapperFactory {
// Check that there is a definition for the mapper for this type
if (!AVRO_OBJECT_MAPPER_MAP.containsKey(avroType) || AVRO_OBJECT_MAPPER_MAP.get(avroType) == null) {
- final String resultSting = userKey.getId() + ": no Avro object mapper defined for Avro type \"" + avroType
- + "\"";
+ final String resultSting =
+ userKey.getId() + ": no Avro object mapper defined for Avro type \"" + avroType + "\"";
LOGGER.warn(resultSting);
throw new ContextRuntimeException(resultSting);
}
@@ -112,14 +113,14 @@ public class AvroObjectMapperFactory {
// Create a mapper
AvroObjectMapper avroObjectMapper;
try {
- avroObjectMapper = AVRO_OBJECT_MAPPER_MAP.get(avroType).newInstance();
+ avroObjectMapper = AVRO_OBJECT_MAPPER_MAP.get(avroType).getDeclaredConstructor().newInstance();
if (isnullable) {
avroObjectMapper = new AvroNullableMapper(avroObjectMapper);
}
} catch (final Exception e) {
final String resultSting = userKey.getId() + ": could not create an Avro object mapper of type \""
- + AVRO_OBJECT_MAPPER_MAP.get(avroType) + "\" for Avro type \"" + avroType + "\" : " + e;
+ + AVRO_OBJECT_MAPPER_MAP.get(avroType) + "\" for Avro type \"" + avroType + "\" : " + e;
LOGGER.warn(resultSting, e);
throw new ContextRuntimeException(resultSting, e);
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml
index 1e91322dc..c2c154685 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml
@@ -1,7 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
- Modifications Copyright (C) 2019 Nordix Foundation.
+ Modifications Copyright (C) 2019-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.
@@ -18,7 +18,9 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -48,6 +50,12 @@
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<profiles>
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java
index 0b73a8793..39164e7c5 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.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-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.
@@ -21,25 +21,10 @@
package org.onap.policy.apex.plugins.event.carrier.restclient;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-
import lombok.Getter;
import lombok.Setter;
-import org.apache.commons.lang3.StringUtils;
+
import org.onap.policy.apex.service.parameters.carriertechnology.RestPluginCarrierTechnologyParameters;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ValidationStatus;
-import org.onap.policy.common.utils.validation.ParameterValidationUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
// @formatter:off
/**
@@ -63,22 +48,16 @@ import org.slf4j.LoggerFactory;
@Setter
@Getter
public class RestClientCarrierTechnologyParameters extends RestPluginCarrierTechnologyParameters {
- // Get a reference to the logger
- private static final Logger LOGGER = LoggerFactory.getLogger(RestClientCarrierTechnologyParameters.class);
+
/**
* Constructor to create a REST carrier technology parameters instance and register the instance with the parameter
* service.
*/
public RestClientCarrierTechnologyParameters() {
super();
- CARRIER_TECHNOLOGY_LABEL = "RESTCLIENT";
- EVENT_PRODUCER_PLUGIN_CLASS = ApexRestClientProducer.class.getName();
- EVENT_CONSUMER_PLUGIN_CLASS = ApexRestClientConsumer.class.getName();
- // Set the carrier technology properties for the web socket carrier technology
- this.setLabel(CARRIER_TECHNOLOGY_LABEL);
- this.setEventProducerPluginClass(EVENT_PRODUCER_PLUGIN_CLASS);
- this.setEventConsumerPluginClass(EVENT_CONSUMER_PLUGIN_CLASS);
- }
-
+ this.setLabel("RESTCLIENT");
+ this.setEventProducerPluginClass(ApexRestClientProducer.class.getName());
+ this.setEventConsumerPluginClass(ApexRestClientConsumer.class.getName());
+ }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java
index 0e4ddd0a3..df3b61bcb 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-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.
@@ -21,6 +21,7 @@
package org.onap.policy.apex.plugins.event.carrier.restclient;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -35,7 +36,7 @@ import org.onap.policy.apex.service.parameters.ApexParameters;
import org.onap.policy.common.parameters.ParameterException;
/**
- * Test REST Requestor carrier technology parameters.
+ * Test REST client carrier technology parameters.
*/
public class RestClientCarrierTechnologyParametersTest {
@@ -92,16 +93,11 @@ public class RestClientCarrierTechnologyParametersTest {
arguments.setConfigurationFilePath("src/test/resources/prodcons/RESTClientWithHTTPFilterInvalid.json");
arguments.setRelativeFileRoot(".");
- try {
- new ApexParameterHandler().getParameters(arguments);
+ assertThatCode(() -> {
ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
-
parameters.getEventInputParameters().get("RestClientConsumer0").getCarrierTechnologyParameters();
- fail("test should throw an exception here");
- } catch (ParameterException pe) {
- assertTrue(pe.getMessage().contains(
- "Invalid HTTP code filter, the filter must be specified as a three digit regular expression: "));
- }
+ }).hasMessageContaining(
+ "Invalid HTTP code filter, the filter must be specified as a three digit regular expression: ");
}
@Test
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java
index 0d122c67b..4296331e4 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.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-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.
@@ -21,25 +21,14 @@
package org.onap.policy.apex.plugins.event.carrier.restrequestor;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
import lombok.Getter;
import lombok.Setter;
-import org.apache.commons.lang3.StringUtils;
+
import org.onap.policy.apex.service.parameters.carriertechnology.RestPluginCarrierTechnologyParameters;
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
-import org.onap.policy.common.utils.validation.ParameterValidationUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
// @formatter:off
/**
@@ -64,10 +53,6 @@ import org.slf4j.LoggerFactory;
@Getter
@Setter
public class RestRequestorCarrierTechnologyParameters extends RestPluginCarrierTechnologyParameters {
- // Get a reference to the logger
- private static final Logger LOGGER = LoggerFactory.getLogger(RestRequestorCarrierTechnologyParameters.class);
-
-
/** The default HTTP method for request events. */
public static final HttpMethod DEFAULT_REQUESTOR_HTTP_METHOD = HttpMethod.GET;
@@ -82,14 +67,10 @@ public class RestRequestorCarrierTechnologyParameters extends RestPluginCarrierT
public RestRequestorCarrierTechnologyParameters() {
super();
- // Set the carrier technology properties for the web socket carrier technology
- CARRIER_TECHNOLOGY_LABEL = "RESTREQUESTOR";
- EVENT_PRODUCER_PLUGIN_CLASS = ApexRestRequestorProducer.class.getName();
- EVENT_CONSUMER_PLUGIN_CLASS = ApexRestRequestorConsumer.class.getName();
- // Set the carrier technology properties for the web socket carrier technology
- this.setLabel(CARRIER_TECHNOLOGY_LABEL);
- this.setEventProducerPluginClass(EVENT_PRODUCER_PLUGIN_CLASS);
- this.setEventConsumerPluginClass(EVENT_CONSUMER_PLUGIN_CLASS);
+ // Set the carrier technology properties for the REST requestor carrier technology
+ this.setLabel("RESTREQUESTOR");
+ this.setEventProducerPluginClass(ApexRestRequestorProducer.class.getName());
+ this.setEventConsumerPluginClass(ApexRestRequestorConsumer.class.getName());
}
// @formatter:off
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java
index 685a1f236..7b64873b8 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java
@@ -1,6 +1,7 @@
/*-
* ============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.
@@ -113,17 +114,17 @@ public class XmlEventHandlerTest {
final Date event0004StartTime = new Date(1434363272000L);
final Map<String, Object> event0004DataMap = new HashMap<String, Object>();
event0004DataMap.put("TestSlogan", "Test slogan for External Event");
- event0004DataMap.put("TestMatchCase", new Integer(2));
- event0004DataMap.put("TestTimestamp", new Long(event0004StartTime.getTime()));
- event0004DataMap.put("TestTemperature", new Double(1064.43));
- event0004DataMap.put("TestMatchCaseSelected", new Integer(2));
- event0004DataMap.put("TestMatchStateTime", new Long(1434370506078L));
- event0004DataMap.put("TestEstablishCaseSelected", new Integer(0));
- event0004DataMap.put("TestEstablishStateTime", new Long(1434370506085L));
- event0004DataMap.put("TestDecideCaseSelected", new Integer(3));
- event0004DataMap.put("TestDecideStateTime", new Long(1434370506092L));
- event0004DataMap.put("TestActCaseSelected", new Integer(2));
- event0004DataMap.put("TestActStateTime", new Long(1434370506095L));
+ event0004DataMap.put("TestMatchCase", Integer.valueOf(2));
+ event0004DataMap.put("TestTimestamp", Long.valueOf(event0004StartTime.getTime()));
+ event0004DataMap.put("TestTemperature", Double.valueOf(1064.43));
+ event0004DataMap.put("TestMatchCaseSelected", Integer.valueOf(2));
+ event0004DataMap.put("TestMatchStateTime", Long.valueOf(1434370506078L));
+ event0004DataMap.put("TestEstablishCaseSelected", Integer.valueOf(0));
+ event0004DataMap.put("TestEstablishStateTime", Long.valueOf(1434370506085L));
+ event0004DataMap.put("TestDecideCaseSelected", Integer.valueOf(3));
+ event0004DataMap.put("TestDecideStateTime", Long.valueOf(1434370506092L));
+ event0004DataMap.put("TestActCaseSelected", Integer.valueOf(2));
+ event0004DataMap.put("TestActStateTime", Long.valueOf(1434370506095L));
final ApexEvent apexEvent0004 =
new ApexEvent("Event0004", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
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 ce242bafb..7eaaa0415 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
@@ -1,6 +1,7 @@
/*-
* ============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.
@@ -56,7 +57,7 @@ public class JavaStateFinalizerExecutor extends StateFinalizerExecutor {
// Get the class for state finalizer execution
try {
// Create the state finalizer logic object from the byte code of the class
- stateFinalizerLogicObject = Class.forName(getSubject().getLogic()).newInstance();
+ stateFinalizerLogicObject = Class.forName(getSubject().getLogic()).getDeclaredConstructor().newInstance();
} catch (final Exception e) {
LOGGER.error("instantiation error on Java class \"" + getSubject().getLogic() + "\"", e);
throw new StateMachineException("instantiation error on Java class \"" + getSubject().getLogic() + "\"", e);
@@ -87,7 +88,7 @@ public class JavaStateFinalizerExecutor extends StateFinalizerExecutor {
// to invoke the
// task logic in the Java class
final Method method = stateFinalizerLogicObject.getClass().getDeclaredMethod("getStateOutput",
- new Class[] { StateFinalizerExecutionContext.class });
+ new Class[] {StateFinalizerExecutionContext.class});
returnValue = (boolean) method.invoke(stateFinalizerLogicObject, getExecutionContext());
} catch (final Exception e) {
LOGGER.error("execute: state finalizer logic failed to run for state finalizer \"" + getSubject().getId()
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 1ceeba3b1..61ab6778e 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
@@ -1,6 +1,7 @@
/*-
* ============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.
@@ -56,7 +57,8 @@ public class JavaTaskExecutor extends TaskExecutor {
// Get the class for task execution
try {
// Create the task logic object from the byte code of the class
- taskLogicObject = Class.forName(getSubject().getTaskLogic().getLogic()).newInstance();
+ taskLogicObject =
+ Class.forName(getSubject().getTaskLogic().getLogic()).getDeclaredConstructor().newInstance();
} catch (final Exception e) {
LOGGER.error("instantiation error on Java class \"" + getSubject().getTaskLogic().getLogic() + "\"", e);
throw new StateMachineException(
@@ -86,8 +88,8 @@ public class JavaTaskExecutor extends TaskExecutor {
// Find and call the method with the signature "public boolean getEvent(final TaskExecutionContext executor)
// throws ApexException" to invoke the
// task logic in the Java class
- final Method method = taskLogicObject.getClass().getDeclaredMethod("getEvent",
- new Class[] { TaskExecutionContext.class });
+ final Method method =
+ taskLogicObject.getClass().getDeclaredMethod("getEvent", new Class[] {TaskExecutionContext.class});
returnValue = (boolean) method.invoke(taskLogicObject, getExecutionContext());
} catch (final Exception e) {
LOGGER.error("execute: task logic failed to run for task \"" + getSubject().getKey().getId() + "\"");
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 17758b19e..244a80a3c 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
@@ -1,6 +1,7 @@
/*-
* ============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.
@@ -57,7 +58,8 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor {
// Get the class for task selection
try {
// Create the task logic object from the byte code of the class
- taskSelectionLogicObject = Class.forName(getSubject().getTaskSelectionLogic().getLogic()).newInstance();
+ taskSelectionLogicObject = Class.forName(getSubject().getTaskSelectionLogic().getLogic())
+ .getDeclaredConstructor().newInstance();
} catch (final Exception e) {
LOGGER.error(
"instantiation error on Java class \"" + getSubject().getTaskSelectionLogic().getLogic() + "\"", e);
@@ -89,7 +91,7 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor {
// executor)" to invoke the task selection
// logic in the Java class
final Method method = taskSelectionLogicObject.getClass().getDeclaredMethod("getTask",
- new Class[] { TaskSelectionExecutionContext.class });
+ new Class[] {TaskSelectionExecutionContext.class});
returnValue = (boolean) method.invoke(taskSelectionLogicObject, getExecutionContext());
} catch (final Exception e) {
LOGGER.error(