aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorning.xi <ning.xi@est.tech>2019-08-22 03:11:18 +0000
committerning.xi <ning.xi@est.tech>2019-08-22 03:11:18 +0000
commit436273994a0a3f13a8e43317e2163e6903995498 (patch)
tree61f991676028caaf41173939e1af32e135de70b8
parent5bf11a7500944b8b306c5d4f478e4bc45ef1fb51 (diff)
test case of model generator
Issue-ID: POLICY-1992 Change-Id: I90143d9903e0ada74dd9efba80aa6589b9f3dff4 Signed-off-by: ning.xi <ning.xi@est.tech>
-rw-r--r--tools/model-generator/pom.xml5
-rw-r--r--tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventSchemaTest.java142
-rw-r--r--tools/model-generator/src/test/resources/ExecutionPropertiesRestTestPolicyModel.json530
-rw-r--r--tools/model-generator/src/test/resources/SmallModel.json416
-rw-r--r--tools/model-generator/src/test/resources/blankSchema.json0
5 files changed, 1093 insertions, 0 deletions
diff --git a/tools/model-generator/pom.xml b/tools/model-generator/pom.xml
index 7e7dd932d..16ddb769d 100644
--- a/tools/model-generator/pom.xml
+++ b/tools/model-generator/pom.xml
@@ -62,6 +62,11 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventSchemaTest.java b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventSchemaTest.java
new file mode 100644
index 000000000..552101f94
--- /dev/null
+++ b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventSchemaTest.java
@@ -0,0 +1,142 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.tools.model.generator.model2event;
+
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import org.apache.avro.Schema;
+import org.apache.avro.Schema.Field;
+import org.apache.avro.Schema.Type;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+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.SchemaParameters;
+import org.onap.policy.apex.model.basicmodel.service.ModelService;
+import org.onap.policy.common.parameters.ParameterService;
+import org.stringtemplate.v4.STGroupFile;
+
+/**
+ * Test the Model2EventSchema.
+ */
+public class Model2EventSchemaTest {
+ String modelFile = "src/test/resources/blankSchema.json";
+ String type = "stimuli";
+ /** The name of the application. */
+ public static final String APP_NAME = "gen-model2eventSchema";
+
+ /**
+ * Set ups parameterService for the test.
+ */
+ @BeforeClass
+ public static void prepareForTest() {
+ final SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+ if (!ParameterService.contains(ContextParameterConstants.SCHEMA_GROUP_NAME)) {
+ ParameterService.register(schemaParameters);
+ }
+ }
+
+ @Test
+ public void testEventSchemaBadModelFile() {
+ Model2JsonEventSchema app = new Model2JsonEventSchema(modelFile, type, APP_NAME);
+ assertThatCode(() -> {
+ int ret = app.runApp();
+ assertEquals(-1, ret);
+ }).doesNotThrowAnyException();
+
+ }
+
+ @Test
+ public void testEventSchemaBadType() {
+ modelFile = "src/test/resources/SmallModel.json";
+ type = "default";
+ Model2JsonEventSchema app = new Model2JsonEventSchema(modelFile, type, APP_NAME);
+ assertThatCode(() -> {
+ int ret = app.runApp();
+ assertEquals(-1, ret);
+ }).doesNotThrowAnyException();
+ }
+
+ @Test
+ public void testEventSchemaStimuli() {
+ modelFile = "src/test/resources/SmallModel.json";
+ type = "stimuli";
+ Model2JsonEventSchema app = new Model2JsonEventSchema(modelFile, type, APP_NAME);
+ assertThatCode(() -> {
+ int ret = app.runApp();
+ assertEquals(0, ret);
+ }).doesNotThrowAnyException();
+ }
+
+ @Test
+ public void testEventSchemaResponse() {
+ modelFile = "src/test/resources/SmallModel.json";
+ type = "response";
+ Model2JsonEventSchema app = new Model2JsonEventSchema(modelFile, type, APP_NAME);
+ assertThatCode(() -> {
+ int ret = app.runApp();
+ assertEquals(0, ret);
+ }).doesNotThrowAnyException();
+ }
+
+ @Test
+ public void testEventSchemaInternal() {
+ modelFile = "src/test/resources/SmallModel.json";
+ type = "internal";
+ Model2JsonEventSchema app = new Model2JsonEventSchema(modelFile, type, APP_NAME);
+ assertThatCode(() -> {
+ int ret = app.runApp();
+ assertEquals(0, ret);
+ }).doesNotThrowAnyException();
+ }
+
+ @Test
+ public void testEventSchemaNotSimpleType() {
+ modelFile = "src/test/resources/ExecutionPropertiesRestTestPolicyModel.json";
+ type = "internal";
+ Model2JsonEventSchema app = new Model2JsonEventSchema(modelFile, type, APP_NAME);
+ final STGroupFile stg = new STGroupFile("org/onap/policy/apex/tools/model/generator/event-json.stg");
+
+ Field stringField = new Field("string", Schema.create(Type.STRING), null, null);
+ Field enumField =
+ new Field("enum", Schema.createEnum("my_enum", "doc", null, Arrays.asList("a", "b", "c")), null, null);
+ Schema schema = Schema.createRecord("my_record", "doc", "mytest", false);
+ schema.setFields(Arrays.asList(stringField, enumField));
+ Schema arrayOut = Schema.createArray(schema);
+ Schema mapOut = Schema.createMap(arrayOut);
+ app.addFieldType(mapOut, stg);
+ assertThatCode(() -> {
+ int ret = app.runApp();
+ assertEquals(0, ret);
+ }).doesNotThrowAnyException();
+ }
+
+ @AfterClass
+ public static void cleanTest() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ ModelService.clear();
+ }
+} \ No newline at end of file
diff --git a/tools/model-generator/src/test/resources/ExecutionPropertiesRestTestPolicyModel.json b/tools/model-generator/src/test/resources/ExecutionPropertiesRestTestPolicyModel.json
new file mode 100644
index 000000000..14a6234e3
--- /dev/null
+++ b/tools/model-generator/src/test/resources/ExecutionPropertiesRestTestPolicyModel.json
@@ -0,0 +1,530 @@
+{
+ "apexPolicyModel" : {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel",
+ "version" : "0.0.1"
+ },
+ "keyInformation" : {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_KeyInfo",
+ "version" : "0.0.1"
+ },
+ "keyInfoMap" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "Event0200",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "Event0200",
+ "version" : "0.0.1"
+ },
+ "UUID" : "7be89b0e-07a6-38fe-a8fb-94f3f3473883",
+ "description" : "Generated description for concept referred to by key \"Event0200:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "Event0201",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "Event0201",
+ "version" : "0.0.1"
+ },
+ "UUID" : "a44bcbd7-c30e-3a78-a9be-3cd3cecf1c93",
+ "description" : "Generated description for concept referred to by key \"Event0201:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel",
+ "version" : "0.0.1"
+ },
+ "UUID" : "08ff4009-748a-3b9c-90f8-a4ac19ebb472",
+ "description" : "Generated description for concept referred to by key \"ExecutionPropertiesRestTestPolicyModel:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_Events",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_Events",
+ "version" : "0.0.1"
+ },
+ "UUID" : "afe732b9-baff-3235-a75c-29a0669b0d1d",
+ "description" : "Generated description for concept referred to by key \"ExecutionPropertiesRestTestPolicyModel_Events:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_KeyInfo",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_KeyInfo",
+ "version" : "0.0.1"
+ },
+ "UUID" : "9ec07b81-7488-3b33-907e-335256c96e08",
+ "description" : "Generated description for concept referred to by key \"ExecutionPropertiesRestTestPolicyModel_KeyInfo:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_Policies",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_Policies",
+ "version" : "0.0.1"
+ },
+ "UUID" : "c1df0d76-7445-32ca-914f-06167254fbce",
+ "description" : "Generated description for concept referred to by key \"ExecutionPropertiesRestTestPolicyModel_Policies:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_Schemas",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_Schemas",
+ "version" : "0.0.1"
+ },
+ "UUID" : "9984fed6-9ec5-3c69-a458-5033767f00f1",
+ "description" : "Generated description for concept referred to by key \"ExecutionPropertiesRestTestPolicyModel_Schemas:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_Tasks",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_Tasks",
+ "version" : "0.0.1"
+ },
+ "UUID" : "08f87bf9-4056-30de-8c4e-179f06bdaabb",
+ "description" : "Generated description for concept referred to by key \"ExecutionPropertiesRestTestPolicyModel_Tasks:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "Policy2",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "Policy2",
+ "version" : "0.0.1"
+ },
+ "UUID" : "9d2804df-f77d-3018-a024-5c6f7fd8e60e",
+ "description" : "Generated description for concept referred to by key \"Policy2:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "SimpleStringType",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "SimpleStringType",
+ "version" : "0.0.1"
+ },
+ "UUID" : "8a4957cf-9493-3a76-8c22-a208e23259af",
+ "description" : "Generated description for concept referred to by key \"SimpleStringType:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "TaskFetchHttpCode",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "TaskFetchHttpCode",
+ "version" : "0.0.1"
+ },
+ "UUID" : "0a776ac8-cc11-37a5-8f40-7262a31ada0a",
+ "description" : "Generated description for concept referred to by key \"TaskFetchHttpCode:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "TaskTagUrl",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "TaskTagUrl",
+ "version" : "0.0.1"
+ },
+ "UUID" : "638c559b-dc94-3d71-bdb0-c4bdeb042de3",
+ "description" : "Generated description for concept referred to by key \"TaskTagUrl:0.0.1\""
+ }
+ } ]
+ }
+ },
+ "policies" : {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_Policies",
+ "version" : "0.0.1"
+ },
+ "policyMap" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "Policy2",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "policyKey" : {
+ "name" : "Policy2",
+ "version" : "0.0.1"
+ },
+ "template" : "freestyle",
+ "state" : {
+ "entry" : [ {
+ "key" : "Decide",
+ "value" : {
+ "stateKey" : {
+ "parentKeyName" : "Policy2",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "NULL",
+ "localName" : "Decide"
+ },
+ "trigger" : {
+ "name" : "Event0201",
+ "version" : "0.0.1"
+ },
+ "stateOutputs" : {
+ "entry" : [ {
+ "key" : "TagUrlOut",
+ "value" : {
+ "key" : {
+ "parentKeyName" : "Policy2",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "Decide",
+ "localName" : "TagUrlOut"
+ },
+ "outgoingEvent" : {
+ "name" : "Event0201",
+ "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" : "TaskTagUrl",
+ "version" : "0.0.1"
+ },
+ "taskReferences" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "TaskTagUrl",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "parentKeyName" : "Policy2",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "Decide",
+ "localName" : "tag"
+ },
+ "outputType" : "DIRECT",
+ "output" : {
+ "parentKeyName" : "Policy2",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "Decide",
+ "localName" : "TagUrlOut"
+ }
+ }
+ } ]
+ }
+ }
+ }, {
+ "key" : "Junit",
+ "value" : {
+ "stateKey" : {
+ "parentKeyName" : "Policy2",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "NULL",
+ "localName" : "Junit"
+ },
+ "trigger" : {
+ "name" : "Event0200",
+ "version" : "0.0.1"
+ },
+ "stateOutputs" : {
+ "entry" : [ {
+ "key" : "HttpCodeOut",
+ "value" : {
+ "key" : {
+ "parentKeyName" : "Policy2",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "Junit",
+ "localName" : "HttpCodeOut"
+ },
+ "outgoingEvent" : {
+ "name" : "Event0201",
+ "version" : "0.0.1"
+ },
+ "nextState" : {
+ "parentKeyName" : "Policy2",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "NULL",
+ "localName" : "Decide"
+ }
+ }
+ } ]
+ },
+ "contextAlbumReference" : [ ],
+ "taskSelectionLogic" : {
+ "key" : "NULL",
+ "logicFlavour" : "UNDEFINED",
+ "logic" : ""
+ },
+ "stateFinalizerLogicMap" : {
+ "entry" : [ ]
+ },
+ "defaultTask" : {
+ "name" : "TaskFetchHttpCode",
+ "version" : "0.0.1"
+ },
+ "taskReferences" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "TaskFetchHttpCode",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "parentKeyName" : "Policy2",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "Junit",
+ "localName" : "check"
+ },
+ "outputType" : "DIRECT",
+ "output" : {
+ "parentKeyName" : "Policy2",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "Junit",
+ "localName" : "HttpCodeOut"
+ }
+ }
+ } ]
+ }
+ }
+ } ]
+ },
+ "firstState" : "Junit"
+ }
+ } ]
+ }
+ },
+ "tasks" : {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_Tasks",
+ "version" : "0.0.1"
+ },
+ "taskMap" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "TaskFetchHttpCode",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "TaskFetchHttpCode",
+ "version" : "0.0.1"
+ },
+ "inputFields" : {
+ "entry" : [ {
+ "key" : "testToRun",
+ "value" : {
+ "key" : "testToRun",
+ "fieldSchemaKey" : {
+ "name" : "SimpleStringType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ },
+ "outputFields" : {
+ "entry" : [ {
+ "key" : "testToRun",
+ "value" : {
+ "key" : "testToRun",
+ "fieldSchemaKey" : {
+ "name" : "SimpleStringType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ },
+ "taskParameters" : {
+ "entry" : [ ]
+ },
+ "contextAlbumReference" : [ ],
+ "taskLogic" : {
+ "key" : "TaskLogic",
+ "logicFlavour" : "JAVASCRIPT",
+ "logic" : "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2019 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nexecutor.logger.info(executor.outFields);\n\nexecutor.logger.info(\"executionProperties:\" + executor.getExecutionProperties());\n\nif (executor.getExecutionProperties() == \"{HTTP_CODE_STATUS=500}\" )\nexecutor.outFields.put(\"testToRun\", \"CodeFilterSet\");\nelse\nexecutor.outFields.put(\"testToRun\", \"CodeFilterDefault\");\n\nvar returnValue = executor.isTrue;"
+ }
+ }
+ }, {
+ "key" : {
+ "name" : "TaskTagUrl",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "TaskTagUrl",
+ "version" : "0.0.1"
+ },
+ "inputFields" : {
+ "entry" : [ {
+ "key" : "testToRun",
+ "value" : {
+ "key" : "testToRun",
+ "fieldSchemaKey" : {
+ "name" : "SimpleStringType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ },
+ "outputFields" : {
+ "entry" : [ {
+ "key" : "testToRun",
+ "value" : {
+ "key" : "testToRun",
+ "fieldSchemaKey" : {
+ "name" : "SimpleStringType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ },
+ "taskParameters" : {
+ "entry" : [ ]
+ },
+ "contextAlbumReference" : [ ],
+ "taskLogic" : {
+ "key" : "TaskLogic",
+ "logicFlavour" : "JAVASCRIPT",
+ "logic" : "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2019 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nexecutor.logger.info(executor.outFields);\n\nexecutor.logger.info(\"executionProperties in:\" + executor.getExecutionProperties());\n\nexecutor.getExecutionProperties().setProperty(\"tagId\", executor.inFields.get(\"testToRun\"));\nexecutor.getExecutionProperties().setProperty(\"value\", \"3\");\n\nexecutor.logger.info(\"executionProperties out:\" + executor.getExecutionProperties());\n\nvar returnValue = executor.isTrue;"
+ }
+ }
+ } ]
+ }
+ },
+ "events" : {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_Events",
+ "version" : "0.0.1"
+ },
+ "eventMap" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "Event0200",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "Event0200",
+ "version" : "0.0.1"
+ },
+ "nameSpace" : "org.onap.policy.apex.domains.test",
+ "source" : "Junit",
+ "target" : "Decide",
+ "parameter" : {
+ "entry" : [ {
+ "key" : "testToRun",
+ "value" : {
+ "key" : "testToRun",
+ "fieldSchemaKey" : {
+ "name" : "SimpleStringType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ }
+ }
+ }, {
+ "key" : {
+ "name" : "Event0201",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "Event0201",
+ "version" : "0.0.1"
+ },
+ "nameSpace" : "org.onap.policy.apex.domains.test",
+ "source" : "Decide",
+ "target" : "OutSide",
+ "parameter" : {
+ "entry" : [ {
+ "key" : "testToRun",
+ "value" : {
+ "key" : "testToRun",
+ "fieldSchemaKey" : {
+ "name" : "SimpleStringType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ }
+ }
+ } ]
+ }
+ },
+ "schemas" : {
+ "key" : {
+ "name" : "ExecutionPropertiesRestTestPolicyModel_Schemas",
+ "version" : "0.0.1"
+ },
+ "schemas" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "SimpleStringType",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "SimpleStringType",
+ "version" : "0.0.1"
+ },
+ "schemaFlavour" : "Java",
+ "schemaDefinition" : "java.lang.String"
+ }
+ } ]
+ }
+ }
+ }
+}
diff --git a/tools/model-generator/src/test/resources/SmallModel.json b/tools/model-generator/src/test/resources/SmallModel.json
new file mode 100644
index 000000000..5c0628809
--- /dev/null
+++ b/tools/model-generator/src/test/resources/SmallModel.json
@@ -0,0 +1,416 @@
+{
+ "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" : "BasicEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "BasicEvent",
+ "version" : "0.0.1"
+ },
+ "UUID" : "cc8d3c1a-e975-459a-bcd2-69f423eaa1f3",
+ "description" : "Generated description for a concept called \"BasicEvent\" with version \"0.0.1\" and UUID \"cc8d3c1a-e975-459a-bcd2-69f423eaa1f3\""
+ }
+ }, {
+ "key" : {
+ "name" : "BasicPolicy",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "BasicPolicy",
+ "version" : "0.0.1"
+ },
+ "UUID" : "d0c5d8ee-5fe7-4978-89ce-4a3e69cad043",
+ "description" : "Generated description for a concept called \"BasicPolicy\" with version \"0.0.1\" and UUID \"d0c5d8ee-5fe7-4978-89ce-4a3e69cad043\""
+ }
+ }, {
+ "key" : {
+ "name" : "BasicTask",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "BasicTask",
+ "version" : "0.0.1"
+ },
+ "UUID" : "c5651414-fc1c-493b-878d-75f0ce685c36",
+ "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" : "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" : "BasicPolicy",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "policyKey" : {
+ "name" : "BasicPolicy",
+ "version" : "0.0.1"
+ },
+ "template" : "FREEFORM",
+ "state" : {
+ "entry" : [ {
+ "key" : "OnlyState",
+ "value" : {
+ "stateKey" : {
+ "parentKeyName" : "BasicPolicy",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "NULL",
+ "localName" : "OnlyState"
+ },
+ "trigger" : {
+ "name" : "BasicEvent",
+ "version" : "0.0.1"
+ },
+ "stateOutputs" : {
+ "entry" : [ {
+ "key" : "OnlyOutput",
+ "value" : {
+ "key" : {
+ "parentKeyName" : "BasicPolicy",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "OnlyState",
+ "localName" : "OnlyOutput"
+ },
+ "outgoingEvent" : {
+ "name" : "BasicEvent",
+ "version" : "0.0.1"
+ },
+ "nextState" : {
+ "parentKeyName" : "NULL",
+ "parentKeyVersion" : "0.0.0",
+ "parentLocalName" : "NULL",
+ "localName" : "NULL"
+ }
+ }
+ } ]
+ },
+ "contextAlbumReference" : [ {
+ "name" : "BasicContextAlbum",
+ "version" : "0.0.1"
+ } ],
+ "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" : "BasicPolicy",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "OnlyState",
+ "localName" : "BasicTask"
+ },
+ "outputType" : "DIRECT",
+ "output" : {
+ "parentKeyName" : "BasicPolicy",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "OnlyState",
+ "localName" : "OnlyOutput"
+ }
+ }
+ } ]
+ }
+ }
+ } ]
+ },
+ "firstState" : "OnlyState"
+ }
+ } ]
+ }
+ },
+ "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.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;"
+ }
+ }
+ } ]
+ }
+ },
+ "events" : {
+ "key" : {
+ "name" : "SmallModel_Events",
+ "version" : "0.0.1"
+ },
+ "eventMap" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "BasicEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "BasicEvent",
+ "version" : "0.0.1"
+ },
+ "nameSpace" : "org.onap.policy.apex.events",
+ "source" : "source",
+ "target" : "target",
+ "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/tools/model-generator/src/test/resources/blankSchema.json b/tools/model-generator/src/test/resources/blankSchema.json
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tools/model-generator/src/test/resources/blankSchema.json