diff options
author | liamfallon <liam.fallon@est.tech> | 2020-01-22 12:11:11 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2020-01-23 12:15:19 +0000 |
commit | 755eb9df282d80273043a2e902e2a51bf6eaab24 (patch) | |
tree | fb603fff3d378bb868dba63e3d766d7723e03839 /tools/model-generator | |
parent | 37da84e2a40f7f39fe73fa2ceb6a7166618e9ddb (diff) |
Run apex-pdp in Java 11: base changes
This change brings in the minimum changes to get apex-pdp running in
Java 11. Other reviews will bring in changes to remove Java 11 warnings
and to convert apex-pdp Javascript handling from the now deprecated
nashorn engine.
Issue-ID: POLICY-1581
Change-Id: I879bbae08d4e67aca3f1bfeedeca639d8dbbc281
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'tools/model-generator')
2 files changed, 34 insertions, 40 deletions
diff --git a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java index 14ff284b9..31f55bda4 100644 --- a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java +++ b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java @@ -1,19 +1,20 @@ /*- * ============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. * 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========================================================= */ @@ -62,14 +63,13 @@ public class SchemaUtilsTest { /** * Read the models into strings. - * + * * @throws IOException on model reading errors * @throws ApexModelException on model reading exceptions */ @BeforeClass public static void readSimpleModel() throws IOException, ApexModelException { - String avroModelString = TextFileUtils - .getTextFileAsString("target/examples/models/pcvs/vpnsla/PCVS-VpnSla.json"); + String avroModelString = TextFileUtils.getTextFileAsString("target/examples/models/pcvs/vpnsla/vpnsla.json"); final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class); avroModel = modelReader.read(new ByteArrayInputStream(avroModelString.getBytes())); @@ -86,7 +86,7 @@ public class SchemaUtilsTest { fail("test should throw an exception"); } catch (Exception apEx) { assertEquals("Model for org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas" - + " not found in model service", apEx.getMessage()); + + " not found in model service", apEx.getMessage()); } try { @@ -95,7 +95,7 @@ public class SchemaUtilsTest { fail("test should throw an exception"); } catch (Exception apEx) { assertEquals("Model for org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas" - + " not found in model service", apEx.getMessage()); + + " not found in model service", apEx.getMessage()); } List<Field> skeletonFields = SchemaUtils.getSkeletonEventSchemaFields(); @@ -103,14 +103,14 @@ public class SchemaUtilsTest { try { AvroSchemaHelper schemaHelper = (AvroSchemaHelper) new SchemaHelperFactory() - .createSchemaHelper(topoNodesKey, avroCtxtSchema.getKey()); + .createSchemaHelper(topoNodesKey, avroCtxtSchema.getKey()); Map<String, Schema> schemaMap = new LinkedHashMap<>(); SchemaUtils.processSubSchemas(schemaHelper.getAvroSchema(), schemaMap); fail("test should throw an exception"); } catch (Exception apEx) { assertEquals("Model for org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas" - + " not found in model service", apEx.getMessage()); + + " not found in model service", apEx.getMessage()); } } @@ -130,11 +130,11 @@ public class SchemaUtilsTest { Schema eventSchema = SchemaUtils.getEventSchema(event); assertEquals("{\"type\":\"record\",\"name\":\"CustomerContextEventIn\"", - eventSchema.toString().substring(0, 48)); + eventSchema.toString().substring(0, 48)); Map<String, Schema> preexistingParamSchemas = new LinkedHashMap<>(); - Schema epSchema = SchemaUtils.getEventParameterSchema(event.getParameterMap().get("links"), - preexistingParamSchemas); + Schema epSchema = + SchemaUtils.getEventParameterSchema(event.getParameterMap().get("links"), preexistingParamSchemas); assertEquals("\"string\"", epSchema.toString()); List<Field> skeletonFields = SchemaUtils.getSkeletonEventSchemaFields(); @@ -142,7 +142,7 @@ public class SchemaUtilsTest { try { AvroSchemaHelper schemaHelper = (AvroSchemaHelper) new SchemaHelperFactory() - .createSchemaHelper(topoNodesKey, avroCtxtSchema.getKey()); + .createSchemaHelper(topoNodesKey, avroCtxtSchema.getKey()); Map<String, Schema> schemaMap = new LinkedHashMap<>(); SchemaUtils.processSubSchemas(schemaHelper.getAvroSchema(), schemaMap); @@ -153,8 +153,8 @@ public class SchemaUtilsTest { schemaParameters.getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters()); - AvroSchemaHelper schemaHelper = (AvroSchemaHelper) new SchemaHelperFactory().createSchemaHelper(topoNodesKey, - avroCtxtSchema.getKey()); + AvroSchemaHelper schemaHelper = + (AvroSchemaHelper) new SchemaHelperFactory().createSchemaHelper(topoNodesKey, avroCtxtSchema.getKey()); Map<String, Schema> schemaMap = new LinkedHashMap<>(); try { @@ -165,13 +165,13 @@ public class SchemaUtilsTest { eventSchema = SchemaUtils.getEventSchema(event); assertEquals("{\"type\":\"record\",\"name\":\"CustomerContextEventIn\"", - eventSchema.toString().substring(0, 48)); + eventSchema.toString().substring(0, 48)); epSchema = SchemaUtils.getEventParameterSchema(event.getParameterMap().get("links"), preexistingParamSchemas); assertEquals("\"string\"", epSchema.toString()); - AxInputField inField = new AxInputField(new AxReferenceKey("FieldParent", "0.0.1", "Field"), - avroCtxtSchema.getKey(), false); + AxInputField inField = + new AxInputField(new AxReferenceKey("FieldParent", "0.0.1", "Field"), avroCtxtSchema.getKey(), false); Schema ep2Schema = SchemaUtils.getEventParameterSchema(inField, preexistingParamSchemas); assertEquals("{\"type\":\"record\",\"name\":\"TopologyNodes\"", ep2Schema.toString().substring(0, 39)); diff --git a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java index fdf862930..bfb134332 100644 --- a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java +++ b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java @@ -1,19 +1,20 @@ /*- * ============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. * 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========================================================= */ @@ -37,8 +38,7 @@ public class Model2CliTest { @Test public void testModel2Cli() { try { - final String[] cliArgs = - { "-h" }; + final String[] cliArgs = {"-h"}; Model2CliMain.main(cliArgs); } catch (Exception exc) { @@ -48,19 +48,16 @@ public class Model2CliTest { @Test public void testModel2CliNoOptions() { - final String[] cliArgs = new String[] - {}; + final String[] cliArgs = new String[] {}; final String outputString = runModel2Cli(cliArgs); - assertTrue(outputString - .contains("gen-model2cli: no '-m' model file given, cannot proceed (try -h for help)")); + assertTrue(outputString.contains("gen-model2cli: no '-m' model file given, cannot proceed (try -h for help)")); } @Test public void testModel2CliBadOptions() { - final String[] cliArgs = - { "-zabbu" }; + final String[] cliArgs = {"-zabbu"}; final String outputString = runModel2Cli(cliArgs); @@ -69,8 +66,7 @@ public class Model2CliTest { @Test public void testModel2CliHelp() { - final String[] cliArgs = - { "-h" }; + final String[] cliArgs = {"-h"}; final String outputString = runModel2Cli(cliArgs); @@ -79,8 +75,7 @@ public class Model2CliTest { @Test public void testModel2CliVersion() { - final String[] cliArgs = - { "-v" }; + final String[] cliArgs = {"-v"}; final String outputString = runModel2Cli(cliArgs); @@ -92,8 +87,7 @@ public class Model2CliTest { File tempFile = File.createTempFile("AvroModel", ".apex"); tempFile.deleteOnExit(); - final String[] cliArgs = - { "-m", "src/test/resources/models/AvroModel.json", "-o", tempFile.getCanonicalPath() }; + final String[] cliArgs = {"-m", "src/test/resources/models/AvroModel.json", "-o", tempFile.getCanonicalPath()}; final String outputString = runModel2Cli(cliArgs); @@ -102,7 +96,7 @@ public class Model2CliTest { @Test public void testModel2CliAvro() throws IOException { - testModel2CliModel("target/examples/models/pcvs/vpnsla", "PCVS-VpnSla"); + testModel2CliModel("target/examples/models/pcvs/vpnsla", "vpnsla"); } @Test @@ -137,7 +131,7 @@ public class Model2CliTest { /** * Run the application. - * + * * @param cliArgs the command arguments * @return a string containing the command output */ @@ -155,7 +149,7 @@ public class Model2CliTest { /** * Test CLI generation. - * + * * @param modelName the name of the model file */ private void testModel2CliModel(final String modelPath, final String modelName) { @@ -164,7 +158,7 @@ public class Model2CliTest { tempFile.deleteOnExit(); final String[] cliArgs = - { "-m", modelPath + "/" + modelName + ".json", "-o", tempFile.getCanonicalPath(), "-ow" }; + {"-m", modelPath + "/" + modelName + ".json", "-o", tempFile.getCanonicalPath(), "-ow"}; runModel2Cli(cliArgs); assertTrue(tempFile.isFile()); |