From 9e5c4b882728ebf3330568d068f109965d599410 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 2 Mar 2020 17:08:47 +0000 Subject: Preparing integration tests for Graal Javascript Graal enforces Javascript more strictly than Nashorn does. This review changes the tests in apex-pdp to comply with the stricter -Javascript checking, re-enabling the integration test module. - All log calls must be passed as strings, using toString() - Byte/Float/Long Java types not supported in Javascript Disable integration tests so that other changes can be brought in. JMS integration test is disabled for now, it will be re-enabled in a review shortly. Issue-ID: POLICY-2106 Change-Id: I14bdb930eff735e862b51802cf72e4793cec3699 Signed-off-by: liamfallon --- .../src/main/resources/examples/models/JMS/JMSTestModel.json | 2 +- .../common/model/javascript/DefaultStateLogic.javascript | 7 ++++--- .../common/model/javascript/DefaultTaskLogic.javascript | 9 +++++---- .../common/model/javascript/EvalStateLogic.javascript | 3 ++- .../integration/common/model/javascript/EvalTaskLogic.javascript | 7 ++++--- 5 files changed, 16 insertions(+), 12 deletions(-) (limited to 'testsuites/integration/integration-common/src/main/resources') 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("TestCaseSelected", new caseSelectedType()); executor.outFields.put("TestStateTime", 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("StateTimestamp", java.lang.System.nanoTime()); -executor.logger.debug(executor.outFields); +executor.logger.debug(executor.outFields.get("name")); var returnValue = executor.isTrue; -- cgit 1.2.3-korg