From e8b197315437cac84872752e2ea090d8fb233941 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Tue, 20 Nov 2018 14:46:45 +0900 Subject: Rename test classes in apex-pdp Make test classes name consistence under auth, model, plugins, testsuits, tools projects Issue-ID: POLICY-1263 Change-Id: I49ec9a9f5b457d6381e693de2c04ec0268ad1b02 Signed-off-by: Parshad Patel --- .../apex/auth/clicodegen/GenerationTest.java | 138 +++++++++++++++++++++ .../apex/auth/clicodegen/TestGeneration.java | 138 --------------------- 2 files changed, 138 insertions(+), 138 deletions(-) create mode 100644 auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/GenerationTest.java delete mode 100644 auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestGeneration.java (limited to 'auth/cli-codegen') diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/GenerationTest.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/GenerationTest.java new file mode 100644 index 000000000..3b79e805c --- /dev/null +++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/GenerationTest.java @@ -0,0 +1,138 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * 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.auth.clicodegen; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import org.junit.Test; +import org.onap.policy.apex.auth.clicodegen.CodeGeneratorCliEditor; +import org.stringtemplate.v4.STGroup; +import org.stringtemplate.v4.STGroupFile; + +/** + * Test for the CG CLI Editor STG file. + * + * @author Sven van der Meer (sven.van.der.meer@ericsson.com) + */ +public class GenerationTest { + + /** + * Get the chunks for the codegen. + * + * @return the chunks + */ + private static Map> getCodeGenChunks() { + // CHECKSTYLE:OFF: LineLength + + final Map> chunks = new LinkedHashMap<>(); + + chunks.put("/policyModel", + Arrays.asList("name", "version", "uuid", "description", "declarations", "definitions")); + chunks.put("/schemaDecl", Arrays.asList("name", "version", "uuid", "description", "flavour", "schema")); + chunks.put("/ctxAlbumDecl", Arrays.asList("name", "version", "uuid", "description", "scope", "writable", + "schemaName", "schemaVersion")); + chunks.put("/eventDecl", + Arrays.asList("name", "version", "uuid", "description", "nameSpace", "source", "target", "fields")); + chunks.put("/eventDefField", + Arrays.asList("eventName", "version", "fieldName", "fieldSchema", "fieldSchemaVersion", "optional")); + chunks.put("/taskDecl", + Arrays.asList("name", "version", "uuid", "description", "infields", "outfields", "logic")); + chunks.put("/taskDefInputFields", + Arrays.asList("taskName", "version", "fieldName", "fieldSchema", "fieldSchemaVersion")); + chunks.put("/taskDefOutputFields", + Arrays.asList("taskName", "version", "fieldName", "fieldSchema", "fieldSchemaVersion")); + chunks.put("/taskDefLogic", Arrays.asList("taskName", "version", "flavour", "logic")); + chunks.put("/taskDefParameter", Arrays.asList("name", "version", "parName", "defaultValue")); + chunks.put("/taskDefCtxRef", Arrays.asList("name", "version", "albumName", "albumVersion")); + chunks.put("/policyDef", Arrays.asList("name", "version", "uuid", "description", "template", "firstState")); + chunks.put("/policyStateDef", Arrays.asList("policyName", "version", "stateName", "triggerName", + "triggerVersion", "defaultTask", "defaultTaskVersion", "outputs", "tasks")); + chunks.put("/policyStateOutput", Arrays.asList("policyName", "version", "stateName", "outputName", "eventName", + "eventVersion", "nextState")); + chunks.put("/policyStateTaskSelectionLogic", + Arrays.asList("name", "version", "stateName", "logicFlavour", "logic")); + chunks.put("/policyStateTask", Arrays.asList("policyName", "version", "stateName", "taskLocalName", "taskName", + "taskVersion", "outputType", "outputName")); + chunks.put("/policyStateFinalizerLogic", + Arrays.asList("name", "version", "stateName", "finalizerLogicName", "logicFlavour", "logic")); + chunks.put("/policyStateContextRef", + Arrays.asList("name", "version", "stateName", "albumName", "albumVersion")); + + return chunks; + // CHECKSTYLE:ON: LineLength + } + + /** Test STG load. */ + @Test + public void testGenerationLoad() { + final StErrorListener errListener = new StErrorListener(); + final STGroupFile stg = new STGroupFile(CodeGeneratorCliEditor.STG_FILE); + stg.setListener(errListener); + + stg.getTemplateNames(); // dummy to compile group and get errors + assertEquals(0, errListener.getErrorCount()); + } + + /** Test STG chunks. */ + @Test + public void testGenerationChunks() { + final StErrorListener errListener = new StErrorListener(); + final STGroupFile stg = new STGroupFile(CodeGeneratorCliEditor.STG_FILE); + stg.setListener(errListener); + + stg.getTemplateNames(); // dummy to compile group and get errors + final Map> chunks = getCodeGenChunks(); + String error = ""; + final Set definedNames = stg.getTemplateNames(); + for (final STGroup group : stg.getImportedGroups()) { + definedNames.addAll(group.getTemplateNames()); + } + final Set requiredNames = chunks.keySet(); + + for (final String required : requiredNames) { + if (!definedNames.contains(required)) { + error += " - target STG does not define template for <" + required + ">\n"; + } else { + final Set definedParams = ((stg.getInstanceOf(required).getAttributes() == null) + ? new TreeSet() : stg.getInstanceOf(required).getAttributes().keySet()); + final List requiredParams = chunks.get(required); + for (final String reqArg : requiredParams) { + if (!definedParams.contains(reqArg)) { + error += " - target STG with template <" + required + "> does not define argument <" + reqArg + + ">\n"; + } + } + } + } + + if (!("".equals(error))) { + System.err.println(error); + } + assertEquals(0, error.length()); + } +} diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestGeneration.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestGeneration.java deleted file mode 100644 index 851c06631..000000000 --- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestGeneration.java +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * 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.auth.clicodegen; - -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import org.junit.Test; -import org.onap.policy.apex.auth.clicodegen.CodeGeneratorCliEditor; -import org.stringtemplate.v4.STGroup; -import org.stringtemplate.v4.STGroupFile; - -/** - * Test for the CG CLI Editor STG file. - * - * @author Sven van der Meer (sven.van.der.meer@ericsson.com) - */ -public class TestGeneration { - - /** - * Get the chunks for the codegen. - * - * @return the chunks - */ - private static Map> getCodeGenChunks() { - // CHECKSTYLE:OFF: LineLength - - final Map> chunks = new LinkedHashMap<>(); - - chunks.put("/policyModel", - Arrays.asList("name", "version", "uuid", "description", "declarations", "definitions")); - chunks.put("/schemaDecl", Arrays.asList("name", "version", "uuid", "description", "flavour", "schema")); - chunks.put("/ctxAlbumDecl", Arrays.asList("name", "version", "uuid", "description", "scope", "writable", - "schemaName", "schemaVersion")); - chunks.put("/eventDecl", - Arrays.asList("name", "version", "uuid", "description", "nameSpace", "source", "target", "fields")); - chunks.put("/eventDefField", - Arrays.asList("eventName", "version", "fieldName", "fieldSchema", "fieldSchemaVersion", "optional")); - chunks.put("/taskDecl", - Arrays.asList("name", "version", "uuid", "description", "infields", "outfields", "logic")); - chunks.put("/taskDefInputFields", - Arrays.asList("taskName", "version", "fieldName", "fieldSchema", "fieldSchemaVersion")); - chunks.put("/taskDefOutputFields", - Arrays.asList("taskName", "version", "fieldName", "fieldSchema", "fieldSchemaVersion")); - chunks.put("/taskDefLogic", Arrays.asList("taskName", "version", "flavour", "logic")); - chunks.put("/taskDefParameter", Arrays.asList("name", "version", "parName", "defaultValue")); - chunks.put("/taskDefCtxRef", Arrays.asList("name", "version", "albumName", "albumVersion")); - chunks.put("/policyDef", Arrays.asList("name", "version", "uuid", "description", "template", "firstState")); - chunks.put("/policyStateDef", Arrays.asList("policyName", "version", "stateName", "triggerName", - "triggerVersion", "defaultTask", "defaultTaskVersion", "outputs", "tasks")); - chunks.put("/policyStateOutput", Arrays.asList("policyName", "version", "stateName", "outputName", "eventName", - "eventVersion", "nextState")); - chunks.put("/policyStateTaskSelectionLogic", - Arrays.asList("name", "version", "stateName", "logicFlavour", "logic")); - chunks.put("/policyStateTask", Arrays.asList("policyName", "version", "stateName", "taskLocalName", "taskName", - "taskVersion", "outputType", "outputName")); - chunks.put("/policyStateFinalizerLogic", - Arrays.asList("name", "version", "stateName", "finalizerLogicName", "logicFlavour", "logic")); - chunks.put("/policyStateContextRef", - Arrays.asList("name", "version", "stateName", "albumName", "albumVersion")); - - return chunks; - // CHECKSTYLE:ON: LineLength - } - - /** Test STG load. */ - @Test - public void testGenerationLoad() { - final StErrorListener errListener = new StErrorListener(); - final STGroupFile stg = new STGroupFile(CodeGeneratorCliEditor.STG_FILE); - stg.setListener(errListener); - - stg.getTemplateNames(); // dummy to compile group and get errors - assertEquals(0, errListener.getErrorCount()); - } - - /** Test STG chunks. */ - @Test - public void testGenerationChunks() { - final StErrorListener errListener = new StErrorListener(); - final STGroupFile stg = new STGroupFile(CodeGeneratorCliEditor.STG_FILE); - stg.setListener(errListener); - - stg.getTemplateNames(); // dummy to compile group and get errors - final Map> chunks = getCodeGenChunks(); - String error = ""; - final Set definedNames = stg.getTemplateNames(); - for (final STGroup group : stg.getImportedGroups()) { - definedNames.addAll(group.getTemplateNames()); - } - final Set requiredNames = chunks.keySet(); - - for (final String required : requiredNames) { - if (!definedNames.contains(required)) { - error += " - target STG does not define template for <" + required + ">\n"; - } else { - final Set definedParams = ((stg.getInstanceOf(required).getAttributes() == null) - ? new TreeSet() : stg.getInstanceOf(required).getAttributes().keySet()); - final List requiredParams = chunks.get(required); - for (final String reqArg : requiredParams) { - if (!definedParams.contains(reqArg)) { - error += " - target STG with template <" + required + "> does not define argument <" + reqArg - + ">\n"; - } - } - } - } - - if (!("".equals(error))) { - System.err.println(error); - } - assertEquals(0, error.length()); - } -} -- cgit 1.2.3-korg