diff options
81 files changed, 3028 insertions, 2546 deletions
diff --git a/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyAvroEventContext.apex b/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyAvroEventContext.apex index 9f62eca74..2cd94416f 100644 --- a/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyAvroEventContext.apex +++ b/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyAvroEventContext.apex @@ -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. @@ -52,7 +53,7 @@ LE schema create name=AvroFloat_type flavour=Avro schema=LS { - "type" : "float" + "type" : "double" } LE @@ -423,18 +424,16 @@ task contextref create name=Test_Task albumName=CustomSetAlbum task contextref create name=Test_Task albumName=CustomMapAlbum task logic create name=Test_Task logicFlavour=JAVASCRIPT logic=LS -executor.logger.debug(executor.subject.id); - -executor.logger.debug(executor.inFields); - -executor.getContextAlbum("AvroBooleanAlbum" ).put("AvroBoolean" , executor.inFields.get("AvroBoolean")); -executor.getContextAlbum("AvroByteAlbum" ).put("AvroByte" , executor.inFields.get("AvroByte" )); -executor.getContextAlbum("AvroShortAlbum" ).put("AvroShort" , executor.inFields.get("AvroShort" )); -executor.getContextAlbum("AvroIntegerAlbum" ).put("AvroInteger" , executor.inFields.get("AvroInteger")); -executor.getContextAlbum("AvroLongAlbum" ).put("AvroLong" , executor.inFields.get("AvroLong" )); -executor.getContextAlbum("AvroFloatAlbum" ).put("AvroFloat" , executor.inFields.get("AvroFloat" )); -executor.getContextAlbum("AvroDoubleAlbum" ).put("AvroDouble" , executor.inFields.get("AvroDouble" )); -executor.getContextAlbum("AvroStringAlbum" ).put("AvroString" , executor.inFields.get("AvroString" )); +executor.logger.debug(executor.getSubject().getId()); + +executor.getContextAlbum("AvroBooleanAlbum" ).put("AvroBoolean" , executor.inFields.get("AvroBoolean" )); +executor.getContextAlbum("AvroByteAlbum" ).put("AvroByte" , executor.inFields.get("AvroByte" )); +executor.getContextAlbum("AvroShortAlbum" ).put("AvroShort" , executor.inFields.get("AvroShort" )); +executor.getContextAlbum("AvroIntegerAlbum" ).put("AvroInteger" , executor.inFields.get("AvroInteger" )); +executor.getContextAlbum("AvroLongAlbum" ).put("AvroLong" , executor.inFields.get("AvroLong" )); +executor.getContextAlbum("AvroFloatAlbum" ).put("AvroFloat" , executor.inFields.get("AvroFloat" )); +executor.getContextAlbum("AvroDoubleAlbum" ).put("AvroDouble" , executor.inFields.get("AvroDouble" )); +executor.getContextAlbum("AvroStringAlbum" ).put("AvroString" , executor.inFields.get("AvroString" )); executor.getContextAlbum("AvroMapAlbum" ).put("AvroMap" , executor.inFields.get("AvroMap" )); executor.getContextAlbum("AvroArrayAlbum" ).put("AvroArray" , executor.inFields.get("AvroArray" )); executor.getContextAlbum("CustomBooleanAlbum").put("CustomBoolean", executor.inFields.get("CustomBoolean")); @@ -488,11 +487,8 @@ avroString = avroString + " added to end of string"; customBoolean.put("flag", !customBoolean.get("flag")); customByte .put("byteValue" , customByte .get("byteValue" ) + 1); customInteger.put("intValue" , customInteger.get("intValue" ) + 1); -customLong .put("longValue" , new javaLongType (customLong .get("longValue" ) + 1)); -customFloat .put("floatValue" , new javaFloatType(customFloat.get("floatValue") + 1.0)); customDouble .put("doubleValue", customDouble .get("doubleValue") + 1.0); customString .put("stringValue", customString .get("stringValue") + " added to end of string"); -customALong .put("longValue" , new javaLongType (customALong.get("longValue" ) + 1)); customDate0.put("year", 1922); customDate0.put("month", 12); @@ -555,8 +551,6 @@ executor.outFields.put("CustomDate2" , executor.getContextAlbum("CustomDate2Alb executor.outFields.put("CustomSet" , executor.getContextAlbum("CustomSetAlbum" ).get("CustomSet" )); executor.outFields.put("CustomMap" , executor.getContextAlbum("CustomMapAlbum" ).get("CustomMap" )); -executor.logger.debug(executor.outFields); - var returnValueType = Java.type("java.lang.Boolean"); var returnValue = new returnValueType(true); diff --git a/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyJavaEventContext.apex b/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyJavaEventContext.apex index e978f15bb..2a36c4fa1 100644 --- a/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyJavaEventContext.apex +++ b/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyJavaEventContext.apex @@ -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. @@ -181,9 +182,7 @@ task contextref create name=Test_Task albumName=CustomSetAlbum task contextref create name=Test_Task albumName=CustomMapAlbum task logic create name=Test_Task logicFlavour=JAVASCRIPT logic=LS -executor.logger.debug(executor.subject.id); - -executor.logger.debug(executor.inFields); +executor.logger.debug(executor.getSubject().getId()); executor.getContextAlbum("JavaBooleanAlbum" ).put("JavaBoolean" , executor.inFields.get("JavaBoolean" )); executor.getContextAlbum("JavaByteAlbum" ).put("JavaByte" , executor.inFields.get("JavaByte" )); @@ -239,13 +238,13 @@ javaFloat += 0.99; javaDouble += 0.99; javaString = javaString + " added to end of string"; customBoolean.setFlag(!customBoolean); -customByte .setByteValue (customByte .getByteValue() + 1); -customInteger.setIntValue (customInteger.getIntValue() + 1); -customLong .setLongValue (customLong .getLongValue() + 1); -customFloat .setFloatValue (customFloat .getFloatValue() + 1); -customDouble .setDoubleValue(customDouble .getDoubleValue() + 1); +customByte .setByteValue (customByte .getIncrementedByteValue()); +customInteger.setIntValue (customInteger.getIncrementedIntValue()); +customLong .setLongValue (customLong .getIncrementedLongValue()); +customFloat .setFloatValue (customFloat .getIncrementedFloatValue()); +customDouble .setDoubleValue(customDouble .getIncrementedDoubleValue()); customString .setStringValue(customString .getStringValue() + " added to end of string"); -customJLong .setLongValue (customJLong .getLongValue() + 1); +customJLong .setLongValue (customJLong .getIncrementedLongValue()); customDate0Type = Java.type("org.onap.policy.apex.context.test.concepts.TestContextDateItem"); customDate0 = new customDate0Type(1499868391); @@ -310,8 +309,6 @@ executor.outFields.put("CustomDate2" , executor.getContextAlbum("CustomDate2Alb executor.outFields.put("CustomSet" , executor.getContextAlbum("CustomSetAlbum" ).get("CustomSet" )); executor.outFields.put("CustomMap" , executor.getContextAlbum("CustomMapAlbum" ).get("CustomMap" )); -executor.logger.debug(executor.outFields); - var returnValueType = Java.type("java.lang.Boolean"); var returnValue = new returnValueType(true); diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java index 88d99a27d..9c7143ef1 100644 --- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java +++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java @@ -84,8 +84,8 @@ public class CommandLineEditorEventsContextTest { final int logCharCount = logString.replaceAll(SPACES, EMPTY_STRING).length(); final int modelCharCount = modelString.replaceAll(SPACES, EMPTY_STRING).length(); - assertEquals(25962, logCharCount); - assertEquals(46189, modelCharCount); + assertEquals(25996, logCharCount); + assertEquals(46162, modelCharCount); } /** @@ -114,8 +114,8 @@ public class CommandLineEditorEventsContextTest { final int logCharCount = logString.replaceAll(SPACES, EMPTY_STRING).length(); final int modelCharCount = modelString.replaceAll(SPACES, EMPTY_STRING).length(); - assertEquals(30407, logCharCount); - assertEquals(53022, modelCharCount); + assertEquals(30154, logCharCount); + assertEquals(52690, modelCharCount); } diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java index e27c62f9a..26753a821 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.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. @@ -48,6 +49,7 @@ import org.slf4j.ext.XLoggerFactory; * * @author Sven van der Meer (sven.van.der.meer@ericsson.com) */ +@Getter public class StateFinalizerExecutionContext { /** * Logger for state finalizer execution, state finalizer logic can use this field to access and log to Apex logging. diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java index 6c670b9d8..0b99c4356 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContext.java @@ -28,8 +28,10 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.TreeMap; + import lombok.Getter; import lombok.Setter; + import org.onap.policy.apex.context.ContextAlbum; import org.onap.policy.apex.context.ContextRuntimeException; import org.onap.policy.apex.core.engine.context.ApexInternalContext; @@ -49,6 +51,7 @@ import org.slf4j.ext.XLoggerFactory; * * @author Sven van der Meer (sven.van.der.meer@ericsson.com) */ +@Getter public class TaskExecutionContext { // Logger for task execution private static final XLogger EXECUTION_LOGGER = @@ -165,7 +168,7 @@ public class TaskExecutionContext { */ private void populateParameters(Map<String, AxTaskParameter> taskParameters) { taskParameters.entrySet().forEach(taskParamEntry -> parameters.put(taskParamEntry.getKey(), - taskParamEntry.getValue().getTaskParameterValue())); + taskParamEntry.getValue().getTaskParameterValue())); } /** diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java index 8d83e7645..7cfb6348e 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.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. @@ -42,12 +43,13 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * Container class for the execution context for Task Selection logic executions in a task being - * executed in an Apex engine. The task must have easy access to the state definition, the incoming - * and outgoing event contexts, as well as the policy, global, and external context. + * Container class for the execution context for Task Selection logic executions in a task being executed in an Apex + * engine. The task must have easy access to the state definition, the incoming and outgoing event contexts, as well as + * the policy, global, and external context. * * @author Sven van der Meer (sven.van.der.meer@ericsson.com) */ +@Getter public class TaskSelectionExecutionContext { // Logger for task execution private static final XLogger EXECUTION_LOGGER = @@ -70,21 +72,19 @@ public class TaskSelectionExecutionContext { public final Long executionId; /** - * The incoming fields from the trigger event for the state. The task selection logic can access - * these fields to decide what task to select for the state. + * The incoming fields from the trigger event for the state. The task selection logic can access these fields to + * decide what task to select for the state. */ public final Map<String, Object> inFields; /** - * The task that the task selection logic has selected for a state. The task selection logic - * sets this field in its logic prior to executing and the Apex engine executes this task as the - * task for this state. + * The task that the task selection logic has selected for a state. The task selection logic sets this field in its + * logic prior to executing and the Apex engine executes this task as the task for this state. */ public final AxArtifactKey selectedTask; /** - * Logger for task selection execution, task selection logic can use this field to access and - * log to Apex logging. + * 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; @@ -110,8 +110,7 @@ public class TaskSelectionExecutionContext { * @param axState the state definition that is the subject of execution * @param incomingEvent the incoming event for the state * @param outgoingKey the outgoing key for the task to execute in this state - * @param internalContext the execution context of the Apex engine in which the task is being - * executed + * @param internalContext the execution context of the Apex engine in which the task is being executed */ public TaskSelectionExecutionContext(final TaskSelectExecutor taskSelectExecutor, final long executionId, final AxState axState, final EnEvent incomingEvent, final AxArtifactKey outgoingKey, @@ -161,8 +160,7 @@ public class TaskSelectionExecutionContext { * * @param contextAlbumName The context album name * @return The context albumxxxxxx - * @throws ContextRuntimeException if the context album does not exist on the state for this - * executor + * @throws ContextRuntimeException if the context album does not exist on the state for this executor */ public ContextAlbum getContextAlbum(final String contextAlbumName) { // Find the context album diff --git a/packages/apex-pdp-docker/src/main/docker/Dockerfile b/packages/apex-pdp-docker/src/main/docker/Dockerfile index c2b9c1e94..ffb6acd05 100644 --- a/packages/apex-pdp-docker/src/main/docker/Dockerfile +++ b/packages/apex-pdp-docker/src/main/docker/Dockerfile @@ -21,7 +21,7 @@ # # Docker file to build an image that runs APEX on Java 11 or better in alpine # -FROM onap/policy-jre-alpine +FROM onap/policy-jre-alpine:2.0.1 LABEL maintainer="Policy Team" diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml new file mode 100644 index 000000000..443f8f173 --- /dev/null +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml @@ -0,0 +1,76 @@ +<?xml version="1.0"?> +<!-- + ============LICENSE_START======================================================= + 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========================================================= +--> +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId> + <artifactId>plugins-event-carrier</artifactId> + <version>2.3.0-SNAPSHOT</version> + </parent> + + <artifactId>plugins-event-carrier-grpc</artifactId> + <name>${project.artifactId}</name> + <description>[${project.parent.artifactId}] Plugin for handling GRPC requests and responses</description> + <dependencies> + <dependency> + <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> + <artifactId>cds</artifactId> + <version>${version.policy.models}</version> + </dependency> + <dependency> + <groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId> + <artifactId>actor.cds</artifactId> + <version>${version.policy.models}</version> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <profiles> + <profile> + <id>apexSite</id> + <activation> + <property> + <name>apexSite</name> + </property> + </activation> + <properties> + <adsite-plugins-event-carrier-grpc-dir>${project.basedir}/src</adsite-plugins-event-carrier-grpc-dir> + </properties> + <distributionManagement> + <site> + <id>${project.artifactId}-site</id> + <url>${apex.adsite.prefix}/modules/plugins/plugins-event/${project.parent.artifactId}/${project.artifactId}/</url> + </site> + </distributionManagement> + </profile> + </profiles> +</project> diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumer.java new file mode 100644 index 000000000..7333c8a05 --- /dev/null +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumer.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * 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========================================================= + */ + +package org.onap.policy.apex.plugins.event.carrier.grpc; + +import org.onap.policy.apex.service.engine.event.ApexEventException; +import org.onap.policy.apex.service.engine.event.ApexEventReceiver; +import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; +import org.onap.policy.apex.service.engine.event.ApexPluginsEventConsumer; +import org.onap.policy.apex.service.engine.event.PeeredReference; +import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; +import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode; + +/** + * This class implements an Apex gRPC consumer. It is not expected to receive events using gRPC. + * So, initializing a gRPC consumer will result in error. + * + * @author Ajith Sreekumar (ajith.sreekumar@est.tech) + */ +public class ApexGrpcConsumer extends ApexPluginsEventConsumer { + + private static final String GRPC_CONSUMER_ERROR_MSG = + "A gRPC Consumer may not be specified. Only sending events is possible using gRPC"; + + @Override + public void init(final String consumerName, final EventHandlerParameters consumerParameters, + final ApexEventReceiver incomingEventReceiver) throws ApexEventException { + throw new ApexEventException(GRPC_CONSUMER_ERROR_MSG); + } + + @Override + public void run() { + throw new ApexEventRuntimeException(GRPC_CONSUMER_ERROR_MSG); + } + + @Override + public void start() { + throw new ApexEventRuntimeException(GRPC_CONSUMER_ERROR_MSG); + } + + @Override + public void stop() { + throw new ApexEventRuntimeException(GRPC_CONSUMER_ERROR_MSG); + } + + @Override + public PeeredReference getPeeredReference(EventHandlerPeeredMode peeredMode) { + throw new ApexEventRuntimeException(GRPC_CONSUMER_ERROR_MSG); + } + + @Override + public void setPeeredReference(EventHandlerPeeredMode peeredMode, PeeredReference peeredReference) { + throw new ApexEventRuntimeException(GRPC_CONSUMER_ERROR_MSG); + } +} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducer.java new file mode 100644 index 000000000..380ae1274 --- /dev/null +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducer.java @@ -0,0 +1,152 @@ +/*- + * ============LICENSE_START======================================================= + * 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========================================================= + */ + +package org.onap.policy.apex.plugins.event.carrier.grpc; + +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.util.JsonFormat; +import java.util.Properties; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; +import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType; +import org.onap.ccsdk.cds.controllerblueprints.common.api.Status; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput.Builder; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; +import org.onap.policy.apex.service.engine.event.ApexEventException; +import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; +import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer; +import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; +import org.onap.policy.cds.api.CdsProcessorListener; +import org.onap.policy.cds.client.CdsProcessorGrpcClient; +import org.onap.policy.cds.properties.CdsServerProperties; +import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Concrete implementation of an Apex gRPC plugin that manages to send a GRPC request. + * + * @author Ajith Sreekumar(ajith.sreekumar@est.tech) + * + */ +public class ApexGrpcProducer extends ApexPluginsEventProducer implements CdsProcessorListener { + private static final Logger LOGGER = LoggerFactory.getLogger(ApexGrpcProducer.class); + + private CdsServerProperties props; + // The gRPC client + private CdsProcessorGrpcClient client; + + private AtomicReference<ExecutionServiceOutput> cdsResponse = new AtomicReference<>(); + + /** + * {@inheritDoc}. + */ + @Override + public void init(final String producerName, final EventHandlerParameters producerParameters) + throws ApexEventException { + this.name = producerName; + + // Check and get the gRPC Properties + if (!(producerParameters.getCarrierTechnologyParameters() instanceof GrpcCarrierTechnologyParameters)) { + final String errorMessage = + "Specified producer properties are not applicable to gRPC producer (" + this.name + ")"; + throw new ApexEventException(errorMessage); + } + GrpcCarrierTechnologyParameters grpcProducerProperties = + (GrpcCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); + + client = makeGrpcClient(grpcProducerProperties); + } + + private CdsProcessorGrpcClient makeGrpcClient(GrpcCarrierTechnologyParameters grpcProducerProperties) { + props = new CdsServerProperties(); + props.setHost(grpcProducerProperties.getHost()); + props.setPort(grpcProducerProperties.getPort()); + props.setUsername(grpcProducerProperties.getUsername()); + props.setPassword(grpcProducerProperties.getPassword()); + props.setTimeout(grpcProducerProperties.getTimeout()); + + return new CdsProcessorGrpcClient(this, props); + } + + /** + * {@inheritDoc}. + */ + @Override + public void sendEvent(final long executionId, final Properties executionProperties, final String eventName, + final Object event) { + + ExecutionServiceInput executionServiceInput; + Builder builder = ExecutionServiceInput.newBuilder(); + try { + JsonFormat.parser().ignoringUnknownFields().merge((String) event, builder); + executionServiceInput = builder.build(); + } catch (InvalidProtocolBufferException e) { + throw new ApexEventRuntimeException( + "Incoming Event cannot be converted to ExecutionServiceInput type for gRPC request." + e.getMessage()); + } + try { + CountDownLatch countDownLatch = client.sendRequest(executionServiceInput); + if (!countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS)) { + cdsResponse.set(ExecutionServiceOutput.newBuilder().setStatus(Status.newBuilder() + .setErrorMessage(CdsActorConstants.TIMED_OUT).setEventType(EventType.EVENT_COMPONENT_FAILURE)) + .build()); + LOGGER.error("gRPC Request timed out."); + } + } catch (InterruptedException e) { + LOGGER.error("gRPC request failed. {}", e.getMessage()); + cdsResponse.set(ExecutionServiceOutput.newBuilder().setStatus(Status.newBuilder() + .setErrorMessage(CdsActorConstants.INTERRUPTED).setEventType(EventType.EVENT_COMPONENT_FAILURE)) + .build()); + Thread.currentThread().interrupt(); + } + + if (!EventType.EVENT_COMPONENT_EXECUTED.equals(cdsResponse.get().getStatus().getEventType())) { + String errorMessage = "Sending event \"" + eventName + "\" by " + this.name + " to CDS failed, " + + "response from CDS:\n" + cdsResponse.get(); + throw new ApexEventRuntimeException(errorMessage); + } + } + + /** + * {@inheritDoc}. + */ + @Override + public void stop() { + client.close(); + } + + @Override + public void onMessage(ExecutionServiceOutput message) { + LOGGER.info("Received notification from CDS: {}", message); + cdsResponse.set(message); + } + + @Override + public void onError(Throwable throwable) { + String errorMsg = throwable.getLocalizedMessage(); + cdsResponse.set(ExecutionServiceOutput.newBuilder() + .setStatus(Status.newBuilder().setErrorMessage(errorMsg).setEventType(EventType.EVENT_COMPONENT_FAILURE)) + .build()); + LOGGER.error("Failed processing blueprint {} {}", errorMsg, throwable); + } +} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/GrpcCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/GrpcCarrierTechnologyParameters.java new file mode 100644 index 000000000..59db16743 --- /dev/null +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/GrpcCarrierTechnologyParameters.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * 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========================================================= + */ + +package org.onap.policy.apex.plugins.event.carrier.grpc; + +import lombok.Getter; +import lombok.Setter; +import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters; +import org.onap.policy.common.parameters.annotations.Max; +import org.onap.policy.common.parameters.annotations.Min; +import org.onap.policy.common.parameters.annotations.NotNull; + +// @formatter:off +/** + * Apex parameters for gRPC as an event carrier technology. + * + * <p>The parameters for this plugin are: + * <ol> + * <li>host: The host on which CDS is running. This parameter is mandatory + * <li>port: The port on the CDS host to connect to for CDS. This parameter is mandatory. + * <li>username: The username for basic authentication to connect to CDS. This parameter is mandatory. + * <li>password: The password for basic authentication to connect to CDS. This parameter is mandatory. + * <li>timeout: The timeout in seconds for CDS requests. This parameter is mandatory. + * </ol> + * + * @author Ajith Sreekumar(ajith.sreekumar@est.tech) + */ +//@formatter:on +@Getter +@Setter +public class GrpcCarrierTechnologyParameters extends CarrierTechnologyParameters { + // @formatter:off + private static final int MIN_USER_PORT = 1024; + private static final int MAX_USER_PORT = 65535; + + /** The label of this carrier technology. */ + public static final String GRPC_CARRIER_TECHNOLOGY_LABEL = "GRPC"; + + /** The producer plugin class for the grpc carrier technology. */ + public static final String GRPC_EVENT_PRODUCER_PLUGIN_CLASS = ApexGrpcProducer.class.getName(); + + /** The consumer plugin class for the gRPC carrier technology. */ + public static final String GRPC_EVENT_CONSUMER_PLUGIN_CLASS = ApexGrpcConsumer.class.getName(); + + @Min(value = 1) + private int timeout; + + @Min(value = MIN_USER_PORT) + @Max(value = MAX_USER_PORT) + private int port; + + @NotNull + private String host; + + @NotNull + private String username; + + @NotNull + private String password; + + + /** + * Constructor to create a gRPC carrier technology parameters instance and register the instance with the + * parameter service. + */ + public GrpcCarrierTechnologyParameters() { + super(); + // Set the carrier technology properties for the gRPC carrier technology + this.setLabel(GRPC_CARRIER_TECHNOLOGY_LABEL); + this.setEventProducerPluginClass(GRPC_EVENT_PRODUCER_PLUGIN_CLASS); + this.setEventConsumerPluginClass(GRPC_EVENT_CONSUMER_PLUGIN_CLASS); + } +} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/package-info.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/package-info.java new file mode 100644 index 000000000..77d26266d --- /dev/null +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/package-info.java @@ -0,0 +1,21 @@ +/*- + * ============LICENSE_START======================================================= + * 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========================================================= + */ + +package org.onap.policy.apex.plugins.event.carrier.grpc; diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java new file mode 100644 index 000000000..dc5cc3809 --- /dev/null +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * 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========================================================= + */ + +package org.onap.policy.apex.plugins.event.carrier.grpc; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.apex.service.engine.event.ApexEventException; +import org.onap.policy.apex.service.engine.event.ApexEventReceiver; +import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; +import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode; + +public class ApexGrpcConsumerTest { + ApexGrpcConsumer grpcConsumer = null; + EventHandlerParameters consumerParameters = null; + ApexEventReceiver incomingEventReceiver = null; + + private static final String GRPC_CONSUMER_ERROR_MSG = + "A gRPC Consumer may not be specified. Only sending events is possible using gRPC"; + + /** + * Set up testing. + * + * @throws ApexEventException on test set up errors. + */ + @Before + public void setUp() throws ApexEventException { + grpcConsumer = new ApexGrpcConsumer(); + consumerParameters = new EventHandlerParameters(); + consumerParameters.setCarrierTechnologyParameters(new GrpcCarrierTechnologyParameters() {}); + } + + @Test + public void testInit() { + assertThatThrownBy(() -> { + grpcConsumer.init("TestApexGrpcConsumer", consumerParameters, incomingEventReceiver); + }).hasMessage(GRPC_CONSUMER_ERROR_MSG); + } + + @Test + public void testStart() { + assertThatThrownBy(() -> { + grpcConsumer.start(); + }).hasMessage(GRPC_CONSUMER_ERROR_MSG); + } + + @Test + public void testGetName() { + assertEquals(null, new ApexGrpcConsumer().getName()); + } + + @Test + public void testGetPeeredReference() { + assertThatThrownBy(() -> { + grpcConsumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR); + }).hasMessage(GRPC_CONSUMER_ERROR_MSG); + } + + @Test + public void testSetPeeredReference() { + assertThatThrownBy(() -> { + grpcConsumer.setPeeredReference(null, null); + }).hasMessage(GRPC_CONSUMER_ERROR_MSG); + } + + @Test() + public void testStop() { + assertThatThrownBy(() -> { + new ApexGrpcConsumer().stop(); + }).hasMessage(GRPC_CONSUMER_ERROR_MSG); + } + +} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java new file mode 100644 index 000000000..53d191e14 --- /dev/null +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java @@ -0,0 +1,98 @@ +/*- + * ============LICENSE_START======================================================= + * 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========================================================= + */ + +package org.onap.policy.apex.plugins.event.carrier.grpc; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.spy; + +import java.nio.file.Files; +import java.nio.file.Paths; +import org.assertj.core.api.Assertions; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.policy.apex.service.engine.event.ApexEventException; +import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; +import org.onap.policy.cds.client.CdsProcessorGrpcClient; + +@RunWith(MockitoJUnitRunner.class) +public class ApexGrpcProducerTest { + private static final String HOST = "localhost"; + @Mock + private CdsProcessorGrpcClient grpcClient; + private ApexGrpcProducer apexGrpcProducer = spy(new ApexGrpcProducer()); + @Mock + private EventHandlerParameters eventHandlerParameters; + + /** + * Set up testing. + * + * @throws ApexEventException on test set up errors. + */ + @Before + public void setUp() throws ApexEventException { + populateEventHandlerParameters(HOST, 5); + } + + @Test(expected = ApexEventException.class) + public void testInit_fail() throws ApexEventException { + apexGrpcProducer.init("TestApexGrpcProducer", new EventHandlerParameters()); + } + + @Test + public void testInit_pass() { + // should not throw an exception + Assertions.assertThatCode(() -> apexGrpcProducer.init("TestApexGrpcProducer", eventHandlerParameters)) + .doesNotThrowAnyException(); + } + + @Test + public void testStop() throws ApexEventException { + apexGrpcProducer.init("TestApexGrpcProducer", eventHandlerParameters); + // should not throw an exception + Assertions.assertThatCode(() -> apexGrpcProducer.stop()).doesNotThrowAnyException(); + } + + @Test + public void testSendEvent() throws ApexEventException { + apexGrpcProducer.init("TestApexGrpcProducer", eventHandlerParameters); + assertThatThrownBy(() -> { + apexGrpcProducer.sendEvent(123, null, "grpcEvent", + Files.readString(Paths.get("src/test/resources/executionServiceInputEvent.json"))); + }).hasMessageContaining("UNAVAILABLE: io exception"); + } + + private void populateEventHandlerParameters(String host, int timeout) { + eventHandlerParameters = new EventHandlerParameters(); + GrpcCarrierTechnologyParameters params = new GrpcCarrierTechnologyParameters(); + params.setLabel("GRPC"); + params.setEventProducerPluginClass(ApexGrpcProducer.class.getName()); + params.setEventConsumerPluginClass(ApexGrpcConsumer.class.getName()); + params.setHost(host); + params.setPort(3214); + params.setUsername("dummyUser"); + params.setPassword("dummyPassword"); + params.setTimeout(timeout); + eventHandlerParameters.setCarrierTechnologyParameters(params); + } +} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/GrpcCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/GrpcCarrierTechnologyParametersTest.java new file mode 100644 index 000000000..a3994c29e --- /dev/null +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/GrpcCarrierTechnologyParametersTest.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * 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========================================================= + */ + +package org.onap.policy.apex.plugins.event.carrier.grpc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.common.parameters.GroupValidationResult; + +public class GrpcCarrierTechnologyParametersTest { + + private static final String USERNAME = "username"; + private static final String PASSWORD = "password"; + private static final String HOST = "localhost"; + + private GrpcCarrierTechnologyParameters params; + + @Before + public void setUp() { + params = new GrpcCarrierTechnologyParameters(); + } + + @Test + public void testGrpcCarrierTechnologyParameters_invalid() { + GroupValidationResult result = params.validate(); + assertFalse(result.isValid()); + assertTrue(result.getResult().contains("field \"timeout\" type \"int\" value \"0\" INVALID, must be >= 1")); + assertTrue(result.getResult().contains("field \"port\" type \"int\" value \"0\" INVALID, must be >= 1024")); + assertTrue( + result.getResult().contains("field \"host\" type \"java.lang.String\" value \"null\" INVALID, is null")); + assertTrue(result.getResult() + .contains("field \"username\" type \"java.lang.String\" value \"null\" INVALID, is null")); + assertTrue(result.getResult() + .contains("field \"password\" type \"java.lang.String\" value \"null\" INVALID, is null")); + assertTrue(result.getResult().contains("")); + assertTrue(result.getResult().contains("")); + } + + @Test + public void testGrpcCarrierTechnologyParameters_valid() { + assertEquals("GRPC", params.getName()); + assertEquals(ApexGrpcConsumer.class.getName(), params.getEventConsumerPluginClass()); + assertEquals(ApexGrpcProducer.class.getName(), params.getEventProducerPluginClass()); + + params.setHost(HOST); + params.setPassword(PASSWORD); + params.setPort(2233); + params.setTimeout(1000); + params.setUsername(USERNAME); + GroupValidationResult result = params.validate(); + assertTrue(result.isValid()); + } + + @Test + public void testGrpcCarrierTechnologyParameters_invalid_values() { + params.setHost(HOST); + params.setPassword(PASSWORD); + params.setTimeout(1000); + params.setUsername(USERNAME); + + params.setPort(23); // invalid value + GroupValidationResult result = params.validate(); + assertFalse(result.isValid()); + assertTrue(result.getResult().contains("field \"port\" type \"int\" value \"23\" INVALID, must be >= 1024")); + } +} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/resources/executionServiceInputEvent.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/resources/executionServiceInputEvent.json new file mode 100644 index 000000000..1054af14a --- /dev/null +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/resources/executionServiceInputEvent.json @@ -0,0 +1,25 @@ +{ + "actionIdentifiers": { + "actionName": "actionName", + "blueprintName": "bluePrintName", + "blueprintVersion": "1.0.0", + "mode": "sync" + }, + "commonHeader": { + "originatorId": "sdnc", + "requestId": "1234567", + "subRequestId": "subReqId" + }, + "payload": { + "config-assign-request": { + "resolution-key": "RES-KEY", + "config-assign-properties": { + "service-instance-id": "sid12", + "pnf-id": "pnf-id", + "pnf-address": "1.2.3.4", + "service-uuid": "service-uuid", + "customization-uuid": "customization-uuid" + } + } + } +} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java index ff300423f..f70a3c1ac 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java @@ -74,7 +74,6 @@ public class ApexJmsConsumer extends ApexPluginsEventConsumer implements Message final String errorMessage = "specified consumer properties of type \"" + consumerParameters.getCarrierTechnologyParameters().getClass().getName() + "\" are not applicable to a JMS consumer"; - LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } jmsConsumerProperties = (JmsCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); @@ -95,7 +94,6 @@ public class ApexJmsConsumer extends ApexPluginsEventConsumer implements Message final String errorMessage = "lookup of JMS connection factory \"" + jmsConsumerProperties.getConnectionFactory() + "\" failed for JMS consumer properties \"" + jmsConsumerProperties.getJmsConsumerProperties() + "\""; - LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -112,7 +110,6 @@ public class ApexJmsConsumer extends ApexPluginsEventConsumer implements Message final String errorMessage = "lookup of JMS topic \"" + jmsConsumerProperties.getConsumerTopic() + "\" failed for JMS consumer properties \"" + jmsConsumerProperties.getJmsConsumerProperties() + "\""; - LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -124,7 +121,6 @@ public class ApexJmsConsumer extends ApexPluginsEventConsumer implements Message } catch (final Exception e) { final String errorMessage = "connection to the JMS server failed for JMS properties \"" + jmsConsumerProperties.getJmsConsumerProperties() + "\""; - LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java index 46b503e04..393ea7310 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.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. @@ -88,7 +88,6 @@ public class ApexJmsProducer implements ApexEventProducer { if (!(producerParameters.getCarrierTechnologyParameters() instanceof JmsCarrierTechnologyParameters)) { final String errorMessage = "specified producer properties are not applicable to a JMS producer (" + this.name + ")"; - LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } jmsProducerProperties = (JmsCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); @@ -110,7 +109,6 @@ public class ApexJmsProducer implements ApexEventProducer { final String errorMessage = "lookup of JMS connection factory \"" + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")"; - LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -128,7 +126,6 @@ public class ApexJmsProducer implements ApexEventProducer { final String errorMessage = "lookup of JMS topic \"" + jmsProducerProperties.getProducerTopic() + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJmsProducerProperties() + FOR_PRODUCER_TAG + this.name + ")"; - LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -140,7 +137,6 @@ public class ApexJmsProducer implements ApexEventProducer { } catch (final Exception e) { final String errorMessage = "connection to JMS server failed for JMS properties \"" + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")"; - LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -150,7 +146,6 @@ public class ApexJmsProducer implements ApexEventProducer { } catch (final Exception e) { final String errorMessage = "creation of session to JMS server failed for JMS properties \"" + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")"; - LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -161,7 +156,6 @@ public class ApexJmsProducer implements ApexEventProducer { final String errorMessage = "creation of producer for sending events " + "to JMS server failed for JMS properties \"" + jmsProducerProperties.getJmsConsumerProperties() + "\""; - LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java index aa8185fdb..a3d273dfd 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java @@ -22,9 +22,9 @@ package org.onap.policy.apex.plugins.event.carrier.restclient; import java.util.Properties; - import java.util.regex.Matcher; import java.util.regex.Pattern; + import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; @@ -35,6 +35,7 @@ import org.onap.policy.apex.service.engine.event.ApexEventException; import org.onap.policy.apex.service.engine.event.ApexEventReceiver; import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; import org.onap.policy.apex.service.engine.event.ApexPluginsEventConsumer; +import org.onap.policy.apex.service.parameters.carriertechnology.RestPluginCarrierTechnologyParameters; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -86,10 +87,10 @@ public class ApexRestClientConsumer extends ApexPluginsEventConsumer { // Check if the HTTP method has been set if (restConsumerProperties.getHttpMethod() == null) { - restConsumerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.GET); + restConsumerProperties.setHttpMethod(RestPluginCarrierTechnologyParameters.HttpMethod.GET); } - if (!RestClientCarrierTechnologyParameters.HttpMethod.GET.equals(restConsumerProperties.getHttpMethod())) { + if (!RestPluginCarrierTechnologyParameters.HttpMethod.GET.equals(restConsumerProperties.getHttpMethod())) { final String errorMessage = "specified HTTP method of \"" + restConsumerProperties.getHttpMethod() + "\" is invalid, only HTTP method \"GET\" " + "is supported for event reception on REST client consumer (" + this.name + ")"; diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java index 3506ace3c..cf3500065 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java @@ -21,8 +21,6 @@ package org.onap.policy.apex.plugins.event.carrier.restclient; -import java.util.EnumMap; -import java.util.Map; import java.util.Optional; import java.util.Properties; import java.util.Set; @@ -33,12 +31,10 @@ import javax.ws.rs.client.Entity; import javax.ws.rs.core.Response; import org.onap.policy.apex.service.engine.event.ApexEventException; -import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer; import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; -import org.onap.policy.apex.service.engine.event.PeeredReference; -import org.onap.policy.apex.service.engine.event.SynchronousEventCache; +import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer; +import org.onap.policy.apex.service.parameters.carriertechnology.RestPluginCarrierTechnologyParameters; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; -import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -77,14 +73,14 @@ public class ApexRestClientProducer extends ApexPluginsEventProducer { // Check if the HTTP method has been set if (restProducerProperties.getHttpMethod() == null) { - restProducerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST); + restProducerProperties.setHttpMethod(RestPluginCarrierTechnologyParameters.HttpMethod.POST); } - if (!RestClientCarrierTechnologyParameters.HttpMethod.POST.equals(restProducerProperties.getHttpMethod()) - && !RestClientCarrierTechnologyParameters.HttpMethod.PUT + if (!RestPluginCarrierTechnologyParameters.HttpMethod.POST.equals(restProducerProperties.getHttpMethod()) + && !RestPluginCarrierTechnologyParameters.HttpMethod.PUT .equals(restProducerProperties.getHttpMethod())) { final String errorMessage = "specified HTTP method of \"" + restProducerProperties.getHttpMethod() - + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supproted " + + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supported " + "for event sending on REST client producer (" + this.name + ")"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); @@ -97,6 +93,7 @@ public class ApexRestClientProducer extends ApexPluginsEventProducer { /** * {@inheritDoc}. */ + @Override public void sendEvent(final long executionId, final Properties executionProperties, final String eventName, final Object event) { super.sendEvent(executionId, executionProperties, eventName, event); @@ -106,15 +103,17 @@ public class ApexRestClientProducer extends ApexPluginsEventProducer { Set<String> names = restProducerProperties.getKeysFromUrl(); Set<String> inputProperty = executionProperties.stringPropertyNames(); + // @formatter:off names.stream().map(Optional::of).forEach(op -> op.filter(inputProperty::contains) .orElseThrow(() -> new ApexEventRuntimeException( - "key\"" + op.get() + "\"specified on url \"" + restProducerProperties.getUrl() - + "\"not found in execution properties passed by the current policy")) + "key \"" + op.get() + "\" specified on url \"" + restProducerProperties.getUrl() + + "\" not found in execution properties passed by the current policy")) ); untaggedUrl = names.stream().reduce(untaggedUrl, (acc, str) -> acc.replace("{" + str + "}", (String) executionProperties.get(str))); + // @formatter:on } // Send the event as a REST request @@ -131,7 +130,7 @@ public class ApexRestClientProducer extends ApexPluginsEventProducer { if (LOGGER.isTraceEnabled()) { LOGGER.trace("event sent from engine using {} to URL {} with HTTP {} : {} and response {} ", this.name, - untaggedUrl, restProducerProperties.getHttpMethod(), event, response); + untaggedUrl, restProducerProperties.getHttpMethod(), event, response); } } @@ -152,7 +151,7 @@ public class ApexRestClientProducer extends ApexPluginsEventProducer { */ private Response sendEventAsRestRequest(final String untaggedUrl, final String event) { // We have already checked that it is a PUT or POST request - if (RestClientCarrierTechnologyParameters.HttpMethod.POST.equals(restProducerProperties.getHttpMethod())) { + if (RestPluginCarrierTechnologyParameters.HttpMethod.POST.equals(restProducerProperties.getHttpMethod())) { return client.target(untaggedUrl).request("application/json") .headers(restProducerProperties.getHttpHeadersAsMultivaluedMap()).post(Entity.json(event)); } else { diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java index b67a339aa..ce688d62d 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.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. @@ -25,8 +25,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; -import ch.qos.logback.classic.Level; - import java.util.Properties; import javax.ws.rs.client.Client; @@ -47,6 +45,8 @@ import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMo import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import ch.qos.logback.classic.Level; + /** * Test the ApexRestClientProducer class. * @@ -77,8 +77,8 @@ public class ApexRestClientProducerTest { fail("test should throw an exception here"); } catch (ApexEventException e) { assertEquals( - "specified producer properties are not applicable to REST client producer (RestClientProducer)", - e.getMessage()); + "specified producer properties are not applicable to REST client producer (RestClientProducer)", + e.getMessage()); } RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters(); @@ -89,8 +89,10 @@ public class ApexRestClientProducerTest { assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.GET, rcctp.getHttpMethod()); fail("test should throw an exception here"); } catch (ApexEventException e) { - assertEquals("specified HTTP method of \"DELETE\" is invalid, only HTTP methods \"POST\" and \"PUT\" " - + "are supproted for event sending on REST client producer (RestClientConsumer)", e.getMessage()); + assertEquals( + "specified HTTP method of \"DELETE\" is invalid, only HTTP methods \"POST\" and \"PUT\" " + + "are supported for event sending on REST client producer (RestClientConsumer)", + e.getMessage()); } rcctp.setHttpMethod(null); @@ -109,7 +111,6 @@ public class ApexRestClientProducerTest { assertEquals(null, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); arcp.stop(); - rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.PUT); arcp.init("RestClientConsumer", producerParameters); assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.PUT, rcctp.getHttpMethod()); @@ -171,7 +172,7 @@ public class ApexRestClientProducerTest { Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl()); arcp.setClient(httpClientMock); - //test property not found + // test property not found rcctp.setUrl("http://some.place2.that.{key}.not/{tag}and.again.{tag}"); Properties properties = new Properties(); properties.put("tag", "exist"); @@ -180,11 +181,9 @@ public class ApexRestClientProducerTest { arcp.stop(); fail("test should throw an exception"); } catch (Exception e) { - assertEquals( - "key\"key\"specified on url " - + "\"http://some.place2.that.{key}.not/{tag}and.again.{tag}\"not found " - + "in execution properties passed by the current policy", - e.getMessage()); + assertEquals("key \"key\" specified on url " + + "\"http://some.place2.that.{key}.not/{tag}and.again.{tag}\" not found " + + "in execution properties passed by the current policy", e.getMessage()); } } @@ -234,8 +233,8 @@ public class ApexRestClientProducerTest { rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST); ApexEventConsumer consumer = new ApexFileEventConsumer(); - SynchronousEventCache cache = new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS, consumer, arcp, - 1000); + SynchronousEventCache cache = + new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS, consumer, arcp, 1000); arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, cache); assertEquals(cache, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); arcp.init("RestClientConsumer", producerParameters); @@ -271,8 +270,8 @@ public class ApexRestClientProducerTest { rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST); ApexEventConsumer consumer = new ApexFileEventConsumer(); - SynchronousEventCache cache = new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS, consumer, arcp, - 1000); + SynchronousEventCache cache = + new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS, consumer, arcp, 1000); arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, cache); assertEquals(cache, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); arcp.init("RestClientConsumer", producerParameters); @@ -320,9 +319,9 @@ public class ApexRestClientProducerTest { fail("test should throw an exception here"); } catch (Exception e) { assertEquals( - "send of event to URL \"http://some.place.that.does.not/exist\" using HTTP \"POST\" " - + "failed with status code 400 and message \"null\", event:\n" + "This is an Event", - e.getMessage()); + "send of event to URL \"http://some.place.that.does.not/exist\" using HTTP \"POST\" " + + "failed with status code 400 and message \"null\", event:\n" + "This is an Event", + e.getMessage()); } } }
\ No newline at end of file diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java index 3e2cd5a94..e166bdc1f 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java @@ -21,16 +21,13 @@ package org.onap.policy.apex.plugins.event.carrier.restrequestor; -import java.util.EnumMap; -import java.util.Map; import java.util.Properties; import org.onap.policy.apex.service.engine.event.ApexEventConsumer; import org.onap.policy.apex.service.engine.event.ApexEventException; -import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer; import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; +import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer; import org.onap.policy.apex.service.engine.event.PeeredReference; -import org.onap.policy.apex.service.engine.event.SynchronousEventCache; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode; import org.slf4j.Logger; @@ -125,8 +122,8 @@ public class ApexRestRequestorProducer extends ApexPluginsEventProducer { // Use the consumer to handle this event final ApexRestRequestorConsumer restRequstConsumer = (ApexRestRequestorConsumer) consumer; - restRequstConsumer.processRestRequest(new ApexRestRequest( - executionId, executionProperties, eventName, event)); + restRequstConsumer + .processRestRequest(new ApexRestRequest(executionId, executionProperties, eventName, event)); eventsSent++; } else { diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/policymodels/RequestorModel.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/policymodels/RequestorModel.json index b6fdc617b..98510d2a5 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/policymodels/RequestorModel.json +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/policymodels/RequestorModel.json @@ -460,7 +460,7 @@ "taskLogic" : { "key" : "TaskLogic", "logicFlavour" : "JAVASCRIPT", - "logic" : "executor.logger.debug(executor.subject.id);\nvar gc = executor.getContextAlbum(\"BasicContextAlbum\");\nexecutor.logger.debug(gc.name);\nexecutor.logger.debug(executor.inFields);\n\nexecutor.logger.debug(executor.eo);\n\nvar returnValue = executor.isTrue;" + "logic" : "executor.logger.debug(executor.subject.getId());\nvar gc = executor.getContextAlbum(\"BasicContextAlbum\");\nexecutor.logger.debug(gc.getName());\nvar returnValue = executor.isTrue;" } } } ] diff --git a/plugins/plugins-event/plugins-event-carrier/pom.xml b/plugins/plugins-event/plugins-event-carrier/pom.xml index cd48929d3..3127c2a77 100644 --- a/plugins/plugins-event/plugins-event-carrier/pom.xml +++ b/plugins/plugins-event/plugins-event-carrier/pom.xml @@ -1,6 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> <!-- ============LICENSE_START======================================================= Copyright (C) 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. @@ -39,7 +41,8 @@ <module>plugins-event-carrier-restclient</module> <module>plugins-event-carrier-restserver</module> <module>plugins-event-carrier-restrequestor</module> - </modules> + <module>plugins-event-carrier-grpc</module> + </modules> <profiles> <profile> diff --git a/plugins/plugins-executor/plugins-executor-javascript/pom.xml b/plugins/plugins-executor/plugins-executor-javascript/pom.xml index 390b803d4..d3d3faac0 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/pom.xml +++ b/plugins/plugins-executor/plugins-executor-javascript/pom.xml @@ -1,6 +1,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 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. @@ -17,7 +18,10 @@ 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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<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> <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId> @@ -29,6 +33,45 @@ <name>${project.artifactId}</name> <description>[${project.parent.artifactId}] Plugin for execution of Javascript logic in Apex</description> + <properties> + <graalvm.version>20.0.0</graalvm.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.graalvm.sdk</groupId> + <artifactId>graal-sdk</artifactId> + <version>${graalvm.version}</version> + </dependency> + <dependency> + <groupId>org.graalvm.truffle</groupId> + <artifactId>truffle-api</artifactId> + <version>${graalvm.version}</version> + </dependency> + <dependency> + <groupId>org.graalvm.js</groupId> + <artifactId>js</artifactId> + <version>${graalvm.version}</version> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.apex-pdp.services</groupId> + <artifactId>services-engine</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> + + </dependencies> + <profiles> <profile> <id>apexSite</id> @@ -48,4 +91,4 @@ </distributionManagement> </profile> </profiles> -</project>
\ No newline at end of file +</project> diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutor.java new file mode 100644 index 000000000..93f6216fc --- /dev/null +++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutor.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * 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========================================================= + */ + +package org.onap.policy.apex.plugins.executor.javascript; + +import org.graalvm.polyglot.Context; +import org.graalvm.polyglot.HostAccess; +import org.graalvm.polyglot.Value; +import org.onap.policy.apex.core.engine.executor.exception.StateMachineException; +import org.onap.policy.apex.model.basicmodel.concepts.AxKey; + +/** + * The Class JavascriptExecutor is the executor for task logic written in Javascript. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class JavascriptExecutor { + // The key of the subject that wants to execute Javascript code + final AxKey subjectKey; + + // The Javascript context + private final Context jsContext; + + /** + * Prepares the executor for processing. + * + * @param subjectKey the key of the subject that is requesting Javascript execution + * @throws StateMachineException thrown when instantiation of the executor fails + */ + public JavascriptExecutor(final AxKey subjectKey) throws StateMachineException { + this.subjectKey = subjectKey; + + // @formatter:off + jsContext = + Context.newBuilder("js") + .allowHostClassLookup(s -> true) + .allowHostAccess(HostAccess.ALL) + .build(); + // @formatter:on + + try { + jsContext.getBindings("js"); + } catch (Exception e) { + jsContext.close(); + throw new StateMachineException( + "prepare: javascript engine failed to initialize properly for \"" + subjectKey.getId() + "\"", e); + } + } + + /** + * Executes the the Javascript code. + * + * @param executionContext the execution context of the subject to be passed to the Javascript context + * @param javascriptCode the Javascript code to execute + * @return true if the Javascript executed properly + * @throws StateMachineException thrown when Javascript execution fails + */ + public boolean execute(final Object executionContext, final String javascriptCode) throws StateMachineException { + try { + // Set up the Javascript engine context + jsContext.getBindings("js").putMember("executor", executionContext); + jsContext.eval("js", javascriptCode); + + } catch (final Exception e) { + throw new StateMachineException("execute: logic failed to run for \"" + subjectKey.getId() + "\"", e); + } + + Value returnValue = jsContext.getBindings("js").getMember("returnValue"); + + if (returnValue == null || returnValue.isNull()) { + throw new StateMachineException( + "execute: logic failed to set a return value for \"" + subjectKey.getId() + "\""); + } + + return returnValue.asBoolean(); + } + + /** + * Cleans up the executor after processing. + * + * @throws StateMachineException thrown when cleanup of the executor fails + */ + public void cleanUp() throws StateMachineException { + try { + jsContext.close(); + } catch (final Exception e) { + throw new StateMachineException( + "cleanUp: executor cleanup failed to close for \"" + subjectKey.getId() + "\"", e); + } + } +} diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java index cd660c807..18a6ef58a 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.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. @@ -24,11 +24,6 @@ package org.onap.policy.apex.plugins.executor.javascript; import java.util.Map; import java.util.Properties; -import javax.script.Compilable; -import javax.script.CompiledScript; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.core.engine.executor.StateFinalizerExecutor; import org.onap.policy.apex.core.engine.executor.exception.StateMachineException; @@ -45,9 +40,7 @@ public class JavascriptStateFinalizerExecutor extends StateFinalizerExecutor { // Logger for this class private static final XLogger LOGGER = XLoggerFactory.getXLogger(JavascriptStateFinalizerExecutor.class); - // Javascript engine - private ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); - private CompiledScript compiled = null; + private JavascriptExecutor javascriptExecutor; /** * Prepares the state finalizer for processing. @@ -58,14 +51,8 @@ public class JavascriptStateFinalizerExecutor extends StateFinalizerExecutor { public void prepare() throws StateMachineException { // Call generic prepare logic super.prepare(); - try { - compiled = ((Compilable) engine).compile(getSubject().getLogic()); - } catch (final ScriptException e) { - LOGGER.error("execute: state finalizer logic failed to compile for state finalizer \"" - + getSubject().getKey().getId() + "\""); - throw new StateMachineException("state finalizer logic failed to compile for state finalizer \"" - + getSubject().getKey().getId() + "\"", e); - } + + javascriptExecutor = new JavascriptExecutor(getSubject().getKey()); } /** @@ -84,25 +71,8 @@ public class JavascriptStateFinalizerExecutor extends StateFinalizerExecutor { // Do execution pre work executePre(executionId, executionProperties, incomingFields); - // Set up the Javascript engine - engine.put("executor", getExecutionContext()); - - // Check and execute the Javascript logic - try { - if (compiled == null) { - engine.eval(getSubject().getLogic()); - } else { - compiled.eval(engine.getContext()); - } - } catch (final ScriptException e) { - LOGGER.error("execute: state finalizer logic failed to run for state finalizer \"" - + getSubject().getKey().getId() + "\""); - throw new StateMachineException("state finalizer logic failed to run for state finalizer \"" - + getSubject().getKey().getId() + "\"", e); - } - - // Do the execution post work - executePost((boolean) engine.get("returnValue")); + // Execute the Javascript and do post processing + executePost(javascriptExecutor.execute(getExecutionContext(), getSubject().getLogic())); return getOutgoing(); } @@ -116,6 +86,7 @@ public class JavascriptStateFinalizerExecutor extends StateFinalizerExecutor { public void cleanUp() throws StateMachineException { LOGGER.debug("cleanUp:" + getSubject().getKey().getId() + "," + getSubject().getLogicFlavour() + "," + getSubject().getLogic()); - engine = null; + + javascriptExecutor.cleanUp(); } } diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java index 9769f42db..29fae193e 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.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. @@ -24,11 +24,6 @@ package org.onap.policy.apex.plugins.executor.javascript; import java.util.Map; import java.util.Properties; -import javax.script.Compilable; -import javax.script.CompiledScript; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.core.engine.executor.TaskExecutor; import org.onap.policy.apex.core.engine.executor.exception.StateMachineException; @@ -45,9 +40,7 @@ public class JavascriptTaskExecutor extends TaskExecutor { // Logger for this class private static final XLogger LOGGER = XLoggerFactory.getXLogger(JavascriptTaskExecutor.class); - // Javascript engine - private ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); - private CompiledScript compiled = null; + private JavascriptExecutor javascriptExecutor; /** * Prepares the task for processing. @@ -58,13 +51,8 @@ public class JavascriptTaskExecutor extends TaskExecutor { public void prepare() throws StateMachineException { // Call generic prepare logic super.prepare(); - try { - compiled = ((Compilable) engine).compile(getSubject().getTaskLogic().getLogic()); - } catch (final ScriptException e) { - LOGGER.error("execute: task logic failed to compile for task \"" + getSubject().getKey().getId() + "\""); - throw new StateMachineException( - "task logic failed to compile for task \"" + getSubject().getKey().getId() + "\"", e); - } + + javascriptExecutor = new JavascriptExecutor(getSubject().getKey()); } /** @@ -83,32 +71,8 @@ public class JavascriptTaskExecutor extends TaskExecutor { // Do execution pre work executePre(executionId, executionProperties, incomingFields); - // Set up the Javascript engine - engine.put("executor", getExecutionContext()); - - // Check and execute the Javascript logic - try { - if (compiled == null) { - engine.eval(getSubject().getTaskLogic().getLogic()); - } else { - compiled.eval(engine.getContext()); - } - } catch (final ScriptException e) { - LOGGER.error("execute: task logic failed to run for task \"" + getSubject().getKey().getId() + "\""); - throw new StateMachineException( - "task logic failed to run for task \"" + getSubject().getKey().getId() + "\"", e); - } - - final Object ret = engine.get("returnValue"); - if (ret == null) { - LOGGER.error("execute: task logic failed to set a return value for task \"" + getSubject().getKey().getId() - + "\""); - throw new StateMachineException("execute: task logic failed to set a return value for task \"" - + getSubject().getKey().getId() + "\""); - } - - // Do the execution post work - executePost((Boolean) ret); + // Execute the Javascript and do post processing + executePost(javascriptExecutor.execute(getExecutionContext(), getSubject().getTaskLogic().getLogic())); return getOutgoing(); } @@ -122,6 +86,7 @@ public class JavascriptTaskExecutor extends TaskExecutor { public void cleanUp() throws StateMachineException { LOGGER.debug("cleanUp:" + getSubject().getKey().getId() + "," + getSubject().getTaskLogic().getLogicFlavour() + "," + getSubject().getTaskLogic().getLogic()); - engine = null; + + javascriptExecutor.cleanUp(); } } diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java index afc7d0183..41585fbd0 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.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. @@ -23,11 +23,6 @@ package org.onap.policy.apex.plugins.executor.javascript; import java.util.Properties; -import javax.script.Compilable; -import javax.script.CompiledScript; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.core.engine.event.EnEvent; import org.onap.policy.apex.core.engine.executor.TaskSelectExecutor; @@ -46,16 +41,10 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor { // Logger for this class private static final XLogger LOGGER = XLoggerFactory.getXLogger(JavascriptTaskSelectExecutor.class); - // Recurring string constants - private static final String TSL_FAILED_PREFIX = - "execute: task selection logic failed to set a return value for state \""; - - // Javascript engine - private ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); - private CompiledScript compiled = null; + private JavascriptExecutor javascriptExecutor; /** - * Prepares the task for processing. + * Prepares the task selection logic for processing. * * @throws StateMachineException thrown when a state machine execution error occurs */ @@ -63,15 +52,8 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor { public void prepare() throws StateMachineException { // Call generic prepare logic super.prepare(); - try { - compiled = ((Compilable) engine).compile(getSubject().getTaskSelectionLogic().getLogic()); - } catch (final ScriptException e) { - LOGGER.error("execute: task selection logic failed to compile for state \"" + getSubject().getKey().getId() - + "\""); - throw new StateMachineException( - "task selection logic failed to compile for state \"" + getSubject().getKey().getId() + "\"", e); - } + javascriptExecutor = new JavascriptExecutor(getSubject().getKey()); } /** @@ -90,31 +72,8 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor { // Do execution pre work executePre(executionId, executionProperties, incomingEvent); - // Set up the Javascript engine - engine.put("executor", getExecutionContext()); - - // Check and execute the Javascript logic - try { - if (compiled == null) { - engine.eval(getSubject().getTaskSelectionLogic().getLogic()); - } else { - compiled.eval(engine.getContext()); - } - } catch (final ScriptException e) { - LOGGER.error( - "execute: task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\""); - throw new StateMachineException( - "task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"", e); - } - - final Object ret = engine.get("returnValue"); - if (ret == null) { - LOGGER.error(TSL_FAILED_PREFIX + getSubject().getKey().getId() + "\""); - throw new StateMachineException(TSL_FAILED_PREFIX + getSubject().getKey().getId() + "\""); - } - - // Do the execution post work - executePost((Boolean) ret); + // Execute the Javascript and do post processing + executePost(javascriptExecutor.execute(getExecutionContext(), getSubject().getTaskSelectionLogic().getLogic())); return getOutgoing(); } @@ -129,6 +88,7 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor { LOGGER.debug("cleanUp:" + getSubject().getKey().getId() + "," + getSubject().getTaskSelectionLogic().getLogicFlavour() + "," + getSubject().getTaskSelectionLogic().getLogic()); - engine = null; + + javascriptExecutor.cleanUp(); } } diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java new file mode 100644 index 000000000..1ac052456 --- /dev/null +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * 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========================================================= + */ + +package org.onap.policy.apex.plugins.executor.javascript; + +import static org.awaitility.Awaitility.await; +import static org.junit.Assert.assertNotNull; + +import java.io.File; +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.service.engine.main.ApexMain; +import org.onap.policy.common.utils.resources.TextFileUtils; + +public class JavascriptExecutorFullApexTest { + + @Test + public void testFullApexPolicy() throws ApexException { + final String[] args = {"src/test/resources/prodcons/File2File.json"}; + + final File outFile0 = new File("src/test/resources/events/EventsOut0.json"); + final File outFile1 = new File("src/test/resources/events/EventsOut1.json"); + outFile0.deleteOnExit(); + outFile1.deleteOnExit(); + + final ApexMain apexMain = new ApexMain(args); + assertNotNull(apexMain); + + await().atMost(10, TimeUnit.SECONDS).until(() -> outFile0.exists()); + await().atMost(10, TimeUnit.SECONDS).until(() -> outFile1.exists()); + + await().atMost(10, TimeUnit.SECONDS).until(() -> fileHasOccurencesOf(outFile0, "BasicEventOut0", 50)); + await().atMost(10, TimeUnit.SECONDS).until(() -> fileHasOccurencesOf(outFile1, "BasicEventOut1", 50)); + + apexMain.shutdown(); + } + + private boolean fileHasOccurencesOf(final File file, final String token, final int occurenceCount) + throws IOException { + + return occurenceCount == StringUtils.countMatches(TextFileUtils.getTextFileAsString(file.getAbsolutePath()), + token); + } +} diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java index 724c70bd2..5ccbd255f 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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. @@ -20,6 +20,7 @@ package org.onap.policy.apex.plugins.executor.javascript; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -31,7 +32,6 @@ import java.util.Properties; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.context.parameters.ContextParameterConstants; import org.onap.policy.apex.context.parameters.DistributorParameters; import org.onap.policy.apex.context.parameters.LockManagerParameters; @@ -41,7 +41,6 @@ import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.core.engine.context.ApexInternalContext; import org.onap.policy.apex.core.engine.event.EnEvent; import org.onap.policy.apex.core.engine.executor.StateExecutor; -import org.onap.policy.apex.core.engine.executor.exception.StateMachineException; import org.onap.policy.apex.core.engine.executor.impl.ExecutorFactoryImpl; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.eventmodel.concepts.AxEvent; @@ -78,30 +77,16 @@ public class JavascriptStateFinalizerExecutorTest { } @Test - public void testJavaStateFinalizerExecutor() { + public void testJavaStateFinalizerExecutor() throws Exception { JavascriptStateFinalizerExecutor jsfe = new JavascriptStateFinalizerExecutor(); assertNotNull(jsfe); - try { + assertThatThrownBy(() -> { jsfe.prepare(); - fail("test should throw an exception here"); - } catch (Exception jtseException) { - assertEquals(java.lang.NullPointerException.class, jtseException.getClass()); - } - - ApexInternalContext internalContext = null; - try { - internalContext = new ApexInternalContext(new AxPolicyModel()); - } catch (ContextException e) { - fail("test should not throw an exception here"); - } - - StateExecutor parentStateExcutor = null; - try { - parentStateExcutor = new StateExecutor(new ExecutorFactoryImpl()); - } catch (StateMachineException e) { - fail("test should not throw an exception here"); - } + }).isInstanceOf(java.lang.NullPointerException.class); + + ApexInternalContext internalContext = new ApexInternalContext(new AxPolicyModel()); + StateExecutor parentStateExcutor = new StateExecutor(new ExecutorFactoryImpl()); AxState state = new AxState(); parentStateExcutor.setContext(null, state, internalContext); @@ -109,29 +94,16 @@ public class JavascriptStateFinalizerExecutorTest { jsfe.setContext(parentStateExcutor, stateFinalizerLogic, internalContext); stateFinalizerLogic.setLogic("return false"); - try { - jsfe.prepare(); - fail("test should throw an exception here"); - } catch (Exception jtseException) { - assertEquals("state finalizer logic failed to compile for state finalizer \"NULL:0.0.0:NULL:NULL\"", - jtseException.getMessage()); - } + jsfe.prepare(); Map<String, Object> incomingParameters1 = new HashMap<>(); - try { + assertThatThrownBy(() -> { jsfe.execute(-1, new Properties(), incomingParameters1); fail("test should throw an exception here"); - } catch (Exception jteException) { - assertEquals("state finalizer logic failed to run for state finalizer \"NULL:0.0.0:NULL:NULL\"", - jteException.getMessage()); - } + }).hasMessage("execute: logic failed to run for \"NULL:0.0.0:NULL:NULL\""); stateFinalizerLogic.setLogic("java.lang.String"); - try { - jsfe.prepare(); - } catch (Exception jtseException) { - fail("test should not throw an exception here"); - } + jsfe.prepare(); AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1")); EnEvent event = new EnEvent(axEvent); @@ -141,26 +113,19 @@ public class JavascriptStateFinalizerExecutorTest { + "executor.setSelectedStateOutputName(\"SelectedOutputIsMe\");\n" + "var returnValueType = Java.type(\"java.lang.Boolean\");\n" + "\n" + "var returnValue = new returnValueType(true);}"); - try { + + assertThatThrownBy(() -> { jsfe.prepare(); jsfe.execute(-1, new Properties(), event); - fail("test should throw an exception here"); - } catch (Exception jtseException) { - assertEquals( - "execute-post: state finalizer logic execution failure on state \"NULL:0.0.0:NULL:NULL\" " - + "on finalizer logic NULL:0.0.0:NULL:NULL", - jtseException.getMessage()); - } + }).hasMessage("execute-post: state finalizer logic execution failure on state \"NULL:0.0.0:NULL:NULL\" " + + "on finalizer logic NULL:0.0.0:NULL:NULL"); state.getStateOutputs().put("SelectedOutputIsMe", null); - try { - jsfe.prepare(); - String stateOutput = jsfe.execute(0, new Properties(), event); - assertEquals("SelectedOutputIsMe", stateOutput); - jsfe.cleanUp(); - } catch (Exception jtseException) { - jtseException.printStackTrace(); - fail("test should not throw an exception here"); - } + + jsfe.prepare(); + String stateOutput = jsfe.execute(0, new Properties(), event); + assertEquals("SelectedOutputIsMe", stateOutput); + + jsfe.cleanUp(); } } diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java index fed293921..786cebcc3 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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. @@ -20,26 +20,37 @@ package org.onap.policy.apex.plugins.executor.javascript; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Properties; -import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; +import org.onap.policy.apex.context.ContextAlbum; import org.onap.policy.apex.context.ContextException; +import org.onap.policy.apex.context.Distributor; +import org.onap.policy.apex.context.impl.ContextAlbumImpl; +import org.onap.policy.apex.context.impl.distribution.jvmlocal.JvmLocalDistributor; +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.DistributorParameters; -import org.onap.policy.apex.context.parameters.LockManagerParameters; -import org.onap.policy.apex.context.parameters.PersistorParameters; +import org.onap.policy.apex.context.parameters.ContextParameters; +import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.context.ApexInternalContext; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.service.ModelService; +import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum; +import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema; +import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.model.policymodel.concepts.AxTask; import org.onap.policy.common.parameters.ParameterService; +import org.onap.policy.common.utils.resources.TextFileUtils; /** * Test the JavaTaskExecutor class. @@ -47,106 +58,147 @@ import org.onap.policy.common.parameters.ParameterService; */ public class JavascriptTaskExecutorTest { /** - * Initiate Parameters. + * Set ups everything for the test. */ - @Before - public void initiateParameters() { - ParameterService.register(new DistributorParameters()); - ParameterService.register(new LockManagerParameters()); - ParameterService.register(new PersistorParameters()); + @BeforeClass + public static void prepareForTest() { + final ContextParameters contextParameters = new ContextParameters(); + contextParameters.getLockManagerParameters() + .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JvmLocalLockManager"); + + contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME); + contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); + contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME); + contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME); + + ParameterService.register(contextParameters); + ParameterService.register(contextParameters.getDistributorParameters()); + ParameterService.register(contextParameters.getLockManagerParameters()); + ParameterService.register(contextParameters.getPersistorParameters()); + + final SchemaParameters schemaParameters = new SchemaParameters(); + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); } /** - * Clear Parameters. + * Clear down the test data. */ - @After - public void clearParameters() { + @AfterClass + public static void cleanUpAfterTest() { ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME); ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME); + ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); + ParameterService.deregister(ContextParameterConstants.MAIN_GROUP_NAME); + ParameterService.clear(); } @Test - public void testJavascriptTaskExecutor() { + public void testJavascriptTaskExecutor() throws Exception { JavascriptTaskExecutor jte = new JavascriptTaskExecutor(); assertNotNull(jte); - try { + assertThatThrownBy(() -> { jte.prepare(); - fail("test should throw an exception here"); - } catch (Exception jteException) { - assertEquals(java.lang.NullPointerException.class, jteException.getClass()); - } + }).isInstanceOf(NullPointerException.class); AxTask task = new AxTask(); - ApexInternalContext internalContext = null; - try { - internalContext = new ApexInternalContext(new AxPolicyModel()); - } catch (ContextException e) { - fail("test should not throw an exception here"); - } + final ApexInternalContext internalContext = new ApexInternalContext(new AxPolicyModel()); + jte.setContext(null, task, internalContext); - task.getTaskLogic().setLogic("return boolean"); - try { - jte.prepare(); - fail("test should throw an exception here"); - } catch (Exception jteException) { - assertEquals("task logic failed to compile for task \"NULL:0.0.0\"", jteException.getMessage()); - } + task.getTaskLogic().setLogic("return boolean;"); + jte.prepare(); Map<String, Object> incomingParameters2 = new HashMap<>(); - try { + assertThatThrownBy(() -> { jte.execute(-1, new Properties(), incomingParameters2); - fail("test should throw an exception here"); - } catch (Exception jteException) { - assertEquals("task logic failed to run for task \"NULL:0.0.0\"", jteException.getMessage()); - } + }).hasMessage("execute: logic failed to run for \"NULL:0.0.0\""); - task.getTaskLogic().setLogic("java.lang.String"); - - try { - jte.prepare(); - } catch (Exception jteException) { - fail("test should not throw an exception here"); - } + task.getTaskLogic().setLogic("var x = 5;"); + jte.prepare(); - try { + assertThatThrownBy(() -> { jte.execute(-1, new Properties(), null); - fail("test should throw an exception here"); - } catch (Exception jteException) { - assertEquals(java.lang.NullPointerException.class, jteException.getClass()); - } + }).isInstanceOf(NullPointerException.class); Map<String, Object> incomingParameters = new HashMap<>(); - try { + assertThatThrownBy(() -> { jte.execute(-1, new Properties(), incomingParameters); - fail("test should throw an exception here"); - } catch (Exception jteException) { - assertEquals("execute: task logic failed to set a return value for task \"NULL:0.0.0\"", - jteException.getMessage()); - } + }).hasMessage("execute: logic failed to set a return value for \"NULL:0.0.0\""); - task.getTaskLogic().setLogic("var returnValueType = Java.type(\"java.lang.Boolean\");\r\n" + task.getTaskLogic().setLogic("var returnValueType = Java.type(\"java.lang.Boolean\");\n" + "var returnValue = new returnValueType(false); "); - try { + + assertThatThrownBy(() -> { jte.prepare(); jte.execute(-1, new Properties(), incomingParameters); - fail("test should throw an exception here"); - } catch (Exception jteException) { - assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0", - jteException.getMessage()); - } + }).hasMessage("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0"); task.getTaskLogic().setLogic("var returnValueType = Java.type(\"java.lang.Boolean\");\r\n" + "var returnValue = new returnValueType(true); "); - try { + + jte.prepare(); + Map<String, Object> returnMap = jte.execute(0, new Properties(), incomingParameters); + assertEquals(0, returnMap.size()); + jte.cleanUp(); + } + + @Test + public void testJavascriptTaskExecutorLogic() throws Exception { + JavascriptTaskExecutor jte = new JavascriptTaskExecutor(); + assertNotNull(jte); + + assertThatThrownBy(() -> { jte.prepare(); - Map<String, Object> returnMap = jte.execute(0, new Properties(), incomingParameters); - assertEquals(0, returnMap.size()); - jte.cleanUp(); - } catch (Exception jteException) { - fail("test should not throw an exception here"); - } + }).isInstanceOf(NullPointerException.class); + + AxTask task = new AxTask(new AxArtifactKey("TestTask:0.0.1")); + + ContextAlbum contextAlbum = createTestContextAlbum(); + + final ApexInternalContext internalContext = new ApexInternalContext(new AxPolicyModel()); + internalContext.getContextAlbums().put(contextAlbum.getKey(), contextAlbum); + + task.getContextAlbumReferences().add(contextAlbum.getKey()); + task.getOutputFields().put("par0", null); + task.getOutputFields().put("par1", null); + + jte.setContext(null, task, internalContext); + + Map<String, Object> incomingParameters = new HashMap<>(); + incomingParameters.put("par0", "value0"); + + task.getTaskLogic().setLogic(TextFileUtils.getTextFileAsString("src/test/resources/javascript/TestLogic00.js")); + + jte.prepare(); + jte.execute(-1, new Properties(), incomingParameters); + + task.getTaskLogic().setLogic(TextFileUtils.getTextFileAsString("src/test/resources/javascript/TestLogic01.js")); + jte.prepare(); + + Map<String, Object> outcomingParameters = jte.execute(-1, new Properties(), incomingParameters); + + assertEquals("returnVal0", outcomingParameters.get("par0")); + assertEquals("returnVal1", outcomingParameters.get("par1")); + } + + private ContextAlbum createTestContextAlbum() throws ContextException { + AxContextSchemas schemas = new AxContextSchemas(); + AxContextSchema simpleStringSchema = + new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"), "JAVA", "java.lang.String"); + schemas.getSchemasMap().put(simpleStringSchema.getKey(), simpleStringSchema); + ModelService.registerModel(AxContextSchemas.class, schemas); + + AxContextAlbum axContextAlbum = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy", + true, AxArtifactKey.getNullKey()); + + axContextAlbum.setItemSchema(simpleStringSchema.getKey()); + Distributor distributor = new JvmLocalDistributor(); + distributor.init(axContextAlbum.getKey()); + return new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<String, Object>()); } } diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java index 9a705020c..abbcd19b7 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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. @@ -20,6 +20,7 @@ package org.onap.policy.apex.plugins.executor.javascript; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -29,7 +30,6 @@ import java.util.Properties; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.context.parameters.ContextParameterConstants; import org.onap.policy.apex.context.parameters.DistributorParameters; import org.onap.policy.apex.context.parameters.LockManagerParameters; @@ -68,92 +68,55 @@ public class JavascriptTaskSelectExecutorTest { } @Test - public void testJavascriptTaskSelectExecutor() { + public void testJavascriptTaskSelectExecutor() throws Exception { JavascriptTaskSelectExecutor jtse = new JavascriptTaskSelectExecutor(); assertNotNull(jtse); - try { + assertThatThrownBy(() -> { jtse.prepare(); fail("test should throw an exception here"); - } catch (Exception jtseException) { - assertEquals(java.lang.NullPointerException.class, jtseException.getClass()); - } + }).isInstanceOf(NullPointerException.class); AxState state = new AxState(); - ApexInternalContext internalContext = null; - try { - internalContext = new ApexInternalContext(new AxPolicyModel()); - } catch (ContextException e) { - fail("test should not throw an exception here"); - } + ApexInternalContext internalContext = new ApexInternalContext(new AxPolicyModel()); jtse.setContext(null, state, internalContext); - - state.getTaskSelectionLogic().setLogic("x!0"); - try { - jtse.prepare(); - fail("test should throw an exception here"); - } catch (Exception jtseException) { - assertEquals("task selection logic failed to compile for state \"NULL:0.0.0:NULL:NULL\"", - jtseException.getMessage()); - } + jtse.prepare(); AxEvent axEvent1 = new AxEvent(new AxArtifactKey("Event", "0.0.1")); EnEvent event1 = new EnEvent(axEvent1); - try { + + assertThatThrownBy(() -> { jtse.execute(-1, new Properties(), event1); - fail("test should throw an exception here"); - } catch (Exception jtseException) { - assertEquals( - "task selection logic failed to run for state \"NULL:0.0.0:NULL:NULL\"", - jtseException.getMessage()); - } + }).hasMessage("execute: logic failed to set a return value for \"NULL:0.0.0:NULL:NULL\""); state.getTaskSelectionLogic().setLogic("java.lang.String"); + jtse.prepare(); - try { - jtse.prepare(); - } catch (Exception jtseException) { - fail("test should not throw an exception here"); - } - - try { + assertThatThrownBy(() -> { jtse.execute(-1, new Properties(), null); - fail("test should throw an exception here"); - } catch (Exception jtseException) { - assertEquals(java.lang.NullPointerException.class, jtseException.getClass()); - } + }).isInstanceOf(NullPointerException.class); AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1")); EnEvent event = new EnEvent(axEvent); - try { + + assertThatThrownBy(() -> { jtse.execute(-1, new Properties(), event); - fail("test should throw an exception here"); - } catch (Exception jtseException) { - assertEquals( - "execute: task selection logic failed to set a return value for state \"NULL:0.0.0:NULL:NULL\"", - jtseException.getMessage()); - } + }).hasMessage("execute: logic failed to set a return value for \"NULL:0.0.0:NULL:NULL\""); state.getTaskSelectionLogic().setLogic("var returnValueType = Java.type(\"java.lang.Boolean\");\r\n" + "var returnValue = new returnValueType(false); "); - try { + + assertThatThrownBy(() -> { jtse.prepare(); jtse.execute(-1, new Properties(), event); - fail("test should throw an exception here"); - } catch (Exception jtseException) { - assertEquals("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"", - jtseException.getMessage()); - } + }).hasMessage("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\""); state.getTaskSelectionLogic().setLogic("var returnValueType = Java.type(\"java.lang.Boolean\");\r\n" + "var returnValue = new returnValueType(true); "); - try { - jtse.prepare(); - AxArtifactKey taskKey = jtse.execute(0, new Properties(), event); - assertEquals("NULL:0.0.0", taskKey.getId()); - jtse.cleanUp(); - } catch (Exception jtseException) { - fail("test should not throw an exception here"); - } + + jtse.prepare(); + AxArtifactKey taskKey = jtse.execute(0, new Properties(), event); + assertEquals("NULL:0.0.0", taskKey.getId()); + jtse.cleanUp(); } } diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/events/EventsIn0.json b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/events/EventsIn0.json new file mode 100644 index 000000000..d16431457 --- /dev/null +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/events/EventsIn0.json @@ -0,0 +1,400 @@ +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn0", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/events/EventsIn1.json b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/events/EventsIn1.json new file mode 100644 index 000000000..574af5a3c --- /dev/null +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/events/EventsIn1.json @@ -0,0 +1,400 @@ +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} +{ + "nameSpace": "org.onap.policy.apex.events", + "name": "BasicEventIn1", + "version": "0.0.1", + "source": "test", + "target": "apex", + "intPar": 12345 +} diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/javascript/PolicyTaskLogic.js b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/javascript/PolicyTaskLogic.js new file mode 100644 index 000000000..a7bb81666 --- /dev/null +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/javascript/PolicyTaskLogic.js @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * 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========================================================= + */ +executor.logger.info(executor.subject.getId()); +var gc = executor.getContextAlbum("BasicContextAlbum"); +executor.logger.info(gc.getName()); +executor.logger.info("incoming value: " + executor.inFields.get("intPar").toString()); + +var intPar = executor.inFields.get("intPar"); + +executor.logger.info("read value: " + intPar.toString()); + +var intParBy2 = intPar * 2; + +executor.outFields.put("intPar", intParBy2); + +executor.logger.info("outgoing value: " + executor.outFields.get("intPar").toString()); + +var returnValue = executor.isTrue;
\ No newline at end of file diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/javascript/TestLogic00.js b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/javascript/TestLogic00.js new file mode 100644 index 000000000..8b3bff425 --- /dev/null +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/javascript/TestLogic00.js @@ -0,0 +1,21 @@ +/*- + * ============LICENSE_START======================================================= + * 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========================================================= + */ +var x = 1; +var returnValue = true; diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/javascript/TestLogic01.js b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/javascript/TestLogic01.js new file mode 100644 index 000000000..7c8a44962 --- /dev/null +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/javascript/TestLogic01.js @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * 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========================================================= + */ +executor.logger.info("hello world"); + +executor.logger.info(executor.subject.getId()); +var gc = executor.getContextAlbum("TestContextAlbum"); +executor.logger.info(gc.getName()); +executor.logger.info(executor.inFields.get("par0")); + +executor.outFields.put("par0", "returnVal0"); +executor.outFields.put("par1", "returnVal1"); + +executor.logger.info(executor.outFields.get("par0")); +executor.logger.info(executor.outFields.get("par1")); + +var returnValue = executor.isTrue; diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/policymodels/ExecutorModel.json b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/policymodels/ExecutorModel.json new file mode 100644 index 000000000..79f08e279 --- /dev/null +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/policymodels/ExecutorModel.json @@ -0,0 +1,635 @@ +{ + "apexPolicyModel" : { + "key" : { + "name" : "SmallModel", + "version" : "0.0.1" + }, + "keyInformation" : { + "key" : { + "name" : "SmallModel_KeyInfo", + "version" : "0.0.1" + }, + "keyInfoMap" : { + "entry" : [ { + "key" : { + "name" : "BasicContextAlbum", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "BasicContextAlbum", + "version" : "0.0.1" + }, + "UUID" : "fec1b353-b35f-4384-b7d9-69622059c248", + "description" : "Generated description for a concept called \"BasicContextAlbum\" with version \"0.0.1\" and UUID \"fec1b353-b35f-4384-b7d9-69622059c248\"" + } + }, { + "key" : { + "name" : "BasicEventIn0", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "BasicEventIn0", + "version" : "0.0.1" + }, + "UUID" : "cab51283-6a38-31f6-81e8-33c381fcba77", + "description" : "Generated description for a concept called \"BasicEventIn0\" with version \"0.0.1\" and UUID \"8bfd4010-1b5b-45c0-b237-dc27d553d446\"" + } + }, { + "key" : { + "name" : "BasicEventIn1", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "BasicEventIn1", + "version" : "0.0.1" + }, + "UUID" : "b51b63bf-29b5-3104-99c7-990e6a7d703d", + "description" : "Generated description for a concept called \"BasicEventIn1\" with version \"0.0.1\" and UUID \"9f3bc09e-1070-437c-8039-bf7bc696e4cc\"" + } + }, { + "key" : { + "name" : "BasicEventOut0", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "BasicEventOut0", + "version" : "0.0.1" + }, + "UUID" : "6846fd9b-775d-3df8-afe2-7ea6898de9d6", + "description" : "Generated description for a concept called \"BasicEventOut0\" with version \"0.0.1\" and UUID \"8a22a808-98a9-41ff-93c2-c01ae73b79b2\"" + } + }, { + "key" : { + "name" : "BasicEventOut1", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "BasicEventOut1", + "version" : "0.0.1" + }, + "UUID" : "28c4cf58-cfc4-3c15-bebf-7046df303a31", + "description" : "Generated description for a concept called \"BasicEventOut1\" with version \"0.0.1\" and UUID \"f43989a7-fe36-4359-bb32-3e50799790ae\"" + } + }, { + "key" : { + "name" : "BasicTask", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "BasicTask", + "version" : "0.0.1" + }, + "UUID" : "5757b356-875b-35b1-872c-1bb8cdfe233f", + "description" : "Generated description for a concept called \"BasicTask\" with version \"0.0.1\" and UUID \"c5651414-fc1c-493b-878d-75f0ce685c36\"" + } + }, { + "key" : { + "name" : "IntType", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "IntType", + "version" : "0.0.1" + }, + "UUID" : "790ff718-8dc0-44e0-89d8-1b3bbe238310", + "description" : "Generated description for a concept called \"IntType\" with version \"0.0.1\" and UUID \"790ff718-8dc0-44e0-89d8-1b3bbe238310\"" + } + }, { + "key" : { + "name" : "Policy0", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "Policy0", + "version" : "0.0.1" + }, + "UUID" : "d2b04a23-ec6d-4626-a18b-03c36fc2e1ba", + "description" : "Generated description for a concept called \"Policy0\" with version \"0.0.1\" and UUID \"d2b04a23-ec6d-4626-a18b-03c36fc2e1ba\"" + } + }, { + "key" : { + "name" : "Policy1", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "Policy1", + "version" : "0.0.1" + }, + "UUID" : "00105b10-3f0e-49b1-bfdf-96d27b08fd54", + "description" : "Generated description for a concept called \"Policy1\" with version \"0.0.1\" and UUID \"00105b10-3f0e-49b1-bfdf-96d27b08fd54\"" + } + }, { + "key" : { + "name" : "SmallModel", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "SmallModel", + "version" : "0.0.1" + }, + "UUID" : "a1bd1f4e-713b-456b-b1a8-bb48beee28e8", + "description" : "Generated description for a concept called \"SmallModel\" with version \"0.0.1\" and UUID \"a1bd1f4e-713b-456b-b1a8-bb48beee28e8\"" + } + }, { + "key" : { + "name" : "SmallModel_Albums", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "SmallModel_Albums", + "version" : "0.0.1" + }, + "UUID" : "72bed9af-ab7d-3379-b9f7-b5eca5c9ef22", + "description" : "Generated description for concept referred to by key \"SmallModel_Albums:0.0.1\"" + } + }, { + "key" : { + "name" : "SmallModel_Events", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "SmallModel_Events", + "version" : "0.0.1" + }, + "UUID" : "796dc6b0-627d-34ae-a5e2-1bc4b4b486b8", + "description" : "Generated description for concept referred to by key \"SmallModel_Events:0.0.1\"" + } + }, { + "key" : { + "name" : "SmallModel_KeyInfo", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "SmallModel_KeyInfo", + "version" : "0.0.1" + }, + "UUID" : "b4876774-6907-3d27-a2b8-f05737c5ee4a", + "description" : "Generated description for concept referred to by key \"SmallModel_KeyInfo:0.0.1\"" + } + }, { + "key" : { + "name" : "SmallModel_Policies", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "SmallModel_Policies", + "version" : "0.0.1" + }, + "UUID" : "5bcf946b-67be-3190-a906-f954896f999f", + "description" : "Generated description for concept referred to by key \"SmallModel_Policies:0.0.1\"" + } + }, { + "key" : { + "name" : "SmallModel_Schemas", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "SmallModel_Schemas", + "version" : "0.0.1" + }, + "UUID" : "c25bf5c3-7f1e-3667-b8a9-971ba21517bc", + "description" : "Generated description for concept referred to by key \"SmallModel_Schemas:0.0.1\"" + } + }, { + "key" : { + "name" : "SmallModel_Tasks", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "SmallModel_Tasks", + "version" : "0.0.1" + }, + "UUID" : "43b015ca-2ed1-3a35-b103-e8a5aa68f1ef", + "description" : "Generated description for concept referred to by key \"SmallModel_Tasks:0.0.1\"" + } + } ] + } + }, + "policies" : { + "key" : { + "name" : "SmallModel_Policies", + "version" : "0.0.1" + }, + "policyMap" : { + "entry" : [ { + "key" : { + "name" : "Policy0", + "version" : "0.0.1" + }, + "value" : { + "policyKey" : { + "name" : "Policy0", + "version" : "0.0.1" + }, + "template" : "FREEFORM", + "state" : { + "entry" : [ { + "key" : "State0", + "value" : { + "stateKey" : { + "parentKeyName" : "Policy0", + "parentKeyVersion" : "0.0.1", + "parentLocalName" : "NULL", + "localName" : "State0" + }, + "trigger" : { + "name" : "BasicEventIn0", + "version" : "0.0.1" + }, + "stateOutputs" : { + "entry" : [ { + "key" : "State0Output", + "value" : { + "key" : { + "parentKeyName" : "Policy0", + "parentKeyVersion" : "0.0.1", + "parentLocalName" : "State0", + "localName" : "State0Output" + }, + "outgoingEvent" : { + "name" : "BasicEventOut0", + "version" : "0.0.1" + }, + "nextState" : { + "parentKeyName" : "NULL", + "parentKeyVersion" : "0.0.0", + "parentLocalName" : "NULL", + "localName" : "NULL" + } + } + } ] + }, + "contextAlbumReference" : [ ], + "taskSelectionLogic" : { + "key" : "NULL", + "logicFlavour" : "UNDEFINED", + "logic" : "" + }, + "stateFinalizerLogicMap" : { + "entry" : [ ] + }, + "defaultTask" : { + "name" : "BasicTask", + "version" : "0.0.1" + }, + "taskReferences" : { + "entry" : [ { + "key" : { + "name" : "BasicTask", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "parentKeyName" : "Policy0", + "parentKeyVersion" : "0.0.1", + "parentLocalName" : "State0", + "localName" : "BasicTask" + }, + "outputType" : "DIRECT", + "output" : { + "parentKeyName" : "Policy0", + "parentKeyVersion" : "0.0.1", + "parentLocalName" : "State0", + "localName" : "State0Output" + } + } + } ] + } + } + } ] + }, + "firstState" : "State0" + } + }, { + "key" : { + "name" : "Policy1", + "version" : "0.0.1" + }, + "value" : { + "policyKey" : { + "name" : "Policy1", + "version" : "0.0.1" + }, + "template" : "FREEFORM", + "state" : { + "entry" : [ { + "key" : "State1", + "value" : { + "stateKey" : { + "parentKeyName" : "Policy1", + "parentKeyVersion" : "0.0.1", + "parentLocalName" : "NULL", + "localName" : "State1" + }, + "trigger" : { + "name" : "BasicEventIn1", + "version" : "0.0.1" + }, + "stateOutputs" : { + "entry" : [ { + "key" : "State1Output", + "value" : { + "key" : { + "parentKeyName" : "Policy1", + "parentKeyVersion" : "0.0.1", + "parentLocalName" : "State1", + "localName" : "State1Output" + }, + "outgoingEvent" : { + "name" : "BasicEventOut1", + "version" : "0.0.1" + }, + "nextState" : { + "parentKeyName" : "NULL", + "parentKeyVersion" : "0.0.0", + "parentLocalName" : "NULL", + "localName" : "NULL" + } + } + } ] + }, + "contextAlbumReference" : [ ], + "taskSelectionLogic" : { + "key" : "NULL", + "logicFlavour" : "UNDEFINED", + "logic" : "" + }, + "stateFinalizerLogicMap" : { + "entry" : [ ] + }, + "defaultTask" : { + "name" : "BasicTask", + "version" : "0.0.1" + }, + "taskReferences" : { + "entry" : [ { + "key" : { + "name" : "BasicTask", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "parentKeyName" : "Policy1", + "parentKeyVersion" : "0.0.1", + "parentLocalName" : "State1", + "localName" : "Task1" + }, + "outputType" : "DIRECT", + "output" : { + "parentKeyName" : "Policy1", + "parentKeyVersion" : "0.0.1", + "parentLocalName" : "State1", + "localName" : "State1Output" + } + } + } ] + } + } + } ] + }, + "firstState" : "State1" + } + } ] + } + }, + "tasks" : { + "key" : { + "name" : "SmallModel_Tasks", + "version" : "0.0.1" + }, + "taskMap" : { + "entry" : [ { + "key" : { + "name" : "BasicTask", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "BasicTask", + "version" : "0.0.1" + }, + "inputFields" : { + "entry" : [ { + "key" : "intPar", + "value" : { + "key" : "intPar", + "fieldSchemaKey" : { + "name" : "IntType", + "version" : "0.0.1" + }, + "optional" : false + } + } ] + }, + "outputFields" : { + "entry" : [ { + "key" : "intPar", + "value" : { + "key" : "intPar", + "fieldSchemaKey" : { + "name" : "IntType", + "version" : "0.0.1" + }, + "optional" : false + } + } ] + }, + "taskParameters" : { + "entry" : [ ] + }, + "contextAlbumReference" : [ { + "name" : "BasicContextAlbum", + "version" : "0.0.1" + } ], + "taskLogic" : { + "key" : "TaskLogic", + "logicFlavour" : "JAVASCRIPT", + "logic" : "executor.logger.debug(executor.subject.getId());\nvar gc = executor.getContextAlbum(\"BasicContextAlbum\");\nexecutor.logger.debug(gc.getName());\nexecutor.logger.debug(\"incoming value: \" + executor.inFields.get(\"intPar\").toString());\n\nvar intPar = executor.inFields.get(\"intPar\");\n\nexecutor.logger.debug(\"read value: \" + intPar.toString());\n\nvar intParBy2 = intPar * 2;\n\nexecutor.outFields.put(\"intPar\", intParBy2);\n\nexecutor.logger.debug(\"outgoing value: \" + executor.outFields.get(\"intPar\").toString());\n\nvar returnValue = executor.isTrue;" + } + } + } ] + } + }, + "events" : { + "key" : { + "name" : "SmallModel_Events", + "version" : "0.0.1" + }, + "eventMap" : { + "entry" : [ { + "key" : { + "name" : "BasicEventIn0", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "BasicEventIn0", + "version" : "0.0.1" + }, + "nameSpace" : "org.onap.policy.apex.events", + "source" : "External", + "target" : "Apex", + "parameter" : { + "entry" : [ { + "key" : "intPar", + "value" : { + "key" : "intPar", + "fieldSchemaKey" : { + "name" : "IntType", + "version" : "0.0.1" + }, + "optional" : false + } + } ] + } + } + }, { + "key" : { + "name" : "BasicEventIn1", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "BasicEventIn1", + "version" : "0.0.1" + }, + "nameSpace" : "org.onap.policy.apex.events", + "source" : "External", + "target" : "Apex", + "parameter" : { + "entry" : [ { + "key" : "intPar", + "value" : { + "key" : "intPar", + "fieldSchemaKey" : { + "name" : "IntType", + "version" : "0.0.1" + }, + "optional" : false + } + } ] + } + } + }, { + "key" : { + "name" : "BasicEventOut0", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "BasicEventOut0", + "version" : "0.0.1" + }, + "nameSpace" : "org.onap.policy.apex.events", + "source" : "Apex", + "target" : "External", + "parameter" : { + "entry" : [ { + "key" : "intPar", + "value" : { + "key" : "intPar", + "fieldSchemaKey" : { + "name" : "IntType", + "version" : "0.0.1" + }, + "optional" : false + } + } ] + } + } + }, { + "key" : { + "name" : "BasicEventOut1", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "BasicEventOut1", + "version" : "0.0.1" + }, + "nameSpace" : "org.onap.policy.apex.events", + "source" : "Apex", + "target" : "External", + "parameter" : { + "entry" : [ { + "key" : "intPar", + "value" : { + "key" : "intPar", + "fieldSchemaKey" : { + "name" : "IntType", + "version" : "0.0.1" + }, + "optional" : false + } + } ] + } + } + } ] + } + }, + "albums" : { + "key" : { + "name" : "SmallModel_Albums", + "version" : "0.0.1" + }, + "albums" : { + "entry" : [ { + "key" : { + "name" : "BasicContextAlbum", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "BasicContextAlbum", + "version" : "0.0.1" + }, + "scope" : "GLOBAL", + "isWritable" : true, + "itemSchema" : { + "name" : "IntType", + "version" : "0.0.1" + } + } + } ] + } + }, + "schemas" : { + "key" : { + "name" : "SmallModel_Schemas", + "version" : "0.0.1" + }, + "schemas" : { + "entry" : [ { + "key" : { + "name" : "IntType", + "version" : "0.0.1" + }, + "value" : { + "key" : { + "name" : "IntType", + "version" : "0.0.1" + }, + "schemaFlavour" : "Java", + "schemaDefinition" : "java.lang.Integer" + } + } ] + } + } + } +} diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/prodcons/File2File.json b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/prodcons/File2File.json new file mode 100644 index 000000000..0a1014ae9 --- /dev/null +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/resources/prodcons/File2File.json @@ -0,0 +1,67 @@ +{ + "engineServiceParameters": { + "name": "MyApexEngine", + "version": "0.0.1", + "id": 45, + "instanceCount": 4, + "deploymentPort": 12561, + "policyModelFileName": "src/test/resources/policymodels/ExecutorModel.json", + "engineParameters": { + "executorParameters": { + "JAVASCRIPT": { + "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" + } + } + } + }, + "eventInputParameters": { + "File0Consumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "src/test/resources/events/EventsIn0.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + }, + "File1Consumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "src/test/resources/events/EventsIn1.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + } + }, + "eventOutputParameters": { + "File0Producer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "src/test/resources/events/EventsOut0.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + }, + "eventNameFilter": "BasicEventOut0" + }, + "File1Producer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "src/test/resources/events/EventsOut1.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + }, + "eventNameFilter": "BasicEventOut1" + } + } +} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java index 208571a3e..1ef830c56 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.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. @@ -23,14 +23,13 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; +import lombok.Data; + /** - * The Class TestContextItem000. + * The Class TestContextBooleanItem. */ +@Data public class TestContextBooleanItem implements Serializable { - private static final int HASH_PRIME_1 = 31; - private static final int HASH_PRIME_2 = 1231; - private static final int HASH_PRIME_3 = 1237; - private static final long serialVersionUID = 7241008665286367796L; private boolean flag = false; @@ -50,59 +49,4 @@ public class TestContextBooleanItem implements Serializable { public TestContextBooleanItem(final Boolean flag) { this.flag = flag; } - - /** - * Gets the flag. - * - * @return the flag - */ - public boolean getFlag() { - return flag; - } - - /** - * Sets the flag. - * - * @param flag the flag - */ - public void setFlag(final boolean flag) { - this.flag = flag; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + (flag ? HASH_PRIME_2 : HASH_PRIME_3); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextBooleanItem other = (TestContextBooleanItem) obj; - return flag == other.flag; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem000 [flag=" + flag + "]"; - } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java index b152f2715..91d383a62 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.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. @@ -23,14 +23,15 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; +import lombok.Data; + /** - * The Class TestContextItem001. + * The Class TestContextByteItem. */ +@Data public class TestContextByteItem implements Serializable { private static final long serialVersionUID = 1361938145823720386L; - private static final int HASH_PRIME_1 = 31; - private byte byteValue = 0; /** @@ -49,58 +50,7 @@ public class TestContextByteItem implements Serializable { this.byteValue = byteValue; } - /** - * Gets the byte value. - * - * @return the byte value - */ - public byte getByteValue() { - return byteValue; - } - - /** - * Sets the byte value. - * - * @param byteValue the byte value - */ - public void setByteValue(final byte byteValue) { - this.byteValue = byteValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + byteValue; - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextByteItem other = (TestContextByteItem) obj; - return byteValue == other.byteValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem001 [byteValue=" + byteValue + "]"; + public Byte getIncrementedByteValue() { + return (byte) (byteValue + 1); } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java index 4ed506977..b35b061a7 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.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. @@ -26,15 +26,15 @@ import java.util.Calendar; import java.util.Date; import java.util.TimeZone; +import lombok.Data; + /** - * The Class TestContextItem008. + * The Class TestContextDateItem. */ +@Data public class TestContextDateItem implements Serializable { private static final long serialVersionUID = -6984963129968805460L; - private static final int HASH_PRIME_1 = 31; - private static final int FOUR_BYTES = 32; - private long time; private int year; @@ -60,8 +60,7 @@ public class TestContextDateItem implements Serializable { public TestContextDateItem(final Date dateValue) { if (dateValue != null) { setDateValue(dateValue.getTime()); - } - else { + } else { new Date(0); } } @@ -76,78 +75,6 @@ public class TestContextDateItem implements Serializable { } /** - * Gets the time. - * - * @return the time - */ - public long getTime() { - return time; - } - - /** - * Gets the year. - * - * @return the year - */ - public int getYear() { - return year; - } - - /** - * Gets the month. - * - * @return the month - */ - public int getMonth() { - return month; - } - - /** - * Gets the day. - * - * @return the day - */ - public int getDay() { - return day; - } - - /** - * Gets the hour. - * - * @return the hour - */ - public int getHour() { - return hour; - } - - /** - * Gets the minute. - * - * @return the minute - */ - public int getMinute() { - return minute; - } - - /** - * Gets the second. - * - * @return the second - */ - public int getSecond() { - return second; - } - - /** - * Gets the milli second. - * - * @return the milli second - */ - public int getMilliSecond() { - return milliSecond; - } - - /** * Gets the date value. * * @return the date value @@ -187,50 +114,4 @@ public class TestContextDateItem implements Serializable { second = calendar.get(Calendar.SECOND); milliSecond = calendar.get(Calendar.MILLISECOND); } - - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + day; - result = prime * result + hour; - result = prime * result + milliSecond; - result = prime * result + minute; - result = prime * result + month; - result = prime * result + second; - result = prime * result + (int) (time ^ (time >>> FOUR_BYTES)); - result = prime * result + year; - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextDateItem other = (TestContextDateItem) obj; - return time == other.time; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem008 [time=" + time + ", year=" + year + ", month=" + month + ", day=" + day + ", hour=" - + hour + ", minute=" + minute + ", second=" + second + ", milliSecond=" + milliSecond + "]"; - } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java index 22c46b4a7..a3d2fc475 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.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. @@ -25,18 +25,17 @@ import java.io.Serializable; import java.util.Locale; import java.util.TimeZone; +import lombok.Data; + /** - * The Class TestContextItem00A. + * The Class TestContextDateLocaleItem. */ +@Data public class TestContextDateLocaleItem implements Serializable { private static final long serialVersionUID = -6579903685538233754L; - private static final int HASH_PRIME_1 = 31; - private static final int HASH_PRIME_2 = 1231; - private static final int HASH_PRIME_3 = 1237; - private TestContextDateItem dateValue = new TestContextDateItem(System.currentTimeMillis()); - private String timeZoneString = TimeZone.getTimeZone("Europe/Dublin").getDisplayName(); + private String tzValue = TimeZone.getTimeZone("Europe/Dublin").getDisplayName(); private boolean dst = false; private int utcOffset = 0; private Locale locale = Locale.ENGLISH; @@ -58,9 +57,9 @@ public class TestContextDateLocaleItem implements Serializable { * @param country the country */ public TestContextDateLocaleItem(final TestContextDateItem dateValue, final String tzValue, final boolean dst, - final int utcOffset, final String language, final String country) { + final int utcOffset, final String language, final String country) { this.dateValue = dateValue; - this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName(); + this.tzValue = TimeZone.getTimeZone(tzValue).getDisplayName(); this.dst = dst; this.utcOffset = utcOffset; @@ -74,7 +73,7 @@ public class TestContextDateLocaleItem implements Serializable { */ public TestContextDateLocaleItem(final TestContextDateLocaleItem original) { this.dateValue = original.dateValue; - this.timeZoneString = TimeZone.getTimeZone(original.timeZoneString).getDisplayName(); + this.tzValue = TimeZone.getTimeZone(original.tzValue).getDisplayName(); this.dst = original.dst; this.utcOffset = original.utcOffset; @@ -82,167 +81,15 @@ public class TestContextDateLocaleItem implements Serializable { } /** - * Gets the date value. - * - * @return the date value - */ - public TestContextDateItem getDateValue() { - return dateValue; - } - - /** - * Sets the date value. - * - * @param dateValue the date value - */ - public void setDateValue(final TestContextDateItem dateValue) { - this.dateValue = dateValue; - } - - /** - * Gets the TZ value. - * - * @return the TZ value - */ - public String getTzValue() { - return timeZoneString; - } - - /** * Sets the TZ value. * * @param tzValue the TZ value */ public void setTzValue(final String tzValue) { if (tzValue != null) { - this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName(); + this.tzValue = TimeZone.getTimeZone(tzValue).getDisplayName(); } else { - this.timeZoneString = null; - } - } - - /** - * Gets the DST. - * - * @return the dst - */ - public boolean getDst() { - return dst; - } - - /** - * Sets the DST. - * - * @param newDst the dst - */ - public void setDst(final boolean newDst) { - this.dst = newDst; - } - - /** - * Gets the UTC offset. - * - * @return the UTC offset - */ - public int getUtcOffset() { - return utcOffset; - } - - /** - * Sets the UTC offset. - * - * @param newUtcOffset the UTC offset - */ - public void setUtcOffset(final int newUtcOffset) { - this.utcOffset = newUtcOffset; - } - - /** - * Gets the locale. - * - * @return the locale - */ - public Locale getLocale() { - return locale; - } - - /** - * Sets the locale. - * - * @param locale the locale - */ - public void setLocale(final Locale locale) { - if (locale != null) { - this.locale = locale; - } - else { - this.locale = null; + this.tzValue = null; } } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + ((dateValue == null) ? 0 : dateValue.hashCode()); - result = prime * result + (dst ? HASH_PRIME_2 : HASH_PRIME_3); - result = prime * result + ((locale == null) ? 0 : locale.hashCode()); - result = prime * result + ((timeZoneString == null) ? 0 : timeZoneString.hashCode()); - result = prime * result + utcOffset; - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextDateLocaleItem other = (TestContextDateLocaleItem) obj; - if (dateValue == null) { - if (other.dateValue != null) { - return false; - } - } else if (!dateValue.equals(other.dateValue)) { - return false; - } - if (dst != other.dst) { - return false; - } - if (locale == null) { - if (other.locale != null) { - return false; - } - } else if (!locale.equals(other.locale)) { - return false; - } - if (timeZoneString == null) { - if (other.timeZoneString != null) { - return false; - } - } else if (!timeZoneString.equals(other.timeZoneString)) { - return false; - } - return utcOffset == other.utcOffset; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem00A [dateValue=" + dateValue + ", timeZoneString=" + timeZoneString + ", dst=" + dst - + ", utcOffset=" + utcOffset + ", locale=" + locale + "]"; - } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java index 602f20917..029719afb 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.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. @@ -24,18 +24,17 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; import java.util.TimeZone; +import lombok.Data; + /** - * The Class TestContextItem009. + * The Class TestContextDateTzItem. */ +@Data public class TestContextDateTzItem implements Serializable { private static final long serialVersionUID = 5604426823170331706L; - private static final int HASH_PRIME_1 = 31; - private static final int HASH_PRIME_2 = 1231; - private static final int HASH_PRIME_3 = 1237; - private TestContextDateItem dateValue = new TestContextDateItem(System.currentTimeMillis()); - private String timeZoneString = TimeZone.getTimeZone("Europe/Dublin").getDisplayName(); + private String tzValue = TimeZone.getTimeZone("Europe/Dublin").getDisplayName(); private boolean dst = false; /** @@ -54,7 +53,7 @@ public class TestContextDateTzItem implements Serializable { */ public TestContextDateTzItem(final TestContextDateItem dateValue, final String tzValue, final boolean dst) { this.dateValue = dateValue; - this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName(); + this.tzValue = TimeZone.getTimeZone(tzValue).getDisplayName(); this.dst = dst; } @@ -65,123 +64,20 @@ public class TestContextDateTzItem implements Serializable { */ public TestContextDateTzItem(final TestContextDateTzItem original) { this.dateValue = original.dateValue; - this.timeZoneString = original.timeZoneString; + this.tzValue = original.tzValue; this.dst = original.dst; } /** - * Gets the date value. - * - * @return the date value - */ - public TestContextDateItem getDateValue() { - return dateValue; - } - - /** - * Sets the date value. - * - * @param dateValue the date value - */ - public void setDateValue(final TestContextDateItem dateValue) { - this.dateValue = dateValue; - } - - /** - * Gets the TZ value. - * - * @return the TZ value - */ - public String getTzValue() { - return timeZoneString; - } - - /** * Sets the TZ value. * * @param tzValue the TZ value */ public void setTzValue(final String tzValue) { if (tzValue != null) { - this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName(); + this.tzValue = TimeZone.getTimeZone(tzValue).getDisplayName(); + } else { + this.tzValue = null; } - else { - this.timeZoneString = null; - } - } - - /** - * Gets the DST. - * - * @return the dst - */ - public boolean getDst() { - return dst; - } - - /** - * Sets the DST. - * - * @param newDst the dst - */ - public void setDst(final boolean newDst) { - this.dst = newDst; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + ((dateValue == null) ? 0 : dateValue.hashCode()); - result = prime * result + (dst ? HASH_PRIME_2 : HASH_PRIME_3); - result = prime * result + ((timeZoneString == null) ? 0 : timeZoneString.hashCode()); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextDateTzItem other = (TestContextDateTzItem) obj; - if (dateValue == null) { - if (other.dateValue != null) { - return false; - } - } else if (!dateValue.equals(other.dateValue)) { - return false; - } - if (dst != other.dst) { - return false; - } - if (timeZoneString == null) { - if (other.timeZoneString != null) { - return false; - } - } - else if (!timeZoneString.equals(other.timeZoneString)) { - return false; - } - return true; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem009 [dateValue=" + dateValue + ", tzValue=" + timeZoneString + ", dst=" + dst + "]"; } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java index e67ba5e7e..dede657c6 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.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. @@ -23,15 +23,15 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; +import lombok.Data; + /** - * The Class TestContextItem005. + * The Class TestContextDoubleItem. */ +@Data public class TestContextDoubleItem implements Serializable { private static final long serialVersionUID = -2958758261076734821L; - private static final int HASH_PRIME_1 = 31; - private static final int FOUR_BYTES = 32; - private double doubleValue = 0; /** @@ -50,60 +50,7 @@ public class TestContextDoubleItem implements Serializable { this.doubleValue = doubleValue; } - /** - * Gets the double value. - * - * @return the double value - */ - public double getDoubleValue() { - return doubleValue; - } - - /** - * Sets the double value. - * - * @param doubleValue the double value - */ - public void setDoubleValue(final double doubleValue) { - this.doubleValue = doubleValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - long temp; - temp = Double.doubleToLongBits(doubleValue); - result = prime * result + (int) (temp ^ (temp >>> FOUR_BYTES)); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextDoubleItem other = (TestContextDoubleItem) obj; - return Double.doubleToLongBits(doubleValue) == Double.doubleToLongBits(other.doubleValue); - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem005 [doubleValue=" + doubleValue + "]"; + public Double getIncrementedDoubleValue() { + return doubleValue + 1; } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java index fec1c2545..8337d8006 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.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. @@ -23,14 +23,15 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; +import lombok.Data; + /** - * The Class TestContextItem004. + * The Class TestContextFloatItem. */ +@Data public class TestContextFloatItem implements Serializable { private static final long serialVersionUID = -3359180576903272400L; - private static final int HASH_PRIME_1 = 31; - private float floatValue = 0; /** @@ -49,58 +50,7 @@ public class TestContextFloatItem implements Serializable { this.floatValue = floatValue; } - /** - * Gets the float value. - * - * @return the float value - */ - public float getFloatValue() { - return floatValue; - } - - /** - * Sets the float value. - * - * @param floatValue the float value - */ - public void setFloatValue(final float floatValue) { - this.floatValue = floatValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + Float.floatToIntBits(floatValue); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextFloatItem other = (TestContextFloatItem) obj; - return Float.floatToIntBits(floatValue) == Float.floatToIntBits(other.floatValue); - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem004 [floatValue=" + floatValue + "]"; + public Float getIncrementedFloatValue() { + return floatValue + 1; } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java index ea76f7049..fde563cf3 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.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. @@ -23,14 +23,15 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; +import lombok.Data; + /** - * The Class TestContextItem002. + * The Class TestContextIntItem. */ +@Data public class TestContextIntItem implements Serializable { private static final long serialVersionUID = -8978435658277900984L; - private static final int HASH_PRIME_1 = 31; - private int intValue = 0; /** @@ -58,58 +59,7 @@ public class TestContextIntItem implements Serializable { this.intValue = original.intValue; } - /** - * Gets the int value. - * - * @return the int value - */ - public int getIntValue() { - return intValue; - } - - /** - * Sets the int value. - * - * @param intValue the int value - */ - public void setIntValue(final int intValue) { - this.intValue = intValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + intValue; - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextIntItem other = (TestContextIntItem) obj; - return intValue == other.intValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem002 [intValue=" + intValue + "]"; + public Integer getIncrementedIntValue() { + return intValue + 1; } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java index dc18da5f5..ac70dafcc 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.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. @@ -23,15 +23,15 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; +import lombok.Data; + /** - * The Class TestContextItem003. + * The Class TestContextLongItem. */ +@Data public class TestContextLongItem implements Serializable { private static final long serialVersionUID = 3599267534512489386L; - private static final int HASH_PRIME_1 = 31; - private static final int FOUR_BYTES = 33; - private long longValue = 0; /** @@ -50,58 +50,7 @@ public class TestContextLongItem implements Serializable { this.longValue = longValue; } - /** - * Gets the long value. - * - * @return the long value - */ - public long getLongValue() { - return longValue; - } - - /** - * Sets the long value. - * - * @param longValue the long value - */ - public void setLongValue(final long longValue) { - this.longValue = longValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + (int) (longValue ^ (longValue >>> FOUR_BYTES)); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextLongItem other = (TestContextLongItem) obj; - return longValue == other.longValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem003 [longValue=" + longValue + "]"; + public Long getIncrementedLongValue() { + return longValue + 1; } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java index fb1e9319d..cadc66f95 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.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. @@ -23,14 +23,15 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; +import lombok.Data; + /** - * The Class TestContextItem007. + * The Class TestContextLongObjectItem. */ +@Data public class TestContextLongObjectItem implements Serializable { private static final long serialVersionUID = -1029406737866392421L; - private static final int HASH_PRIME_1 = 31; - private Long longValue = 0L; /** @@ -49,65 +50,7 @@ public class TestContextLongObjectItem implements Serializable { this.longValue = longValue; } - /** - * Gets the long value. - * - * @return the long value - */ - public Long getLongValue() { - return longValue; - } - - /** - * Sets the long value. - * - * @param longValue the long value - */ - public void setLongValue(final Long longValue) { - this.longValue = longValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + ((longValue == null) ? 0 : longValue.hashCode()); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextLongObjectItem other = (TestContextLongObjectItem) obj; - if (longValue == null) { - if (other.longValue != null) { - return false; - } - } else if (!longValue.equals(other.longValue)) { - return false; - } - return true; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem007 [longValue=" + longValue + "]"; + public Long getIncrementedLongValue() { + return longValue + 1; } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java index 16a180a64..e443b9c8a 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.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. @@ -23,14 +23,15 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; +import lombok.Data; + /** - * The Class TestContextItem006. + * The Class TestContextStringItem. */ +@Data public class TestContextStringItem implements Serializable { private static final long serialVersionUID = -1074772190611125121L; - private static final int HASH_PRIME_1 = 31; - private String stringValue = ""; /** @@ -48,66 +49,4 @@ public class TestContextStringItem implements Serializable { public TestContextStringItem(final String stringValue) { this.stringValue = stringValue; } - - /** - * Gets the string value. - * - * @return the string value - */ - public String getStringValue() { - return stringValue; - } - - /** - * Sets the string value. - * - * @param stringValue the string value - */ - public void setStringValue(final String stringValue) { - this.stringValue = stringValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + ((stringValue == null) ? 0 : stringValue.hashCode()); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextStringItem other = (TestContextStringItem) obj; - if (stringValue == null) { - if (other.stringValue != null) { - return false; - } - } else if (!stringValue.equals(other.stringValue)) { - return false; - } - return true; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem006 [stringValue=" + stringValue + "]"; - } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java index 3e3aae121..fcdd1ad06 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.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. @@ -25,14 +25,15 @@ import java.io.Serializable; import java.util.Map; import java.util.TreeMap; +import lombok.Data; + /** - * The Class TestContextItem00C. + * The Class TestContextTreeMapItem. */ +@Data public class TestContextTreeMapItem implements Serializable { private static final long serialVersionUID = -7497746259264651884L; - private static final int HASH_PRIME_1 = 31; - private Map<String, String> mapValue = new TreeMap<>(); /** @@ -50,70 +51,4 @@ public class TestContextTreeMapItem implements Serializable { public TestContextTreeMapItem(final Map<String, String> mapValue) { this.mapValue = mapValue; } - - /** - * Gets the map value. - * - * @return the map value - */ - public Map<String, String> getMapValue() { - if (mapValue == null) { - mapValue = new TreeMap<>(); - } - return mapValue; - } - - /** - * Sets the map value. - * - * @param mapValue the map value - */ - public void setMapValue(final Map<String, String> mapValue) { - this.mapValue = mapValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + ((mapValue == null) ? 0 : mapValue.hashCode()); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextTreeMapItem other = (TestContextTreeMapItem) obj; - if (mapValue == null) { - if (other.mapValue != null) { - return false; - } - } else if (!mapValue.equals(other.mapValue)) { - return false; - } - return true; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem00C [mapValue=" + mapValue + "]"; - } - } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java index 7c83d48e5..d84aebbff 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.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. @@ -23,18 +23,18 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; import java.util.Arrays; -import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import lombok.Data; + /** - * The Class TestContextItem00B. + * The Class TestContextTreeSetItem. */ +@Data public class TestContextTreeSetItem implements Serializable { private static final long serialVersionUID = 1254589722957250388L; - private static final int HASH_PRIME_1 = 31; - private SortedSet<String> setValue = new TreeSet<>(); /** @@ -61,69 +61,4 @@ public class TestContextTreeSetItem implements Serializable { public TestContextTreeSetItem(final SortedSet<String> setValue) { this.setValue = setValue; } - - /** - * Gets the set value. - * - * @return the sets the value - */ - public Set<String> getSetValue() { - if (setValue == null) { - setValue = new TreeSet<>(); - } - return setValue; - } - - /** - * Sets the set value. - * - * @param setValue the sets the value - */ - public void setSetValue(final SortedSet<String> setValue) { - this.setValue = setValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + ((setValue == null) ? 0 : setValue.hashCode()); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestContextTreeSetItem other = (TestContextTreeSetItem) obj; - if (setValue == null) { - if (other.setValue != null) { - return false; - } - } else if (!setValue.equals(other.setValue)) { - return false; - } - return true; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestContextItem00B [setValue=" + setValue + "]"; - } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java index 3d17eeccc..d20e4bde8 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.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. @@ -23,14 +23,15 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; +import lombok.Data; + /** * The Class TestExternalContextItem. */ +@Data public class TestExternalContextItem implements Serializable { private static final long serialVersionUID = 3512435733818672173L; - private static final int HASH_PRIME_1 = 31; - private TestContextBooleanItem testExternalContextItem000; private TestContextByteItem testExternalContextItem001; private TestContextIntItem testExternalContextItem002; @@ -44,386 +45,4 @@ public class TestExternalContextItem implements Serializable { private TestContextDateLocaleItem testExternalContextItem00A; private TestContextTreeSetItem testExternalContextItem00B; private TestContextTreeMapItem testExternalContextItem00C; - - /** - * Gets the test external context item 000. - * - * @return the test external context item 000 - */ - public TestContextBooleanItem getTestExternalContextItem000() { - return testExternalContextItem000; - } - - /** - * Sets the test external context item 000. - * - * @param testExternalContextItem000 the test external context item 000 - */ - public void setTestExternalContextItem000(final TestContextBooleanItem testExternalContextItem000) { - this.testExternalContextItem000 = testExternalContextItem000; - } - - /** - * Gets the test external context item 001. - * - * @return the test external context item 001 - */ - public TestContextByteItem getTestExternalContextItem001() { - return testExternalContextItem001; - } - - /** - * Sets the test external context item 001. - * - * @param testExternalContextItem001 the test external context item 001 - */ - public void setTestExternalContextItem001(final TestContextByteItem testExternalContextItem001) { - this.testExternalContextItem001 = testExternalContextItem001; - } - - /** - * Gets the test external context item 002. - * - * @return the test external context item 002 - */ - public TestContextIntItem getTestExternalContextItem002() { - return testExternalContextItem002; - } - - /** - * Sets the test external context item 002. - * - * @param testExternalContextItem002 the test external context item 002 - */ - public void setTestExternalContextItem002(final TestContextIntItem testExternalContextItem002) { - this.testExternalContextItem002 = testExternalContextItem002; - } - - /** - * Gets the test external context item 003. - * - * @return the test external context item 003 - */ - public TestContextLongItem getTestExternalContextItem003() { - return testExternalContextItem003; - } - - /** - * Sets the test external context item 003. - * - * @param testExternalContextItem003 the test external context item 003 - */ - public void setTestExternalContextItem003(final TestContextLongItem testExternalContextItem003) { - this.testExternalContextItem003 = testExternalContextItem003; - } - - /** - * Gets the test external context item 004. - * - * @return the test external context item 004 - */ - public TestContextFloatItem getTestExternalContextItem004() { - return testExternalContextItem004; - } - - /** - * Sets the test external context item 004. - * - * @param testExternalContextItem004 the test external context item 004 - */ - public void setTestExternalContextItem004(final TestContextFloatItem testExternalContextItem004) { - this.testExternalContextItem004 = testExternalContextItem004; - } - - /** - * Gets the test external context item 005. - * - * @return the test external context item 005 - */ - public TestContextDoubleItem getTestExternalContextItem005() { - return testExternalContextItem005; - } - - /** - * Sets the test external context item 005. - * - * @param testExternalContextItem005 the test external context item 005 - */ - public void setTestExternalContextItem005(final TestContextDoubleItem testExternalContextItem005) { - this.testExternalContextItem005 = testExternalContextItem005; - } - - /** - * Gets the test external context item 006. - * - * @return the test external context item 006 - */ - public TestContextStringItem getTestExternalContextItem006() { - return testExternalContextItem006; - } - - /** - * Sets the test external context item 006. - * - * @param testExternalContextItem006 the test external context item 006 - */ - public void setTestExternalContextItem006(final TestContextStringItem testExternalContextItem006) { - this.testExternalContextItem006 = testExternalContextItem006; - } - - /** - * Gets the test external context item 007. - * - * @return the test external context item 007 - */ - public TestContextLongObjectItem getTestExternalContextItem007() { - return testExternalContextItem007; - } - - /** - * Sets the test external context item 007. - * - * @param testExternalContextItem007 the test external context item 007 - */ - public void setTestExternalContextItem007(final TestContextLongObjectItem testExternalContextItem007) { - this.testExternalContextItem007 = testExternalContextItem007; - } - - /** - * Gets the test external context item 008. - * - * @return the test external context item 008 - */ - public TestContextDateItem getTestExternalContextItem008() { - return testExternalContextItem008; - } - - /** - * Sets the test external context item 008. - * - * @param testExternalContextItem008 the test external context item 008 - */ - public void setTestExternalContextItem008(final TestContextDateItem testExternalContextItem008) { - this.testExternalContextItem008 = testExternalContextItem008; - } - - /** - * Gets the test external context item 009. - * - * @return the test external context item 009 - */ - public TestContextDateTzItem getTestExternalContextItem009() { - return testExternalContextItem009; - } - - /** - * Sets the test external context item 009. - * - * @param testExternalContextItem009 the test external context item 009 - */ - public void setTestExternalContextItem009(final TestContextDateTzItem testExternalContextItem009) { - this.testExternalContextItem009 = testExternalContextItem009; - } - - /** - * Gets the test external context item 00 A. - * - * @return the test external context item 00 A - */ - public TestContextDateLocaleItem getTestExternalContextItem00A() { - return testExternalContextItem00A; - } - - /** - * Sets the test external context item 00 A. - * - * @param testExternalContextItem00A the test external context item 00 A - */ - public void setTestExternalContextItem00A(final TestContextDateLocaleItem testExternalContextItem00A) { - this.testExternalContextItem00A = testExternalContextItem00A; - } - - /** - * Gets the test external context item 00 B. - * - * @return the test external context item 00 B - */ - public TestContextTreeSetItem getTestExternalContextItem00B() { - return testExternalContextItem00B; - } - - /** - * Sets the test external context item 00 B. - * - * @param testExternalContextItem00B the test external context item 00 B - */ - public void setTestExternalContextItem00B(final TestContextTreeSetItem testExternalContextItem00B) { - this.testExternalContextItem00B = testExternalContextItem00B; - } - - /** - * Gets the test external context item 00 C. - * - * @return the test external context item 00 C - */ - public TestContextTreeMapItem getTestExternalContextItem00C() { - return testExternalContextItem00C; - } - - /** - * Sets the test external context item 00 C. - * - * @param testExternalContextItem00C the test external context item 00 C - */ - public void setTestExternalContextItem00C(final TestContextTreeMapItem testExternalContextItem00C) { - this.testExternalContextItem00C = testExternalContextItem00C; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + ((testExternalContextItem000 == null) ? 0 : testExternalContextItem000.hashCode()); - result = prime * result + ((testExternalContextItem001 == null) ? 0 : testExternalContextItem001.hashCode()); - result = prime * result + ((testExternalContextItem002 == null) ? 0 : testExternalContextItem002.hashCode()); - result = prime * result + ((testExternalContextItem003 == null) ? 0 : testExternalContextItem003.hashCode()); - result = prime * result + ((testExternalContextItem004 == null) ? 0 : testExternalContextItem004.hashCode()); - result = prime * result + ((testExternalContextItem005 == null) ? 0 : testExternalContextItem005.hashCode()); - result = prime * result + ((testExternalContextItem006 == null) ? 0 : testExternalContextItem006.hashCode()); - result = prime * result + ((testExternalContextItem007 == null) ? 0 : testExternalContextItem007.hashCode()); - result = prime * result + ((testExternalContextItem008 == null) ? 0 : testExternalContextItem008.hashCode()); - result = prime * result + ((testExternalContextItem009 == null) ? 0 : testExternalContextItem009.hashCode()); - result = prime * result + ((testExternalContextItem00A == null) ? 0 : testExternalContextItem00A.hashCode()); - result = prime * result + ((testExternalContextItem00B == null) ? 0 : testExternalContextItem00B.hashCode()); - result = prime * result + ((testExternalContextItem00C == null) ? 0 : testExternalContextItem00C.hashCode()); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestExternalContextItem other = (TestExternalContextItem) obj; - if (testExternalContextItem000 == null) { - if (other.testExternalContextItem000 != null) { - return false; - } - } else if (!testExternalContextItem000.equals(other.testExternalContextItem000)) { - return false; - } - if (testExternalContextItem001 == null) { - if (other.testExternalContextItem001 != null) { - return false; - } - } else if (!testExternalContextItem001.equals(other.testExternalContextItem001)) { - return false; - } - if (testExternalContextItem002 == null) { - if (other.testExternalContextItem002 != null) { - return false; - } - } else if (!testExternalContextItem002.equals(other.testExternalContextItem002)) { - return false; - } - if (testExternalContextItem003 == null) { - if (other.testExternalContextItem003 != null) { - return false; - } - } else if (!testExternalContextItem003.equals(other.testExternalContextItem003)) { - return false; - } - if (testExternalContextItem004 == null) { - if (other.testExternalContextItem004 != null) { - return false; - } - } else if (!testExternalContextItem004.equals(other.testExternalContextItem004)) { - return false; - } - if (testExternalContextItem005 == null) { - if (other.testExternalContextItem005 != null) { - return false; - } - } else if (!testExternalContextItem005.equals(other.testExternalContextItem005)) { - return false; - } - if (testExternalContextItem006 == null) { - if (other.testExternalContextItem006 != null) { - return false; - } - } else if (!testExternalContextItem006.equals(other.testExternalContextItem006)) { - return false; - } - if (testExternalContextItem007 == null) { - if (other.testExternalContextItem007 != null) { - return false; - } - } else if (!testExternalContextItem007.equals(other.testExternalContextItem007)) { - return false; - } - if (testExternalContextItem008 == null) { - if (other.testExternalContextItem008 != null) { - return false; - } - } else if (!testExternalContextItem008.equals(other.testExternalContextItem008)) { - return false; - } - if (testExternalContextItem009 == null) { - if (other.testExternalContextItem009 != null) { - return false; - } - } else if (!testExternalContextItem009.equals(other.testExternalContextItem009)) { - return false; - } - if (testExternalContextItem00A == null) { - if (other.testExternalContextItem00A != null) { - return false; - } - } else if (!testExternalContextItem00A.equals(other.testExternalContextItem00A)) { - return false; - } - if (testExternalContextItem00B == null) { - if (other.testExternalContextItem00B != null) { - return false; - } - } else if (!testExternalContextItem00B.equals(other.testExternalContextItem00B)) { - return false; - } - if (testExternalContextItem00C == null) { - if (other.testExternalContextItem00C != null) { - return false; - } - } else if (!testExternalContextItem00C.equals(other.testExternalContextItem00C)) { - return false; - } - return true; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestExternalContextItem [testExternalContextItem000=" + testExternalContextItem000 - + ", testExternalContextItem001=" + testExternalContextItem001 + ", testExternalContextItem002=" - + testExternalContextItem002 + ", testExternalContextItem003=" + testExternalContextItem003 - + ", testExternalContextItem004=" + testExternalContextItem004 + ", testExternalContextItem005=" - + testExternalContextItem005 + ", testExternalContextItem006=" + testExternalContextItem006 - + ", testExternalContextItem007=" + testExternalContextItem007 + ", testExternalContextItem008=" - + testExternalContextItem008 + ", testExternalContextItem009=" + testExternalContextItem009 - + ", testExternalContextItem00A=" + testExternalContextItem00A + ", testExternalContextItem00B=" - + testExternalContextItem00B + ", testExternalContextItem00C=" + testExternalContextItem00C + "]"; - } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java index 94707082d..f10d8c823 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.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. @@ -23,14 +23,15 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; +import lombok.Data; + /** * The Class TestGlobalContextItem. */ +@Data public class TestGlobalContextItem implements Serializable { private static final long serialVersionUID = 3348445332683174361L; - private static final int HASH_PRIME_1 = 31; - private TestContextBooleanItem testGlobalContextItem000; private TestContextByteItem testGlobalContextItem001; private TestContextIntItem testGlobalContextItem002; @@ -44,386 +45,4 @@ public class TestGlobalContextItem implements Serializable { private TestContextDateLocaleItem testGlobalContextItem00A; private TestContextTreeSetItem testGlobalContextItem00B; private TestContextTreeMapItem testGlobalContextItem00C; - - /** - * Gets the test global context item 000. - * - * @return the test global context item 000 - */ - public TestContextBooleanItem getTestGlobalContextItem000() { - return testGlobalContextItem000; - } - - /** - * Sets the test global context item 000. - * - * @param testGlobalContextItem000 the test global context item 000 - */ - public void setTestGlobalContextItem000(final TestContextBooleanItem testGlobalContextItem000) { - this.testGlobalContextItem000 = testGlobalContextItem000; - } - - /** - * Gets the test global context item 001. - * - * @return the test global context item 001 - */ - public TestContextByteItem getTestGlobalContextItem001() { - return testGlobalContextItem001; - } - - /** - * Sets the test global context item 001. - * - * @param testGlobalContextItem001 the test global context item 001 - */ - public void setTestGlobalContextItem001(final TestContextByteItem testGlobalContextItem001) { - this.testGlobalContextItem001 = testGlobalContextItem001; - } - - /** - * Gets the test global context item 002. - * - * @return the test global context item 002 - */ - public TestContextIntItem getTestGlobalContextItem002() { - return testGlobalContextItem002; - } - - /** - * Sets the test global context item 002. - * - * @param testGlobalContextItem002 the test global context item 002 - */ - public void setTestGlobalContextItem002(final TestContextIntItem testGlobalContextItem002) { - this.testGlobalContextItem002 = testGlobalContextItem002; - } - - /** - * Gets the test global context item 003. - * - * @return the test global context item 003 - */ - public TestContextLongItem getTestGlobalContextItem003() { - return testGlobalContextItem003; - } - - /** - * Sets the test global context item 003. - * - * @param testGlobalContextItem003 the test global context item 003 - */ - public void setTestGlobalContextItem003(final TestContextLongItem testGlobalContextItem003) { - this.testGlobalContextItem003 = testGlobalContextItem003; - } - - /** - * Gets the test global context item 004. - * - * @return the test global context item 004 - */ - public TestContextFloatItem getTestGlobalContextItem004() { - return testGlobalContextItem004; - } - - /** - * Sets the test global context item 004. - * - * @param testGlobalContextItem004 the test global context item 004 - */ - public void setTestGlobalContextItem004(final TestContextFloatItem testGlobalContextItem004) { - this.testGlobalContextItem004 = testGlobalContextItem004; - } - - /** - * Gets the test global context item 005. - * - * @return the test global context item 005 - */ - public TestContextDoubleItem getTestGlobalContextItem005() { - return testGlobalContextItem005; - } - - /** - * Sets the test global context item 005. - * - * @param testGlobalContextItem005 the test global context item 005 - */ - public void setTestGlobalContextItem005(final TestContextDoubleItem testGlobalContextItem005) { - this.testGlobalContextItem005 = testGlobalContextItem005; - } - - /** - * Gets the test global context item 006. - * - * @return the test global context item 006 - */ - public TestContextStringItem getTestGlobalContextItem006() { - return testGlobalContextItem006; - } - - /** - * Sets the test global context item 006. - * - * @param testGlobalContextItem006 the test global context item 006 - */ - public void setTestGlobalContextItem006(final TestContextStringItem testGlobalContextItem006) { - this.testGlobalContextItem006 = testGlobalContextItem006; - } - - /** - * Gets the test global context item 007. - * - * @return the test global context item 007 - */ - public TestContextLongObjectItem getTestGlobalContextItem007() { - return testGlobalContextItem007; - } - - /** - * Sets the test global context item 007. - * - * @param testGlobalContextItem007 the test global context item 007 - */ - public void setTestGlobalContextItem007(final TestContextLongObjectItem testGlobalContextItem007) { - this.testGlobalContextItem007 = testGlobalContextItem007; - } - - /** - * Gets the test global context item 008. - * - * @return the test global context item 008 - */ - public TestContextDateItem getTestGlobalContextItem008() { - return testGlobalContextItem008; - } - - /** - * Sets the test global context item 008. - * - * @param testGlobalContextItem008 the test global context item 008 - */ - public void setTestGlobalContextItem008(final TestContextDateItem testGlobalContextItem008) { - this.testGlobalContextItem008 = testGlobalContextItem008; - } - - /** - * Gets the test global context item 009. - * - * @return the test global context item 009 - */ - public TestContextDateTzItem getTestGlobalContextItem009() { - return testGlobalContextItem009; - } - - /** - * Sets the test global context item 009. - * - * @param testGlobalContextItem009 the test global context item 009 - */ - public void setTestGlobalContextItem009(final TestContextDateTzItem testGlobalContextItem009) { - this.testGlobalContextItem009 = testGlobalContextItem009; - } - - /** - * Gets the test global context item 00 A. - * - * @return the test global context item 00 A - */ - public TestContextDateLocaleItem getTestGlobalContextItem00A() { - return testGlobalContextItem00A; - } - - /** - * Sets the test global context item 00 A. - * - * @param testGlobalContextItem00A the test global context item 00 A - */ - public void setTestGlobalContextItem00A(final TestContextDateLocaleItem testGlobalContextItem00A) { - this.testGlobalContextItem00A = testGlobalContextItem00A; - } - - /** - * Gets the test global context item 00 B. - * - * @return the test global context item 00 B - */ - public TestContextTreeSetItem getTestGlobalContextItem00B() { - return testGlobalContextItem00B; - } - - /** - * Sets the test global context item 00 B. - * - * @param testGlobalContextItem00B the test global context item 00 B - */ - public void setTestGlobalContextItem00B(final TestContextTreeSetItem testGlobalContextItem00B) { - this.testGlobalContextItem00B = testGlobalContextItem00B; - } - - /** - * Gets the test global context item 00 C. - * - * @return the test global context item 00 C - */ - public TestContextTreeMapItem getTestGlobalContextItem00C() { - return testGlobalContextItem00C; - } - - /** - * Sets the test global context item 00 C. - * - * @param testGlobalContextItem00C the test global context item 00 C - */ - public void setTestGlobalContextItem00C(final TestContextTreeMapItem testGlobalContextItem00C) { - this.testGlobalContextItem00C = testGlobalContextItem00C; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + ((testGlobalContextItem000 == null) ? 0 : testGlobalContextItem000.hashCode()); - result = prime * result + ((testGlobalContextItem001 == null) ? 0 : testGlobalContextItem001.hashCode()); - result = prime * result + ((testGlobalContextItem002 == null) ? 0 : testGlobalContextItem002.hashCode()); - result = prime * result + ((testGlobalContextItem003 == null) ? 0 : testGlobalContextItem003.hashCode()); - result = prime * result + ((testGlobalContextItem004 == null) ? 0 : testGlobalContextItem004.hashCode()); - result = prime * result + ((testGlobalContextItem005 == null) ? 0 : testGlobalContextItem005.hashCode()); - result = prime * result + ((testGlobalContextItem006 == null) ? 0 : testGlobalContextItem006.hashCode()); - result = prime * result + ((testGlobalContextItem007 == null) ? 0 : testGlobalContextItem007.hashCode()); - result = prime * result + ((testGlobalContextItem008 == null) ? 0 : testGlobalContextItem008.hashCode()); - result = prime * result + ((testGlobalContextItem009 == null) ? 0 : testGlobalContextItem009.hashCode()); - result = prime * result + ((testGlobalContextItem00A == null) ? 0 : testGlobalContextItem00A.hashCode()); - result = prime * result + ((testGlobalContextItem00B == null) ? 0 : testGlobalContextItem00B.hashCode()); - result = prime * result + ((testGlobalContextItem00C == null) ? 0 : testGlobalContextItem00C.hashCode()); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestGlobalContextItem other = (TestGlobalContextItem) obj; - if (testGlobalContextItem000 == null) { - if (other.testGlobalContextItem000 != null) { - return false; - } - } else if (!testGlobalContextItem000.equals(other.testGlobalContextItem000)) { - return false; - } - if (testGlobalContextItem001 == null) { - if (other.testGlobalContextItem001 != null) { - return false; - } - } else if (!testGlobalContextItem001.equals(other.testGlobalContextItem001)) { - return false; - } - if (testGlobalContextItem002 == null) { - if (other.testGlobalContextItem002 != null) { - return false; - } - } else if (!testGlobalContextItem002.equals(other.testGlobalContextItem002)) { - return false; - } - if (testGlobalContextItem003 == null) { - if (other.testGlobalContextItem003 != null) { - return false; - } - } else if (!testGlobalContextItem003.equals(other.testGlobalContextItem003)) { - return false; - } - if (testGlobalContextItem004 == null) { - if (other.testGlobalContextItem004 != null) { - return false; - } - } else if (!testGlobalContextItem004.equals(other.testGlobalContextItem004)) { - return false; - } - if (testGlobalContextItem005 == null) { - if (other.testGlobalContextItem005 != null) { - return false; - } - } else if (!testGlobalContextItem005.equals(other.testGlobalContextItem005)) { - return false; - } - if (testGlobalContextItem006 == null) { - if (other.testGlobalContextItem006 != null) { - return false; - } - } else if (!testGlobalContextItem006.equals(other.testGlobalContextItem006)) { - return false; - } - if (testGlobalContextItem007 == null) { - if (other.testGlobalContextItem007 != null) { - return false; - } - } else if (!testGlobalContextItem007.equals(other.testGlobalContextItem007)) { - return false; - } - if (testGlobalContextItem008 == null) { - if (other.testGlobalContextItem008 != null) { - return false; - } - } else if (!testGlobalContextItem008.equals(other.testGlobalContextItem008)) { - return false; - } - if (testGlobalContextItem009 == null) { - if (other.testGlobalContextItem009 != null) { - return false; - } - } else if (!testGlobalContextItem009.equals(other.testGlobalContextItem009)) { - return false; - } - if (testGlobalContextItem00A == null) { - if (other.testGlobalContextItem00A != null) { - return false; - } - } else if (!testGlobalContextItem00A.equals(other.testGlobalContextItem00A)) { - return false; - } - if (testGlobalContextItem00B == null) { - if (other.testGlobalContextItem00B != null) { - return false; - } - } else if (!testGlobalContextItem00B.equals(other.testGlobalContextItem00B)) { - return false; - } - if (testGlobalContextItem00C == null) { - if (other.testGlobalContextItem00C != null) { - return false; - } - } else if (!testGlobalContextItem00C.equals(other.testGlobalContextItem00C)) { - return false; - } - return true; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestGlobalContextItem [testGlobalContextItem000=" + testGlobalContextItem000 - + ", testGlobalContextItem001=" + testGlobalContextItem001 + ", testGlobalContextItem002=" - + testGlobalContextItem002 + ", testGlobalContextItem003=" + testGlobalContextItem003 - + ", testGlobalContextItem004=" + testGlobalContextItem004 + ", testGlobalContextItem005=" - + testGlobalContextItem005 + ", testGlobalContextItem006=" + testGlobalContextItem006 - + ", testGlobalContextItem007=" + testGlobalContextItem007 + ", testGlobalContextItem008=" - + testGlobalContextItem008 + ", testGlobalContextItem009=" + testGlobalContextItem009 - + ", testGlobalContextItem00A=" + testGlobalContextItem00A + ", testGlobalContextItem00B=" - + testGlobalContextItem00B + ", testGlobalContextItem00C=" + testGlobalContextItem00C + "]"; - } } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java index 23d506639..c58da226a 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.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. @@ -23,214 +23,19 @@ package org.onap.policy.apex.context.test.concepts; import java.io.Serializable; +import lombok.Data; + /** * The Class TestPolicyContextItem. */ +@Data public class TestPolicyContextItem implements Serializable { private static final long serialVersionUID = 6336372857646152910L; - private static final int HASH_PRIME_1 = 31; - private TestContextStringItem testPolicyContextItem000; private TestContextLongItem testPolicyContextItem001; private TestContextDoubleItem testPolicyContextItem002; private TestContextBooleanItem testPolicyContextItem003; private TestContextLongItem testPolicyContextItem004; private TestContextTreeMapItem testPolicyContextItem005; - - /** - * Gets the test policy context item 000. - * - * @return the test policy context item 000 - */ - public TestContextStringItem getTestPolicyContextItem000() { - return testPolicyContextItem000; - } - - /** - * Sets the test policy context item 000. - * - * @param testPolicyContextItem000 the test policy context item 000 - */ - public void setTestPolicyContextItem000(final TestContextStringItem testPolicyContextItem000) { - this.testPolicyContextItem000 = testPolicyContextItem000; - } - - /** - * Gets the test policy context item 001. - * - * @return the test policy context item 001 - */ - public TestContextLongItem getTestPolicyContextItem001() { - return testPolicyContextItem001; - } - - /** - * Sets the test policy context item 001. - * - * @param testPolicyContextItem001 the test policy context item 001 - */ - public void setTestPolicyContextItem001(final TestContextLongItem testPolicyContextItem001) { - this.testPolicyContextItem001 = testPolicyContextItem001; - } - - /** - * Gets the test policy context item 002. - * - * @return the test policy context item 002 - */ - public TestContextDoubleItem getTestPolicyContextItem002() { - return testPolicyContextItem002; - } - - /** - * Sets the test policy context item 002. - * - * @param testPolicyContextItem002 the test policy context item 002 - */ - public void setTestPolicyContextItem002(final TestContextDoubleItem testPolicyContextItem002) { - this.testPolicyContextItem002 = testPolicyContextItem002; - } - - /** - * Gets the test policy context item 003. - * - * @return the test policy context item 003 - */ - public TestContextBooleanItem getTestPolicyContextItem003() { - return testPolicyContextItem003; - } - - /** - * Sets the test policy context item 003. - * - * @param testPolicyContextItem003 the test policy context item 003 - */ - public void setTestPolicyContextItem003(final TestContextBooleanItem testPolicyContextItem003) { - this.testPolicyContextItem003 = testPolicyContextItem003; - } - - /** - * Gets the test policy context item 004. - * - * @return the test policy context item 004 - */ - public TestContextLongItem getTestPolicyContextItem004() { - return testPolicyContextItem004; - } - - /** - * Sets the test policy context item 004. - * - * @param testPolicyContextItem004 the test policy context item 004 - */ - public void setTestPolicyContextItem004(final TestContextLongItem testPolicyContextItem004) { - this.testPolicyContextItem004 = testPolicyContextItem004; - } - - /** - * Gets the test policy context item 005. - * - * @return the test policy context item 005 - */ - public TestContextTreeMapItem getTestPolicyContextItem005() { - return testPolicyContextItem005; - } - - /** - * Sets the test policy context item 005. - * - * @param testPolicyContextItem005 the test policy context item 005 - */ - public void setTestPolicyContextItem005(final TestContextTreeMapItem testPolicyContextItem005) { - this.testPolicyContextItem005 = testPolicyContextItem005; - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = HASH_PRIME_1; - int result = 1; - result = prime * result + ((testPolicyContextItem000 == null) ? 0 : testPolicyContextItem000.hashCode()); - result = prime * result + ((testPolicyContextItem001 == null) ? 0 : testPolicyContextItem001.hashCode()); - result = prime * result + ((testPolicyContextItem002 == null) ? 0 : testPolicyContextItem002.hashCode()); - result = prime * result + ((testPolicyContextItem003 == null) ? 0 : testPolicyContextItem003.hashCode()); - result = prime * result + ((testPolicyContextItem004 == null) ? 0 : testPolicyContextItem004.hashCode()); - result = prime * result + ((testPolicyContextItem005 == null) ? 0 : testPolicyContextItem005.hashCode()); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TestPolicyContextItem other = (TestPolicyContextItem) obj; - if (testPolicyContextItem000 == null) { - if (other.testPolicyContextItem000 != null) { - return false; - } - } else if (!testPolicyContextItem000.equals(other.testPolicyContextItem000)) { - return false; - } - if (testPolicyContextItem001 == null) { - if (other.testPolicyContextItem001 != null) { - return false; - } - } else if (!testPolicyContextItem001.equals(other.testPolicyContextItem001)) { - return false; - } - if (testPolicyContextItem002 == null) { - if (other.testPolicyContextItem002 != null) { - return false; - } - } else if (!testPolicyContextItem002.equals(other.testPolicyContextItem002)) { - return false; - } - if (testPolicyContextItem003 == null) { - if (other.testPolicyContextItem003 != null) { - return false; - } - } else if (!testPolicyContextItem003.equals(other.testPolicyContextItem003)) { - return false; - } - if (testPolicyContextItem004 == null) { - if (other.testPolicyContextItem004 != null) { - return false; - } - } else if (!testPolicyContextItem004.equals(other.testPolicyContextItem004)) { - return false; - } - if (testPolicyContextItem005 == null) { - if (other.testPolicyContextItem005 != null) { - return false; - } - } else if (!testPolicyContextItem005.equals(other.testPolicyContextItem005)) { - return false; - } - return true; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "TestPolicyContextItem [testPolicyContextItem000=" + testPolicyContextItem000 - + ", testPolicyContextItem001=" + testPolicyContextItem001 + ", testPolicyContextItem002=" - + testPolicyContextItem002 + ", testPolicyContextItem003=" + testPolicyContextItem003 - + ", testPolicyContextItem004=" + testPolicyContextItem004 + ", testPolicyContextItem005=" - + testPolicyContextItem005 + "]"; - } } diff --git a/testsuites/integration/integration-common/src/main/resources/examples/models/JMS/JMSTestModel.json b/testsuites/integration/integration-common/src/main/resources/examples/models/JMS/JMSTestModel.json index 02365bcdb..78c8110b9 100644 --- a/testsuites/integration/integration-common/src/main/resources/examples/models/JMS/JMSTestModel.json +++ b/testsuites/integration/integration-common/src/main/resources/examples/models/JMS/JMSTestModel.json @@ -342,7 +342,7 @@ "taskLogic": { "key": "TaskLogic", "logicFlavour": "JAVASCRIPT", - "logic": "var outFieldType = Java.type(\"org.onap.policy.apex.testsuites.integration.common.testclasses.PingTestClass\");\nvar outValue = new outFieldType();\n\nvar inValue = executor.inFields.get(\"PingTestClass\");\n\nexecutor.logger.info(inValue);\n\noutValue.setPingTime(inValue.getPingTime());\noutValue.setPongTime(new Date().getTime());\noutValue.setName(inValue.getName() + \"_out\");\n\noutValue.setDescription(\ninValue.getDescription() +\n\". So Romeo would, were he not Romeo call'd,\" +\n\" retain that dear perfection which he owes, without that title.\");\n\nexecutor.logger.info(outValue);\nexecutor.outFields.put(\"PingTestClass\", outValue)\n\nvar returnValueType = Java.type(\"java.lang.Boolean\");\nvar returnValue = new returnValueType(true);" + "logic": "var outFieldType = Java.type(\"org.onap.policy.apex.testsuites.integration.common.testclasses.PingTestClass\");\nvar outValue = new outFieldType();\n\nvar inValue = executor.inFields.get(\"PingTestClass\");\n\nexecutor.logger.info(inValue.toString());\n\noutValue.setPingTime(inValue.getPingTime());\noutValue.setPongTime(new Date().getTime());\noutValue.setName(inValue.getName() + \"_out\");\n\noutValue.setDescription(\ninValue.getDescription() +\n\". So Romeo would, were he not Romeo call'd,\" +\n\" retain that dear perfection which he owes, without that title.\");\n\nexecutor.logger.info(outValue.toString();\nexecutor.outFields.put(\"PingTestClass\", outValue)\n\nvar returnValueType = Java.type(\"java.lang.Boolean\");\nvar returnValue = new returnValueType(true);" } } } diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultStateLogic.javascript b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultStateLogic.javascript index e25cb9c6e..a3f1525d0 100644 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultStateLogic.javascript +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultStateLogic.javascript @@ -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. @@ -18,10 +19,10 @@ * ============LICENSE_END========================================================= */ -executor.logger.debug(executor.subject.id); +executor.logger.debug(executor.subject.getId()); var gc = executor.getContextAlbum("GlobalContextAlbum"); -executor.logger.debug(gc.name); -executor.subject.defaultTaskKey.copyTo(executor.selectedTask) +executor.logger.debug(gc.getName()); +executor.getSubject().getDefaultTaskKey().copyTo(executor.selectedTask); var returnValue = executor.isTrue; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultTaskLogic.javascript b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultTaskLogic.javascript index 158e49eea..36fd2c4a2 100644 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultTaskLogic.javascript +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultTaskLogic.javascript @@ -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. @@ -18,15 +19,15 @@ * ============LICENSE_END========================================================= */ -executor.logger.debug(executor.subject.id); +executor.logger.debug(executor.subject.getId()); var gc = executor.getContextAlbum("GlobalContextAlbum"); -executor.logger.debug(gc.name); -executor.logger.debug(executor.inFields); +executor.logger.debug(gc.getName()); +executor.logger.debug(executor.inFields.get("TestSlogan")); var caseSelectedType = Java.type("java.lang.Byte"); executor.outFields.put("Test<STATE_NAME>CaseSelected", new caseSelectedType(<RANDOM_BYTE_VALUE>)); executor.outFields.put("Test<STATE_NAME>StateTime", java.lang.System.nanoTime()); -executor.logger.debug(executor.eo); +executor.logger.debug(executor.inFields.get("TestSlogan")); var returnValue = executor.isTrue; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalStateLogic.javascript b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalStateLogic.javascript index 535cad595..5ee2a0448 100644 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalStateLogic.javascript +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalStateLogic.javascript @@ -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. @@ -18,7 +19,7 @@ * ============LICENSE_END========================================================= */ -executor.logger.debug(executor.subject.id); +executor.logger.debug(executor.subject.getId()); executor.subject.defaultTaskKey.copyTo(executor.selectedTask); var returnValue = executor.isTrue; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalTaskLogic.javascript b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalTaskLogic.javascript index efbe5cb4d..b29e96fcf 100644 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalTaskLogic.javascript +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalTaskLogic.javascript @@ -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. @@ -18,10 +19,10 @@ * ============LICENSE_END========================================================= */ -executor.logger.debug(executor.subject.id); -executor.logger.debug(executor.inFields); +executor.logger.debug(executor.subject.getId()); +executor.logger.debug(executor.inFields.get("name")); executor.outFields.put("State<STATE_NUMBER>Timestamp", java.lang.System.nanoTime()); -executor.logger.debug(executor.outFields); +executor.logger.debug(executor.outFields.get("name")); var returnValue = executor.isTrue; diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java index e954fe862..75ac4a1bb 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java @@ -158,7 +158,7 @@ public class ContextInstantiation { assertEquals(LONG_VAL, contextItem.getTestPolicyContextItem001().getLongValue()); assertDouble(contextItem.getTestPolicyContextItem002().getDoubleValue(), PI_VAL); - assertTrue(contextItem.getTestPolicyContextItem003().getFlag()); + assertTrue(contextItem.getTestPolicyContextItem003().isFlag()); assertEquals(contextItem.getTestPolicyContextItem004().getLongValue(), testDate.getTime()); assertEquals(TEST_HASH_MAP, contextItem.getTestPolicyContextItem005().getMapValue()); @@ -174,7 +174,7 @@ public class ContextInstantiation { final TestGlobalContextItem globalContextItem = (TestGlobalContextItem) globalContextAlbum.get(GLOBAL_CONTEXT_KEY); - assertFalse(globalContextItem.getTestGlobalContextItem000().getFlag()); + assertFalse(globalContextItem.getTestGlobalContextItem000().isFlag()); assertEquals(BYTE_VAL, globalContextItem.getTestGlobalContextItem001().getByteValue()); @@ -220,7 +220,7 @@ public class ContextInstantiation { TestExternalContextItem externalContextItem = (TestExternalContextItem) externalContextAlbum.get(EXTERNAL_CONTEXT); - assertFalse(externalContextItem.getTestExternalContextItem000().getFlag()); + assertFalse(externalContextItem.getTestExternalContextItem000().isFlag()); assertEquals(BYTE_VAL, externalContextItem.getTestExternalContextItem001().getByteValue()); assertEquals(INT_VAL, externalContextItem.getTestExternalContextItem002().getIntValue()); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java index ca2d3ecc0..60b9711c9 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.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. @@ -38,6 +39,7 @@ import org.apache.activemq.security.SimpleAuthenticationPlugin; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; @@ -141,8 +143,9 @@ public class TestJms2Jms { * @throws JMSException the JMS exception */ @Test + @Ignore public void testJmsObjectEvents() throws ApexException, JMSException { - final String[] args = { "-rfr", "target", "-c", "target/examples/config/JMS/JMS2JMSObjectEvent.json" }; + final String[] args = {"-rfr", "target", "-c", "target/examples/config/JMS/JMS2JMSObjectEvent.json"}; testJmsEvents(args, true); } @@ -154,7 +157,7 @@ public class TestJms2Jms { */ @Test public void testJmsJsonEvents() throws ApexException, JMSException { - final String[] args = { "-rfr", "target", "-c", "target/examples/config/JMS/JMS2JMSJsonEvent.json" }; + final String[] args = {"-rfr", "target", "-c", "target/examples/config/JMS/JMS2JMSJsonEvent.json"}; testJmsEvents(args, false); } diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java index 6675d9f24..298a56be6 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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. @@ -24,9 +24,11 @@ import static org.junit.Assert.assertTrue; import java.io.ByteArrayOutputStream; import java.io.PrintStream; + import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; + import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -87,8 +89,8 @@ public class TestExecutionPropertyRest { throw new IllegalStateException("port " + PORT + " is still in use"); } - server = HttpServletServerFactoryInstance.getServerFactory().build( - "TestExecutionPropertyRest", false, null, PORT, "/TestExecutionRest", false, false); + server = HttpServletServerFactoryInstance.getServerFactory().build("TestExecutionPropertyRest", false, null, + PORT, "/TestExecutionRest", false, false); server.addServletClass(null, TestRestClientEndpoint.class.getName()); server.setSerializationProvider(GsonMessageBodyHandler.class.getName()); @@ -129,7 +131,7 @@ public class TestExecutionPropertyRest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/testdata/executionproperties/RESTEventBadUrl.json" }; + final String[] args = {"src/test/resources/testdata/executionproperties/RESTEventBadUrl.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(500); @@ -142,7 +144,7 @@ public class TestExecutionPropertyRest { System.setErr(stderr); LOGGER.info("testReplaceUrlTag-OUTSTRING=\n" + outString + "\nEnd-TagUrl"); - assertTrue(outString.contains("no proper URL has been set for event sending on REST client")); + assertTrue(outString.contains("no URL has been set for event sending on RESTCLIENT")); } /** @@ -153,7 +155,7 @@ public class TestExecutionPropertyRest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/testdata/executionproperties/RESTEventNoValueSetForTag.json" }; + final String[] args = {"src/test/resources/testdata/executionproperties/RESTEventNoValueSetForTag.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(2000); @@ -166,8 +168,8 @@ public class TestExecutionPropertyRest { System.setErr(stderr); LOGGER.info("testReplaceUrlTag-OUTSTRING=\n" + outString + "\nEnd-TagUrl"); - assertTrue(outString.contains("key\"Number\"specified on url \"http://localhost:32801/TestExecutionRest/apex" - + "/event/{tagId}/{Number}\"not found in execution properties passed by the current policy")); + assertTrue(outString.contains("key \"Number\" specified on url \"http://localhost:32801/TestExecutionRest/apex" + + "/event/{tagId}/{Number}\" not found in execution properties passed by the current policy")); } /** @@ -178,7 +180,7 @@ public class TestExecutionPropertyRest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/testdata/executionproperties/RESTEventBadHttpCodeFilter.json" }; + final String[] args = {"src/test/resources/testdata/executionproperties/RESTEventBadHttpCodeFilter.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(500); @@ -201,8 +203,7 @@ public class TestExecutionPropertyRest { public void testReplaceUrlTag() throws Exception { final Client client = ClientBuilder.newClient(); - final String[] args = - { "src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToTagUrlOK.json" }; + final String[] args = {"src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToTagUrlOK.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(1000); apexMain.shutdown(); @@ -226,8 +227,11 @@ public class TestExecutionPropertyRest { @Test public void testReplaceUrlMultiTag() throws Exception { final Client client = ClientBuilder.newClient(); - final String[] args = - { "src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToMultiTagUrlOK.json" }; + // @formatter:off + final String[] args = { + "src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToMultiTagUrlOK.json" + }; + // @formatter:on final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(1500); apexMain.shutdown(); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java index 0ae8f703d..e433771f8 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.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. @@ -30,6 +30,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Map; + import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; @@ -71,8 +72,8 @@ public class TestFile2Rest { */ @BeforeClass public static void setUp() throws Exception { - server = HttpServletServerFactoryInstance.getServerFactory().build( - "TestFile2Rest", false, null, PORT, "/TestFile2Rest", false, false); + server = HttpServletServerFactoryInstance.getServerFactory().build("TestFile2Rest", false, null, PORT, + "/TestFile2Rest", false, false); server.addServletClass(null, TestRestClientEndpoint.class.getName()); server.setSerializationProvider(GsonMessageBodyHandler.class.getName()); @@ -115,8 +116,14 @@ public class TestFile2Rest { public void testFileEventsPost() throws MessagingException, ApexException, IOException { final Client client = ClientBuilder.newClient(); - final String[] args = - { "-rfr", "target", "-c", "target/examples/config/SampleDomain/File2RESTJsonEventPost.json" }; + // @formatter:off + final String[] args = { + "-rfr", + "target", + "-c", + "target/examples/config/SampleDomain/File2RESTJsonEventPost.json" + }; + // @formatter:on final ApexMain apexMain = new ApexMain(args); Response response = null; @@ -125,7 +132,7 @@ public class TestFile2Rest { for (int i = 0; i < 100; i++) { ThreadUtilities.sleep(100); response = client.target("http://localhost:32801/TestFile2Rest/apex/event/Stats") - .request("application/json").get(); + .request("application/json").get(); if (Response.Status.OK.getStatusCode() != response.getStatus()) { break; @@ -154,8 +161,14 @@ public class TestFile2Rest { */ @Test public void testFileEventsPut() throws MessagingException, ApexException, IOException { - final String[] args = - { "-rfr", "target", "-c", "target/examples/config/SampleDomain/File2RESTJsonEventPut.json" }; + // @formatter:off + final String[] args = { + "-rfr", + "target", + "-c", + "target/examples/config/SampleDomain/File2RESTJsonEventPut.json" + }; + // @formatter:on final ApexMain apexMain = new ApexMain(args); final Client client = ClientBuilder.newClient(); @@ -166,7 +179,7 @@ public class TestFile2Rest { for (int i = 0; i < 20; i++) { ThreadUtilities.sleep(300); response = client.target("http://localhost:32801/TestFile2Rest/apex/event/Stats") - .request("application/json").get(); + .request("application/json").get(); if (Response.Status.OK.getStatusCode() != response.getStatus()) { break; @@ -198,8 +211,7 @@ public class TestFile2Rest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = - { "src/test/resources/prodcons/File2RESTJsonEventNoURL.json" }; + final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventNoURL.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(200); @@ -211,7 +223,7 @@ public class TestFile2Rest { System.setErr(stderr); LOGGER.info("NoUrl-OUTSTRING=\n" + outString + "\nEnd-NoUrl"); - assertTrue(outString.contains(" no URL has been set for event sending on REST client")); + assertTrue(outString.contains(" no URL has been set for event sending on RESTCLIENT")); } /** @@ -226,8 +238,7 @@ public class TestFile2Rest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = - { "src/test/resources/prodcons/File2RESTJsonEventBadURL.json" }; + final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventBadURL.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(2000); @@ -240,7 +251,7 @@ public class TestFile2Rest { LOGGER.info("BadUrl-OUTSTRING=\n" + outString + "\nEnd-BadUrl"); assertTrue(outString.contains( - "send of event to URL \"http://localhost:32801/TestFile2Rest/apex/event/Bad\" using HTTP \"POST\" failed with status code 404")); + "send of event to URL \"http://localhost:32801/TestFile2Rest/apex/event/Bad\" using HTTP \"POST\" failed with status code 404")); } /** @@ -255,8 +266,7 @@ public class TestFile2Rest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = - { "src/test/resources/prodcons/File2RESTJsonEventBadHTTPMethod.json" }; + final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventBadHTTPMethod.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(200); @@ -268,9 +278,9 @@ public class TestFile2Rest { System.setErr(stderr); LOGGER.info("BadHttpMethod-OUTSTRING=\n" + outString + "\nEnd-BadHttpMethod"); - assertTrue(outString.contains( - "specified HTTP method of \"DELETE\" is invalid, only HTTP methods \"POST\" and \"PUT\" " - + "are supproted for event sending on REST client producer")); + assertTrue(outString + .contains("specified HTTP method of \"DELETE\" is invalid, only HTTP methods \"POST\" and \"PUT\" " + + "are supported for event sending on REST client producer")); } /** @@ -285,8 +295,7 @@ public class TestFile2Rest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = - { "src/test/resources/prodcons/File2RESTJsonEventPostBadResponse.json" }; + final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventPostBadResponse.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(2000); @@ -299,7 +308,7 @@ public class TestFile2Rest { LOGGER.info("BadResponse-OUTSTRING=\n" + outString + "\nEnd-BadResponse"); assertTrue(outString.contains( - "send of event to URL \"http://localhost:32801/TestFile2Rest/apex/event/PostEventBadResponse\"" - + " using HTTP \"POST\" failed with status code 400")); + "send of event to URL \"http://localhost:32801/TestFile2Rest/apex/event/PostEventBadResponse\"" + + " using HTTP \"POST\" failed with status code 400")); } } diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java index e799f5973..3243cd772 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java @@ -180,7 +180,7 @@ public class TestRest2File { System.setOut(stdout); System.setErr(stderr); - checkRequiredString(outString, " no URL has been set for event sending on REST client"); + checkRequiredString(outString, " no URL has been set for event sending on RESTCLIENT"); } /** diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_AvroEventAlbum_EventOutCompare.json b/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_AvroEventAlbum_EventOutCompare.json index 1c30984e7..9b3481890 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_AvroEventAlbum_EventOutCompare.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_AvroEventAlbum_EventOutCompare.json @@ -15,7 +15,7 @@ "AvroBoolean": true, "AvroByte": -127.0, "AvroDouble": 1.2345E67, - "AvroFloat": 1.9999999999999998E23, + "AvroFloat": 1.9999999556392617E23, "AvroInteger": 1234568.0, "AvroLong": 1.234567890124E12, "AvroMap": { @@ -80,7 +80,7 @@ "doubleValue": 6.71000001E8 }, "CustomFloat": { - "floatValue": 3000001.0 + "floatValue": 3000000.0 }, "CustomInteger": { "intValue": -9876542.0 diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_JavaEventAlbum_EventOutCompare.json b/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_JavaEventAlbum_EventOutCompare.json index fc7b04a12..a0f8549e6 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_JavaEventAlbum_EventOutCompare.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_JavaEventAlbum_EventOutCompare.json @@ -31,7 +31,7 @@ "second": 48, "milliSecond": 391 }, - "timeZoneString": "Greenwich Mean Time", + "tzValue": "Greenwich Mean Time", "dst": true }, "CustomDate2": { @@ -45,7 +45,7 @@ "second": 48, "milliSecond": 391 }, - "timeZoneString": "Greenwich Mean Time", + "tzValue": "Greenwich Mean Time", "dst": false, "utcOffset": 0, "locale": "en" @@ -60,10 +60,10 @@ "intValue": -9876542 }, "CustomJLong": { - "longValue": 9223372036854775807 + "longValue": -9223372036854775808 }, "CustomLong": { - "longValue": 9223372036854775807 + "longValue": -9223372036854775808 }, "CustomMap": { "mapValue": { diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/AddPropertyTask.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/AddPropertyTask.js index af0db4e3e..54826ce7a 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/AddPropertyTask.js +++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/AddPropertyTask.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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,10 +18,7 @@ * ============LICENSE_END========================================================= */ -executor.logger.info(executor.subject.id); -executor.logger.info(executor.inFields); - -executor.logger.info(executor.outFields); +executor.logger.info(executor.getSubject().getId()); executor.logger.info("executionProperties in:" + executor.getExecutionProperties()); diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/DefinedToEmptyTask.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/DefinedToEmptyTask.js index dce37cc3e..4596dd4b4 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/DefinedToEmptyTask.js +++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/DefinedToEmptyTask.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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,10 +18,7 @@ * ============LICENSE_END========================================================= */ -executor.logger.info(executor.subject.id); -executor.logger.info(executor.inFields); - -executor.logger.info(executor.outFields); +executor.logger.info(executor.getSubject().getId()); executor.logger.info("executionProperties in:" + executor.getExecutionProperties()); diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/EmptyToDefinedTask.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/EmptyToDefinedTask.js index 090b7a00c..ba807cf73 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/EmptyToDefinedTask.js +++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/EmptyToDefinedTask.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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,10 +18,7 @@ * ============LICENSE_END========================================================= */ -executor.logger.info(executor.subject.id); -executor.logger.info(executor.inFields); - -executor.logger.info(executor.outFields); +executor.logger.info(executor.getSubject().getId()); executor.logger.info("executionProperties in:" + executor.getExecutionProperties()); diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/EmptyToEmptyTask.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/EmptyToEmptyTask.js index 62af4e97b..6cae0ceb1 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/EmptyToEmptyTask.js +++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/EmptyToEmptyTask.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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,10 +18,7 @@ * ============LICENSE_END========================================================= */ -executor.logger.info(executor.subject.id); -executor.logger.info(executor.inFields); - -executor.logger.info(executor.outFields); +executor.logger.info(executor.getSubject().getId()); executor.logger.info("executionProperties:" + executor.getExecutionProperties()); diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/ReadOnlyTask.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/ReadOnlyTask.js index 62af4e97b..6cae0ceb1 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/ReadOnlyTask.js +++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/ReadOnlyTask.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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,10 +18,7 @@ * ============LICENSE_END========================================================= */ -executor.logger.info(executor.subject.id); -executor.logger.info(executor.inFields); - -executor.logger.info(executor.outFields); +executor.logger.info(executor.getSubject().getId()); executor.logger.info("executionProperties:" + executor.getExecutionProperties()); diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/RemovePropertyTask.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/RemovePropertyTask.js index f08b718e4..2d934636a 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/RemovePropertyTask.js +++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/RemovePropertyTask.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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,10 +18,7 @@ * ============LICENSE_END========================================================= */ -executor.logger.info(executor.subject.id); -executor.logger.info(executor.inFields); - -executor.logger.info(executor.outFields); +executor.logger.info(executor.getSubject().getId()); executor.logger.info("executionProperties in:" + executor.getExecutionProperties()); diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/RunTestStateTSL.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/RunTestStateTSL.js index b527fc1f1..f41c7c02a 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/RunTestStateTSL.js +++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/RunTestStateTSL.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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,8 +18,7 @@ * ============LICENSE_END========================================================= */ -executor.logger.info(executor.subject.id); -executor.logger.info(executor.inFields); +executor.logger.info(executor.getSubject().getId()); var returnValue = executor.isTrue; diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskFetchHttpCode.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskFetchHttpCode.js index 5916a23b2..3bf129bf8 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskFetchHttpCode.js +++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskFetchHttpCode.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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,16 +18,15 @@ * ============LICENSE_END========================================================= */ -executor.logger.info(executor.subject.id); -executor.logger.info(executor.inFields); +executor.logger.info(executor.getSubject().getId()); -executor.logger.info(executor.outFields); +executor.logger.info("executionProperties: " + executor.getExecutionProperties()); -executor.logger.info("executionProperties:" + executor.getExecutionProperties()); - -if (executor.getExecutionProperties() == "{HTTP_CODE_STATUS=500}" ) +if (executor.getExecutionProperties().get("HTTP_CODE_STATUS") == "500") executor.outFields.put("testToRun", "CodeFilterSet"); else executor.outFields.put("testToRun", "CodeFilterDefault"); +executor.logger.info("testToRun: " + executor.outFields.get("testToRun")); + var returnValue = executor.isTrue;
\ No newline at end of file diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskTagUrl.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskTagUrl.js index 4a8ff30f1..b584ec464 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskTagUrl.js +++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskTagUrl.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * 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,10 +18,7 @@ * ============LICENSE_END========================================================= */ -executor.logger.info(executor.subject.id); -executor.logger.info(executor.inFields); - -executor.logger.info(executor.outFields); +executor.logger.info(executor.getSubject().getId()); executor.logger.info("executionProperties in:" + executor.getExecutionProperties()); diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/policy/ExecutionPropertiesRestTestPolicyModel.apex b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/policy/ExecutionPropertiesRestTestPolicyModel.apex index 053e05349..6e0f4f2f8 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/policy/ExecutionPropertiesRestTestPolicyModel.apex +++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/policy/ExecutionPropertiesRestTestPolicyModel.apex @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------- # ============LICENSE_START======================================================= -# Copyright (C) 2019 Nordix Foundation. +# 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. @@ -47,7 +47,6 @@ task logic create name=TaskTagUrl logicFlavour=JAVASCRIPT logic=LS #MACROFILE:"src/test/resources/policies/executionproperties/logic/TaskTagUrl.js" LE - policy create name=Policy2 template=freestyle firstState=Junit policy state create name=Policy2 stateName=Decide triggerName=Event0201 defaultTaskName=TaskTagUrl @@ -58,7 +57,4 @@ policy state create name=Policy2 stateName=Junit triggerName=Event0200 defaultTa policy state output create name=Policy2 stateName=Junit outputName=HttpCodeOut eventName=Event0201 nextState=Decide policy state taskref create name=Policy2 stateName=Junit taskLocalName=check taskName=TaskFetchHttpCode outputType=DIRECT outputName=HttpCodeOut - - validate - diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetControlLoopNameForTest.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetControlLoopNameForTest.js index a4ab0360f..9d02b0228 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetControlLoopNameForTest.js +++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetControlLoopNameForTest.js @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ -executor.logger.info(executor.subject.id); -executor.logger.info(executor.inFields); -executor.logger.info(executor.outFields); -executor.logger.info(executor.parameters); +executor.logger.info(executor.getSubject().getId()); +executor.logger.info(executor.getInFields().toString()); +executor.logger.info(executor.getOutFields().toString()); +executor.logger.info(executor.getParameters().toString()); -executor.logger.info("executionProperties in: {}", executor.getExecutionProperties()); +executor.logger.info("executionProperties in: {}", executor.getExecutionProperties().toString()); executor.getExecutionProperties().setProperty("tagId", "doActionForCL"); -var closedLoopId = executor.parameters.get("closedLoopId") +var closedLoopId = executor.getParameters().get("closedLoopId") if (null == closedLoopId) { closedLoopId = "INVALID - closedLoopId not available in TaskParameters" } executor.getExecutionProperties().setProperty("value", closedLoopId); -executor.logger.info("executionProperties out: {}", executor.getExecutionProperties()); +executor.logger.info("executionProperties out: {}", executor.getExecutionProperties().toString()); var returnValue = executor.isTrue;
\ No newline at end of file diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetServiceIdForTest.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetServiceIdForTest.js index 6d56616d8..814e30217 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetServiceIdForTest.js +++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetServiceIdForTest.js @@ -18,19 +18,19 @@ * ============LICENSE_END========================================================= */ -executor.logger.info(executor.subject.id); -executor.logger.info(executor.inFields); -executor.logger.info(executor.outFields); -executor.logger.info(executor.parameters); +executor.logger.info(executor.getSubject().getId()); +executor.logger.info(executor.getInFields().toString()); +executor.logger.info(executor.getOutFields().toString()); +executor.logger.info(executor.getParameters().toString()); -executor.logger.info("executionProperties in: {}", executor.getExecutionProperties()); +executor.logger.info("executionProperties in: {}", executor.getExecutionProperties().toString()); executor.getExecutionProperties().setProperty("tagId", "getInfoForServiceId"); -var svcId = executor.parameters.get("serviceId") +var svcId = executor.getParameters().get("serviceId") if (null == svcId) { svcId = "INVALID - serviceId not available in TaskParameters" } executor.getExecutionProperties().setProperty("value", svcId); -executor.logger.info("executionProperties out: {}", executor.getExecutionProperties()); +executor.logger.info("executionProperties out: {}", executor.getExecutionProperties().toString()); var returnValue = executor.isTrue;
\ No newline at end of file diff --git a/testsuites/integration/pom.xml b/testsuites/integration/pom.xml index 8ec0d387c..885ac72ee 100644 --- a/testsuites/integration/pom.xml +++ b/testsuites/integration/pom.xml @@ -34,8 +34,8 @@ <modules> <module>integration-common</module> - <!-- module>integration-executor-test</module--> - <!-- module>integration-uservice-test</module--> + <!--module>integration-executor-test</module--> + <!--module>integration-uservice-test</module--> </modules> <dependencies> |