aboutsummaryrefslogtreecommitdiffstats
path: root/gui-editors/gui-editor-apex/src/test
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-09-11 14:28:32 +0100
committerliamfallon <liam.fallon@est.tech>2020-09-11 14:37:24 +0100
commit9a9127b65920580de8b4a69479a9983481c8faf8 (patch)
tree35c6449e4850b661f86a639a33684e079beb836d /gui-editors/gui-editor-apex/src/test
parentafcf92da0d813028b48ea781df33148bc6f000b6 (diff)
Add TOSCA support to Apex editor
The APEX editor now loads, saves, and downloads files in TOSCA format, the same as the apex-pdp does. The non-standard TOSCA handling for file upload has been refactored to be aligned with the Policy Frameowkr TOSCA support. Issue-ID: POLICY-2621 Change-Id: I1ec7475cbcc6ffc23de92687c9f284ac7dfbdd80 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'gui-editors/gui-editor-apex/src/test')
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ApexEditorStartupTest.java143
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/RestInterfaceTest.java47
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/UploadPluginConfigParametersTest.java85
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResourceTest.java2
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ConfigurationRestResourceTest.java64
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/ApexConfigProcessorTest.java111
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/PolicyToscaConverterTest.java187
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/PolicyUploadHandlerTest.java201
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/ToscaTemplateProcessorTest.java204
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/UploadPluginClientTest.java71
-rw-r--r--gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.json1521
-rw-r--r--gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.yaml538
12 files changed, 1414 insertions, 1760 deletions
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ApexEditorStartupTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ApexEditorStartupTest.java
index c80b816..d78eba3 100644
--- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ApexEditorStartupTest.java
+++ b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ApexEditorStartupTest.java
@@ -50,16 +50,16 @@ public class ApexEditorStartupTest {
final String[] args = new String[] {};
final String outString = runEditor(args);
- assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], "
- + "State=READY) starting at http://localhost:18989/apexservices/"));
- assertTrue(outString.contains("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], "
- + "State=RUNNING) started at http://localhost:18989/apexservices/"));
- assertTrue(outString.replaceAll("[\\r?\\n]+", " ")
- .endsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec],"
- + " State=STOPPED) shut down "));
+
+ assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain:"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("State=RUNNING) started"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("help=false"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("restPort=18989"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("timeToLive=-1"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("listenAddress=localhost"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("uploadUrl=null"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("uploadUserid=null"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").endsWith(" State=STOPPED) shut down "));
}
/**
@@ -73,8 +73,7 @@ public class ApexEditorStartupTest {
final String[] args = new String[] { "12321" };
assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
- .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED)"
- + " parameter error, too many command line arguments specified : [12321]");
+ .hasMessageContaining("parameter error, too many command line arguments specified : [12321]");
}
/**
@@ -88,8 +87,7 @@ public class ApexEditorStartupTest {
final String[] args = new String[] { "12321 12322 12323" };
assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
- .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED)"
- + " parameter error, too many command line arguments specified : [12321 12322 12323]");
+ .hasMessageContaining("parameter error, too many command line arguments specified : [12321 12322 12323]");
}
/**
@@ -102,9 +100,8 @@ public class ApexEditorStartupTest {
public void testBadArg2() throws IOException, InterruptedException {
final String[] args = new String[] { "-z" };
- assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
- .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED)"
- + " parameter error, invalid command line arguments specified : Unrecognized option: -z");
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class).hasMessageContaining(
+ "parameter error, invalid command line arguments specified : Unrecognized option: -z");
}
/**
@@ -117,9 +114,8 @@ public class ApexEditorStartupTest {
public void testBadArg3() throws IOException, InterruptedException {
final String[] args = new String[] { "--hello" };
- assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
- .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED)"
- + " parameter error, invalid command line arguments specified : Unrecognized option: --hello");
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class).hasMessageContaining(
+ "parameter error, invalid command line arguments specified : Unrecognized option: --hello");
}
/**
@@ -133,9 +129,7 @@ public class ApexEditorStartupTest {
final String[] args = new String[] { "-l", "+++++" };
assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
- .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://+++++:18989/apexservices/, TTL=-1sec], "
- + "State=STOPPED) parameters invalid, listen address is not valid. "
+ .hasMessageContaining("parameters invalid, listen address is not valid. "
+ "Illegal character in hostname at index 7: http://+++++:18989/apexservices/");
}
@@ -179,16 +173,10 @@ public class ApexEditorStartupTest {
final String outString = runEditor(args);
- assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:12321/apexservices/, TTL=-1sec], "
- + "State=READY) starting at http://localhost:12321/apexservices/"));
- assertTrue(outString.contains("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:12321/apexservices/, TTL=-1sec], "
- + "State=RUNNING) started at http://localhost:12321/apexservices/"));
- assertTrue(outString.replaceAll("[\\r?\\n]+", " ")
- .endsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:12321/apexservices/, TTL=-1sec],"
- + " State=STOPPED) shut down "));
+ assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain:"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("State=RUNNING) started"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("localhost:12321"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").endsWith(" State=STOPPED) shut down "));
}
/**
@@ -203,16 +191,10 @@ public class ApexEditorStartupTest {
final String outString = runEditor(args);
- assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:12321/apexservices/, TTL=-1sec], "
- + "State=READY) starting at http://localhost:12321/apexservices/"));
- assertTrue(outString.contains("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:12321/apexservices/, TTL=-1sec], "
- + "State=RUNNING) started at http://localhost:12321/apexservices/"));
- assertTrue(outString.replaceAll("[\\r?\\n]+", " ")
- .endsWith("(ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:12321/apexservices/, TTL=-1sec],"
- + " State=STOPPED) shut down "));
+ assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain:"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("State=RUNNING) started"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("localhost:12321"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").endsWith(" State=STOPPED) shut down "));
}
/**
@@ -226,8 +208,7 @@ public class ApexEditorStartupTest {
final String[] args = new String[] { "-p 12321" };
assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
- .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED)"
- + " parameter error, error parsing argument \"port\" :For input string: \" 12321\"");
+ .hasMessageContaining("parameter error, error parsing argument \"port\" :For input string: \" 12321\"");
}
/**
@@ -241,9 +222,7 @@ public class ApexEditorStartupTest {
final String[] args = new String[] { "-p0" };
assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
- .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:0/apexservices/, TTL=-1sec], "
- + "State=STOPPED) parameters invalid, port must be between 1024 and 65535");
+ .hasMessageContaining("parameters invalid, port must be between 1024 and 65535");
}
/**
@@ -257,9 +236,7 @@ public class ApexEditorStartupTest {
final String[] args = new String[] { "-p1023" };
assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
- .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:1023/apexservices/, TTL=-1sec], "
- + "State=STOPPED) parameters invalid, port must be between 1024 and 65535");
+ .hasMessageContaining("parameters invalid, port must be between 1024 and 65535");
}
/**
@@ -273,9 +250,7 @@ public class ApexEditorStartupTest {
final String[] args = new String[] { "-p65536" };
assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
- .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:65536/apexservices/, TTL=-1sec], "
- + "State=STOPPED) parameters invalid, port must be between 1024 and 65535");
+ .hasMessageContaining("parameters invalid, port must be between 1024 and 65535");
}
/**
@@ -290,17 +265,10 @@ public class ApexEditorStartupTest {
final String outString = runEditor(args);
- assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:18989/apexservices/, TTL=10sec], "
- + "State=READY) starting at http://localhost:18989/apexservices/"));
- assertTrue(outString.replaceAll("[\\r?\\n]+", " ")
- .contains("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:18989/apexservices/, TTL=10sec], State=RUNNING)"
- + " started"));
- assertTrue(outString.replaceAll("[\\r?\\n]+", " ")
- .endsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:18989/apexservices/, TTL=10sec], State=STOPPED)"
- + " shut down "));
+ assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain:"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("State=RUNNING) started"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("timeToLive=10"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").endsWith(" State=STOPPED) shut down "));
}
/**
@@ -315,17 +283,10 @@ public class ApexEditorStartupTest {
final String outString = runEditor(args);
- assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:18989/apexservices/, TTL=10sec], "
- + "State=READY) starting at http://localhost:18989/apexservices/"));
- assertTrue(outString.replaceAll("[\\r?\\n]+", " ")
- .contains("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:18989/apexservices/, TTL=10sec], State=RUNNING)"
- + " started"));
- assertTrue(outString.replaceAll("[\\r?\\n]+", " ")
- .endsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:18989/apexservices/, TTL=10sec], State=STOPPED)"
- + " shut down "));
+ assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain:"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("State=RUNNING) started"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("timeToLive=10"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").endsWith(" State=STOPPED) shut down "));
}
/**
@@ -340,17 +301,10 @@ public class ApexEditorStartupTest {
final String outString = runEditor(args);
- assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:12321/apexservices/, TTL=10sec], "
- + "State=READY) starting at http://localhost:12321/apexservices/"));
- assertTrue(outString.replaceAll("[\\r?\\n]+", " ")
- .contains("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:12321/apexservices/, TTL=10sec], State=RUNNING)"
- + " started"));
- assertTrue(outString.replaceAll("[\\r?\\n]+", " ")
- .endsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://localhost:12321/apexservices/, TTL=10sec], State=STOPPED)"
- + " shut down "));
+ assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain:"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("State=RUNNING) started"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("timeToLive=10"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").endsWith(" State=STOPPED) shut down "));
}
/**
@@ -365,17 +319,10 @@ public class ApexEditorStartupTest {
final String outString = runEditor(args);
- assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://127.0.0.1:12321/apexservices/, TTL=10sec], "
- + "State=READY) starting at http://127.0.0.1:12321/apexservices/"));
- assertTrue(outString.replaceAll("[\\r?\\n]+", " ")
- .contains("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://127.0.0.1:12321/apexservices/, TTL=10sec], State=RUNNING)"
- + " started"));
- assertTrue(outString.replaceAll("[\\r?\\n]+", " ")
- .endsWith("Apex Editor REST endpoint (ApexEditorMain: "
- + "Config=[ApexEditorParameters: URI=http://127.0.0.1:12321/apexservices/, TTL=10sec], State=STOPPED)"
- + " shut down "));
+ assertTrue(outString.startsWith("Apex Editor REST endpoint (ApexEditorMain:"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("State=RUNNING) started"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").contains("timeToLive=10"));
+ assertTrue(outString.replaceAll("[\\r?\\n]+", " ").endsWith(" State=STOPPED) shut down "));
}
/**
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/RestInterfaceTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/RestInterfaceTest.java
index 60a2012..cf1c4fa 100644
--- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/RestInterfaceTest.java
+++ b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/RestInterfaceTest.java
@@ -42,10 +42,8 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelStringWriter;
import org.onap.policy.apex.model.modelapi.ApexApiResult;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicy;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.gui.editors.apex.rest.ApexEditorMain.EditorState;
@@ -56,7 +54,7 @@ import org.onap.policy.gui.editors.apex.rest.ApexEditorMain.EditorState;
public class RestInterfaceTest {
// CHECKSTYLE:OFF: MagicNumber
- private static final String TESTMODELFILE = "models/PolicyModel.json";
+ private static final String TESTMODELFILE = "models/PolicyModel.yaml";
private static final String TESTPORTNUM = "18989";
private static final long MAX_WAIT = 15000; // 15 sec
private static final InputStream SYSIN = System.in;
@@ -65,8 +63,7 @@ public class RestInterfaceTest {
private static ApexEditorMain editorMain;
private static WebTarget target;
- private static AxPolicyModel localmodel = null;
- private static String localmodelString = null;
+ private static String localModelString = null;
/**
* Sets up the tests.
@@ -103,10 +100,7 @@ public class RestInterfaceTest {
target = c.target(new ApexEditorParameters().getBaseUri());
// load a test model locally
- localmodel = new ApexModelReader<>(AxPolicyModel.class, false)
- .read(ResourceUtils.getResourceAsStream(TESTMODELFILE));
- localmodelString = new ApexModelStringWriter<AxPolicyModel>(false).writeJsonString(localmodel,
- AxPolicyModel.class);
+ localModelString = ResourceUtils.getResourceAsString(TESTMODELFILE);
// initialize a session ID
createNewSession();
@@ -159,8 +153,8 @@ public class RestInterfaceTest {
}
/**
- * Create a new session, Upload a test policy model, then get a policy, parse
- * it, and compare it to the same policy in the original model.
+ * Create a new session, Upload a test policy model, then get a policy, parse it, and compare it to the same policy
+ * in the original model.
*
* @throws ApexException if there is an Apex Error
* @throws JAXBException if there is a JaxB Error
@@ -170,7 +164,7 @@ public class RestInterfaceTest {
final int sessionId = createNewSession();
- uploadPolicy(sessionId, localmodelString);
+ uploadPolicy(sessionId, localModelString);
final ApexApiResult responseMsg = target.path("editor/" + sessionId + "/Policy/Get")
.queryParam("name", "policy").queryParam("version", "0.0.1").request().get(ApexApiResult.class);
@@ -180,29 +174,10 @@ public class RestInterfaceTest {
// object. Lets parse it
final String returnedPolicyAsString = responseMsg.getMessages().get(0);
ApexModelReader<AxPolicy> apexPolicyReader = new ApexModelReader<>(AxPolicy.class, false);
- final AxPolicy returnedpolicy = apexPolicyReader.read(returnedPolicyAsString);
- // AxPolicy returnedpolicy =
- // RestUtils.getConceptFromJSON(returnedPolicyAsString, AxPolicy.class);
-
- // Extract the local copy of that policy from the local Apex Policy Model
- final AxPolicy localpolicy = localmodel.getPolicies().get("policy", "0.0.1");
-
- // Write that local copy of the AxPolicy object to a Json String, ten parse it
- // again
- final ApexModelStringWriter<AxPolicy> apexModelWriter = new ApexModelStringWriter<>(false);
- final String localPolicyString = apexModelWriter.writeJsonString(localpolicy, AxPolicy.class);
- apexPolicyReader = new ApexModelReader<>(AxPolicy.class, false);
- final AxPolicy localpolicyReparsed = apexPolicyReader.read(localPolicyString);
- // AxPolicy localpolicy_reparsed =
- // RestUtils.getConceptFromJSON(returnedPolicyAsString, AxPolicy.class);
-
- assertNotNull(returnedpolicy);
- assertNotNull(localpolicy);
- assertNotNull(localpolicyReparsed);
- assertEquals(localpolicy, localpolicyReparsed);
- assertEquals(localpolicy, returnedpolicy);
- }
-
- // TODO Full unit testing of REST interface
+ final AxPolicy returnedPolicy = apexPolicyReader.read(returnedPolicyAsString);
+ assertNotNull(returnedPolicy);
+ assertEquals("state", returnedPolicy.getFirstState());
+ assertEquals(1, returnedPolicy.getStateMap().size());
+ }
}
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/UploadPluginConfigParametersTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/UploadPluginConfigParametersTest.java
deleted file mode 100644
index 3f743a7..0000000
--- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/UploadPluginConfigParametersTest.java
+++ /dev/null
@@ -1,85 +0,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=========================================================
- */
-
-package org.onap.policy.gui.editors.apex.rest;
-
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.Optional;
-import org.junit.Test;
-import org.onap.policy.gui.editors.apex.rest.handling.config.PolicyUploadPluginConfigKey;
-
-public class UploadPluginConfigParametersTest {
-
- @Test
- public void setupPropertiesTest() {
- final String expectedUrl = "aUrl";
- final boolean expectedEnabled = true;
- System.setProperty(PolicyUploadPluginConfigKey.URL.getKey(), expectedUrl);
- System.setProperty(PolicyUploadPluginConfigKey.ENABLE.getKey(), String.valueOf(expectedEnabled));
- final UploadPluginConfigParameters uploadPluginConfigParameters = new UploadPluginConfigParameters();
- final String url = uploadPluginConfigParameters.getUrl();
- final Boolean isEnabled = uploadPluginConfigParameters.isEnabled();
- assertThat(url).isEqualTo(expectedUrl);
- assertThat(isEnabled).isEqualTo(expectedEnabled);
- }
-
- @Test
- public void testGetValue() {
- final String expectedUrl = "aUrl";
- final boolean expectedEnabled = true;
- System.setProperty(PolicyUploadPluginConfigKey.URL.getKey(), expectedUrl);
- System.setProperty(PolicyUploadPluginConfigKey.ENABLE.getKey(), String.valueOf(expectedEnabled));
- UploadPluginConfigParameters uploadPluginConfigParameters = new UploadPluginConfigParameters();
- Optional<String> actualUrl = uploadPluginConfigParameters.getValue(PolicyUploadPluginConfigKey.URL);
- assertThat(actualUrl).isPresent().contains(expectedUrl);
- Optional<Boolean> actualEnabled = uploadPluginConfigParameters.getValue(PolicyUploadPluginConfigKey.ENABLE);
- assertThat(actualEnabled).isPresent().contains(expectedEnabled);
-
- System.clearProperty(PolicyUploadPluginConfigKey.URL.getKey());
- uploadPluginConfigParameters = new UploadPluginConfigParameters();
- actualUrl = uploadPluginConfigParameters.getValue(PolicyUploadPluginConfigKey.URL);
- assertThat(actualUrl).isNotPresent();
-
- System.clearProperty(PolicyUploadPluginConfigKey.ENABLE.getKey());
- uploadPluginConfigParameters = new UploadPluginConfigParameters();
- actualEnabled = uploadPluginConfigParameters.getValue(PolicyUploadPluginConfigKey.ENABLE);
- assertThat(actualEnabled).isPresent();
- assertThat(actualEnabled.get()).isFalse();
- }
-
- @Test
- public void testValidate() {
- final String expectedUrl = "aUrl";
- final boolean expectedEnabled = true;
- System.setProperty(PolicyUploadPluginConfigKey.URL.getKey(), expectedUrl);
- System.setProperty(PolicyUploadPluginConfigKey.ENABLE.getKey(), String.valueOf(expectedEnabled));
- UploadPluginConfigParameters uploadPluginConfigParameters = new UploadPluginConfigParameters();
- assertThat(uploadPluginConfigParameters.isValid()).isTrue();
-
- System.clearProperty(PolicyUploadPluginConfigKey.URL.getKey());
- uploadPluginConfigParameters = new UploadPluginConfigParameters();
- assertThat(uploadPluginConfigParameters.isValid()).isFalse();
-
- System.clearProperty(PolicyUploadPluginConfigKey.ENABLE.getKey());
- uploadPluginConfigParameters = new UploadPluginConfigParameters();
- assertThat(uploadPluginConfigParameters.isValid()).isTrue();
- }
-} \ No newline at end of file
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResourceTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResourceTest.java
index 9b0ce32..6e9dca4 100644
--- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResourceTest.java
+++ b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResourceTest.java
@@ -398,7 +398,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
.queryParam("version", (String) null).request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- final String modelString = TextFileUtils.getTextFileAsString("src/test/resources/models/PolicyModel.json");
+ final String modelString = TextFileUtils.getTextFileAsString("src/test/resources/models/PolicyModel.yaml");
Entity<String> modelEntity = Entity.entity("Somewhere over the rainbow", MediaType.APPLICATION_JSON);
result = target("editor/" + -12345 + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ConfigurationRestResourceTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ConfigurationRestResourceTest.java
deleted file mode 100644
index 3820240..0000000
--- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ConfigurationRestResourceTest.java
+++ /dev/null
@@ -1,64 +0,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=========================================================
- */
-
-package org.onap.policy.gui.editors.apex.rest.handling;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import org.glassfish.jersey.server.ResourceConfig;
-import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Test;
-import org.onap.policy.apex.model.modelapi.ApexApiResult;
-import org.onap.policy.apex.model.modelapi.ApexApiResult.Result;
-import org.onap.policy.common.parameters.ParameterService;
-import org.onap.policy.gui.editors.apex.rest.UploadPluginConfigParameters;
-import org.onap.policy.gui.editors.apex.rest.handling.config.PolicyUploadPluginConfigKey;
-
-public class ConfigurationRestResourceTest extends JerseyTest {
-
- private String anUrl;
- private Boolean isEnabled;
-
- @Override
- protected Application configure() {
- anUrl = "url";
- isEnabled = true;
- System.setProperty(PolicyUploadPluginConfigKey.URL.getKey(), anUrl);
- System.setProperty(PolicyUploadPluginConfigKey.ENABLE.getKey(), String.valueOf(isEnabled));
- final UploadPluginConfigParameters uploadPluginConfigParameters = new UploadPluginConfigParameters();
- ParameterService.clear();
- ParameterService.register(uploadPluginConfigParameters);
- return new ResourceConfig(ConfigurationRestResource.class);
- }
-
- @Test
- public void testShowSuccess() {
- final Response response = target("/editor/config").request().get();
- assertEquals(Status.OK.getStatusCode(), response.getStatus());
- final ApexApiResult apexApiResult = response.readEntity(ApexApiResult.class);
- assertEquals(Result.SUCCESS, apexApiResult.getResult());
- final String message = apexApiResult.getMessage();
- assertThat(message).contains(String.format("\"%s\":\"%s\"", PolicyUploadPluginConfigKey.URL.getKey(), anUrl))
- .contains(String.format("\"%s\":%s", PolicyUploadPluginConfigKey.ENABLE.getKey(), isEnabled));
- }
-} \ No newline at end of file
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/ApexConfigProcessorTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/ApexConfigProcessorTest.java
deleted file mode 100644
index 0842b1b..0000000
--- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/ApexConfigProcessorTest.java
+++ /dev/null
@@ -1,111 +0,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=========================================================
- */
-
-package org.onap.policy.gui.editors.apex.rest.handling.converter.tosca;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.is;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.ApexConfigProcessor.ErrorMessage.INVALID_APEX_CONFIG;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.ApexConfigProcessor.ErrorMessage.INVALID_ENTRY;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.ApexConfigProcessor.ErrorMessage.MISSING_ENTRY;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.PolicyToscaConverter.ToscaKey.ENGINE_SERVICE_PARAMETERS;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import org.junit.Test;
-import org.onap.policy.common.utils.coder.StandardCoder;
-
-public class ApexConfigProcessorTest {
-
- private final ApexConfigProcessor apexConfigProcessor = new ApexConfigProcessor(new StandardCoder());
- private final Path testResourcesPath = Paths.get("src", "test", "resources", "processor");
-
- @Test
- public void testProcessSuccess() throws IOException {
- final String fileName = "ApexConfig.json";
- final ProcessedTemplate process;
- try (final FileInputStream fileInputStream = readFileAsStream(fileName)) {
- process = apexConfigProcessor.process(fileInputStream);
- }
- assertThat("Template should be valid", process.isValid(), is(true));
- final String expectedContent = readFileAsString(fileName);
- assertThat("Content should be the same", process.getContent(), is(expectedContent));
- }
-
- @Test
- public void testProcessMissingPoliciesEntry() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream(
- "ApexConfig-missing-engineServiceParameters.json")) {
- processedTemplate = apexConfigProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false,
- List.of(MISSING_ENTRY.getMessage(ENGINE_SERVICE_PARAMETERS.getKey())));
- }
-
- @Test
- public void testProcessInvalidToscaTemplate() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream("ApexConfig-invalid.jsonbad")) {
- processedTemplate = apexConfigProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false, List.of(INVALID_APEX_CONFIG.getMessage()));
- }
-
- @Test
- public void testProcessInvalidEngineServiceParameters() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream(
- "ApexConfig-invalid-engineServiceParameters.json")) {
- processedTemplate = apexConfigProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false,
- List.of(INVALID_ENTRY.getMessage(ENGINE_SERVICE_PARAMETERS.getKey())));
- }
-
- private void assertProcessedTemplate(final ProcessedTemplate process, boolean isValid,
- final List<String> expectedErrorList) {
-
- assertThat("Template should be valid", process.isValid(), is(isValid));
- if (isValid || expectedErrorList == null) {
- return;
- }
- assertThat("Should contains the expected quantity of errors", process.getErrorSet().size(),
- is(expectedErrorList.size()));
- expectedErrorList.forEach(errorMsg -> assertThat("Should contains a specific error message",
- process.getErrorSet(), contains(errorMsg)));
- }
-
- private FileInputStream readFileAsStream(final String fileName) throws FileNotFoundException {
- final Path path = Paths.get(testResourcesPath.toString(), fileName);
- return new FileInputStream(path.toFile());
- }
-
- private String readFileAsString(final String fileName) throws IOException {
- final Path path = Paths.get(testResourcesPath.toString(), fileName);
- return Files.readString(path);
- }
-
-} \ No newline at end of file
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/PolicyToscaConverterTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/PolicyToscaConverterTest.java
deleted file mode 100644
index ecf896e..0000000
--- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/PolicyToscaConverterTest.java
+++ /dev/null
@@ -1,187 +0,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=========================================================
- */
-
-package org.onap.policy.gui.editors.apex.rest.handling.converter.tosca;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doThrow;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.PolicyToscaConverter.ToscaKey.ENGINE_SERVICE_PARAMETERS;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.PolicyToscaConverter.ToscaKey.POLICIES;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.PolicyToscaConverter.ToscaKey.POLICY_TYPE_IMPL;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.PolicyToscaConverter.ToscaKey.PROPERTIES;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.PolicyToscaConverter.ToscaKey.TOPOLOGY_TEMPLATE;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.PolicyToscaConverter.ToscaKey.TOSCA_DEFINITIONS_VERSION;
-
-import com.google.gson.JsonObject;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.coder.StandardYamlCoder;
-import org.onap.policy.common.utils.coder.YamlJsonTranslator;
-import org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.exception.PolicyToscaConverterException;
-
-public class PolicyToscaConverterTest {
-
- @Spy
- private final StandardCoder standardCoder = new StandardCoder();
- @Spy
- private final YamlJsonTranslator yamlJsonTranslator = new YamlJsonTranslator();
- @InjectMocks
- private PolicyToscaConverter policyToscaConverter;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testConvertSuccess() throws IOException, PolicyToscaConverterException, CoderException {
- final String apexConfig = readResourceFileToString(Paths.get("converter", "ApexConfig.json"));
- final String apexPolicy = readResourceFileToString(Paths.get("converter", "APEXgRPCPolicy.json"));
- final String toscaTemplate = readResourceFileToString(Paths.get("converter", "ToscaTemplate.json"));
- final Optional<String> convert = policyToscaConverter.convert(apexPolicy, apexConfig, toscaTemplate);
- assertTrue(convert.isPresent());
- final String convertedYaml = convert.get();
- final StandardYamlCoder standardYamlCoder = new StandardYamlCoder();
- @SuppressWarnings("unchecked") final Map<String, Object> yamlAsMap =
- standardYamlCoder.decode(convertedYaml, Map.class);
- assertThat(yamlAsMap).containsKeys(TOSCA_DEFINITIONS_VERSION.getKey(), TOPOLOGY_TEMPLATE.getKey());
- @SuppressWarnings("unchecked") final Map<String, Object> topology_template =
- (Map<String, Object>) yamlAsMap.get(TOPOLOGY_TEMPLATE.getKey());
- assertThat(topology_template).containsKey(POLICIES.getKey());
- @SuppressWarnings("unchecked") final List<Object> policies =
- (List<Object>) topology_template.get(POLICIES.getKey());
- assertEquals(1, policies.size());
- @SuppressWarnings("unchecked") final Map<String, Object> firstPolicyMap = (Map<String, Object>) policies.get(0);
- assertEquals(1, firstPolicyMap.keySet().size());
- @SuppressWarnings("unchecked") final Map<String, Object> firstPolicy =
- (Map<String, Object>) firstPolicyMap.get(firstPolicyMap.keySet().iterator().next());
- assertThat(firstPolicy).containsKey(PROPERTIES.getKey());
- @SuppressWarnings("unchecked") final Map<String, Object> propertiesMap =
- (Map<String, Object>) firstPolicy.get(PROPERTIES.getKey());
- assertThat(propertiesMap).containsKey(ENGINE_SERVICE_PARAMETERS.getKey());
- @SuppressWarnings("unchecked") final Map<String, Object> engineServiceParametersProperty =
- (Map<String, Object>) propertiesMap.get(ENGINE_SERVICE_PARAMETERS.getKey());
- assertThat(engineServiceParametersProperty).containsKey(POLICY_TYPE_IMPL.getKey());
- }
-
- @Test
- public void testConvertInvalidJsonDecode() throws CoderException {
- final String invalidJson = "this is an invalid JSON";
- doThrow(CoderException.class).when(standardCoder).decode(eq(invalidJson), eq(JsonObject.class));
-
- final String expectedMsg = String.format("Could not convert JSON string to JSON:\n%s", invalidJson);
- assertThatThrownBy(() -> policyToscaConverter.convert(invalidJson, invalidJson, invalidJson))
- .isInstanceOf(PolicyToscaConverterException.class)
- .hasMessage(expectedMsg);
- }
-
- @Test
- public void testConvertInvalidJsonEncodeToString() throws IOException {
- final String apexConfig = readResourceFileToString(Paths.get("converter", "ApexConfig.json"));
- final String apexPolicy = readResourceFileToString(Paths.get("converter", "APEXgRPCPolicy.json"));
- final String toscaTemplate = readResourceFileToString(Paths.get("converter", "ToscaTemplate.json"));
-
- doThrow(RuntimeException.class).when(yamlJsonTranslator).toYaml(any(JsonObject.class));
-
- assertThatThrownBy(() -> policyToscaConverter.convert(apexPolicy, apexConfig, toscaTemplate))
- .isInstanceOf(PolicyToscaConverterException.class)
- .hasMessageContaining("Could not convert JSON Object to YAML:");
- }
-
- @Test
- public void testCouldNotReadFirstPolicy() throws IOException {
- final String apexConfig = readResourceFileToString(Paths.get("converter", "ApexConfig.json"));
- final String apexPolicy = readResourceFileToString(Paths.get("converter", "APEXgRPCPolicy.json"));
- final String toscaTemplate1 =
- readResourceFileToString(Paths.get("processor", "ToscaTemplate-missing-policies.json"));
- final String expectedError =
- String.format("Could not read the first policy in the '%s' entry under '%s'",
- POLICIES.getKey(), TOPOLOGY_TEMPLATE.getKey());
-
- assertThatThrownBy(() -> policyToscaConverter.convert(apexPolicy, apexConfig, toscaTemplate1))
- .isInstanceOf(PolicyToscaConverterException.class)
- .hasMessage(expectedError);
- final String toscaTemplate2 =
- readResourceFileToString(Paths.get("processor", "ToscaTemplate-missing-policy.json"));
-
- assertThatThrownBy(() -> policyToscaConverter.convert(apexPolicy, apexConfig, toscaTemplate2))
- .isInstanceOf(PolicyToscaConverterException.class)
- .hasMessage(expectedError);
- }
-
- @Test
- public void testCouldNotReadPolicyProperties() throws IOException {
- final String apexConfig = readResourceFileToString(Paths.get("converter", "ApexConfig.json"));
- final String apexPolicy = readResourceFileToString(Paths.get("converter", "APEXgRPCPolicy.json"));
- final String toscaTemplate =
- readResourceFileToString(Paths.get("processor", "ToscaTemplate-missing-properties.json"));
- assertThatThrownBy(() -> policyToscaConverter.convert(apexPolicy, apexConfig, toscaTemplate))
- .isInstanceOf(PolicyToscaConverterException.class)
- .hasMessage(String.format("Could not read the policy '%s' entry", PROPERTIES.getKey()));
- }
-
- @Test
- public void testCouldNotReadEngineServiceParameters() throws IOException {
- final String apexConfig =
- readResourceFileToString(Paths.get("converter", "ApexConfig-engineServiceParameters-notAnObject.json"));
- final String apexPolicy = readResourceFileToString(Paths.get("converter", "APEXgRPCPolicy.json"));
- final String toscaTemplate =
- readResourceFileToString(Paths.get("converter", "ToscaTemplate.json"));
- assertThatThrownBy(() -> policyToscaConverter.convert(apexPolicy, apexConfig, toscaTemplate))
- .isInstanceOf(PolicyToscaConverterException.class)
- .hasMessage(
- String.format("Could not read the '%s' in the Apex Config", ENGINE_SERVICE_PARAMETERS.getKey()));
- }
-
- @Test
- public void testCouldNotReadTopologyTemplate() throws IOException {
- final String apexConfig = readResourceFileToString(Paths.get("converter", "ApexConfig.json"));
- final String apexPolicy = readResourceFileToString(Paths.get("converter", "APEXgRPCPolicy.json"));
- final String toscaTemplate =
- readResourceFileToString(Paths.get("processor", "ToscaTemplate-missing-topology-template.json"));
- assertThatThrownBy(() -> policyToscaConverter.convert(apexPolicy, apexConfig, toscaTemplate))
- .isInstanceOf(PolicyToscaConverterException.class)
- .hasMessage(
- String.format("Could not read the '%s' entry in the Tosca Template", TOPOLOGY_TEMPLATE.getKey()));
- }
-
- private String readResourceFileToString(final Path filePathFromResources) throws IOException {
- final Path resourceDirectory = Paths.get("src", "test", "resources");
- final Path converter = Paths.get(resourceDirectory.toString(), filePathFromResources.toString());
- return Files.readString(converter);
- }
-
-} \ No newline at end of file
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/PolicyUploadHandlerTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/PolicyUploadHandlerTest.java
deleted file mode 100644
index 6ec5eef..0000000
--- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/PolicyUploadHandlerTest.java
+++ /dev/null
@@ -1,201 +0,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=========================================================
- */
-
-package org.onap.policy.gui.editors.apex.rest.handling.converter.tosca;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import javax.ws.rs.core.Response;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.policy.apex.model.modelapi.ApexApiResult;
-import org.onap.policy.apex.model.modelapi.ApexModel;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-import org.onap.policy.gui.editors.apex.rest.UploadPluginConfigParameters;
-import org.onap.policy.gui.editors.apex.rest.handling.PolicyUploadHandler;
-import org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.exception.PolicyToscaConverterException;
-import org.onap.policy.gui.editors.apex.rest.handling.plugin.upload.UploadPluginClient;
-import org.onap.policy.gui.editors.apex.rest.handling.plugin.upload.UploadPolicyRequestDto;
-
-public class PolicyUploadHandlerTest {
-
- private static final String USER_ID = "cs0008";
- @Mock
- private PolicyToscaConverter policyToscaConverter;
- @Mock
- private ToscaTemplateProcessor toscaTemplateProcessor;
- @Mock
- private ApexConfigProcessor apexConfigProcessor;
- @Mock
- private UploadPluginClient uploadPluginClient;
- @Mock
- private UploadPluginConfigParameters config;
-
- @InjectMocks
- private PolicyUploadHandler policyUploadHandler;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- when(config.isEnabled()).thenReturn(true);
- }
-
- @Test
- public void doUploadResponseSuccessAndFail() throws PolicyToscaConverterException, IOException {
- final ApexModel apexModel = mockApexModel();
- final ProcessedTemplate processedToscaTemplate = new ProcessedTemplate();
- processedToscaTemplate.setContent("tosca");
- final ProcessedTemplate processedApexConfig = new ProcessedTemplate();
- processedApexConfig.setContent("apexConfig");
- when(toscaTemplateProcessor.process(any(InputStream.class))).thenReturn(processedToscaTemplate);
- when(apexConfigProcessor.process(any(InputStream.class))).thenReturn(processedApexConfig);
- when(policyToscaConverter.convert(eq("policy\n"), eq("apexConfig"), eq("tosca")))
- .thenReturn(Optional.of("test"));
- when(uploadPluginClient.upload(any(UploadPolicyRequestDto.class)))
- .thenReturn(Response.ok().status(201).build());
-
- ApexApiResult apexApiResult = policyUploadHandler
- .doUpload(apexModel, mock(InputStream.class), mock(InputStream.class), USER_ID);
-
- assertThat("Response should be ok", apexApiResult.isOk(), is(true));
- String expectedSuccessMsg =
- String.format("Policy '%s' uploaded successfully", apexModel.getPolicyModel().getId());
- assertThat("Response message should be as expected",
- apexApiResult.getMessage(), is(expectedSuccessMsg + "\n"));
-
- when(uploadPluginClient.upload(any(UploadPolicyRequestDto.class)))
- .thenReturn(Response.serverError().build());
-
- apexApiResult = policyUploadHandler
- .doUpload(apexModel, mock(InputStream.class), mock(InputStream.class), USER_ID);
-
- assertThat("Response should not be ok", apexApiResult.isNok(), is(true));
- expectedSuccessMsg =
- String.format("An error has occurred while uploading the Policy '%s'. Status was %s",
- apexModel.getPolicyModel().getId(), 500);
- assertThat("Response message should be as expected",
- apexApiResult.getMessage(), is(expectedSuccessMsg + "\n"));
- }
-
- @Test
- public void doUploadPluginDisabled() throws IOException {
- when(config.isEnabled()).thenReturn(false);
-
- final ProcessedTemplate processedToscaTemplate = new ProcessedTemplate();
- final ProcessedTemplate processedApexConfig = new ProcessedTemplate();
- when(toscaTemplateProcessor.process(any(InputStream.class))).thenReturn(processedToscaTemplate);
- when(apexConfigProcessor.process(any(InputStream.class))).thenReturn(processedApexConfig);
- final ApexApiResult apexApiResult = policyUploadHandler
- .doUpload(mock(ApexModel.class), mock(InputStream.class), mock(InputStream.class), USER_ID);
-
- assertThat("Response should not be ok", apexApiResult.isNok(), is(true));
- assertThat("Response message should be as expected",
- apexApiResult.getMessage(), is("Upload feature is disabled\n"));
- }
-
- @Test
- public void doUploadInvalidToscaTemplate() throws IOException {
- when(config.isEnabled()).thenReturn(false);
-
- final ProcessedTemplate processedToscaTemplate = new ProcessedTemplate();
- final String errorMsg = "an error";
- processedToscaTemplate.addToErrors(Collections.singleton(errorMsg));
- when(toscaTemplateProcessor.process(any(InputStream.class))).thenReturn(processedToscaTemplate);
- final ApexApiResult apexApiResult = policyUploadHandler
- .doUpload(mock(ApexModel.class), mock(InputStream.class), mock(InputStream.class), USER_ID);
-
- assertThat("Response should not be ok", apexApiResult.isNok(), is(true));
- assertThat("Response message should be as expected",
- apexApiResult.getMessage(), is(errorMsg + "\n"));
- }
-
- @Test
- public void doUploadInvalidApexConfigTemplate() throws IOException {
- when(config.isEnabled()).thenReturn(false);
-
- when(toscaTemplateProcessor.process(any(InputStream.class))).thenReturn(new ProcessedTemplate());
- final ProcessedTemplate processedApexConfig = new ProcessedTemplate();
- final String errorMsg = "an error";
- processedApexConfig.addToErrors(Collections.singleton(errorMsg));
- when(apexConfigProcessor.process(any(InputStream.class))).thenReturn(processedApexConfig);
- final ApexApiResult apexApiResult = policyUploadHandler
- .doUpload(mock(ApexModel.class), mock(InputStream.class), mock(InputStream.class), USER_ID);
-
- assertThat("Response should not be ok", apexApiResult.isNok(), is(true));
- assertThat("Response message should be as expected",
- apexApiResult.getMessage(), is(errorMsg + "\n"));
- }
-
- @Test
- public void doUploadConversionFailed() throws PolicyToscaConverterException, IOException {
- final ApexModel apexModel = mockApexModel();
- final ProcessedTemplate processedToscaTemplate = new ProcessedTemplate();
- processedToscaTemplate.setContent("tosca");
- final ProcessedTemplate processedApexConfig = new ProcessedTemplate();
- processedApexConfig.setContent("apexConfig");
- when(toscaTemplateProcessor.process(any(InputStream.class))).thenReturn(processedToscaTemplate);
- when(apexConfigProcessor.process(any(InputStream.class))).thenReturn(processedApexConfig);
- when(policyToscaConverter.convert(eq("policy\n"), eq("apexConfig"), eq("tosca")))
- .thenThrow(PolicyToscaConverterException.class);
- when(uploadPluginClient.upload(any(UploadPolicyRequestDto.class)))
- .thenReturn(Response.ok().status(201).build());
-
- final ApexApiResult apexApiResult = policyUploadHandler
- .doUpload(apexModel, mock(InputStream.class), mock(InputStream.class), USER_ID);
-
- assertThat("Response should not be ok", apexApiResult.isNok(), is(true));
- final String expectedErrorMsg = String
- .format("An error has occurred while uploading the converting the Policy '%s' to YAML.",
- apexModel.getPolicyModel().getId());
- assertThat("Response message should be as expected",
- apexApiResult.getMessage(), is(expectedErrorMsg + "\n"));
- }
-
- private ApexModel mockApexModel() {
- final ApexModel apexModel = mock(ApexModel.class);
- final ApexApiResult listModelApexApiResult = new ApexApiResult();
- listModelApexApiResult.addMessage("policy");
- when(apexModel.listModel()).thenReturn(listModelApexApiResult);
- final AxPolicyModel axPolicyModel = new AxPolicyModel();
- final AxArtifactKey axArtifactKey = new AxArtifactKey("policyKey", "1.0.0");
- final Map<AxArtifactKey, AxKeyInfo> keyInfoMap = new HashMap<>();
- keyInfoMap.put(axArtifactKey, new AxKeyInfo(axArtifactKey));
- final AxKeyInformation axKeyInformation = new AxKeyInformation(axArtifactKey, keyInfoMap);
- axPolicyModel.setKeyInformation(axKeyInformation);
- when(apexModel.getPolicyModel()).thenReturn(axPolicyModel);
- return apexModel;
- }
-}
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/ToscaTemplateProcessorTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/ToscaTemplateProcessorTest.java
deleted file mode 100644
index 7166621..0000000
--- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/converter/tosca/ToscaTemplateProcessorTest.java
+++ /dev/null
@@ -1,204 +0,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=========================================================
- */
-
-package org.onap.policy.gui.editors.apex.rest.handling.converter.tosca;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.is;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.PolicyToscaConverter.ToscaKey.POLICIES;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.PolicyToscaConverter.ToscaKey.PROPERTIES;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.PolicyToscaConverter.ToscaKey.TOPOLOGY_TEMPLATE;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.PolicyToscaConverter.ToscaKey.TOSCA_DEFINITIONS_VERSION;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.ToscaTemplateProcessor.ErrorMessage.INVALID_ENTRY;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.ToscaTemplateProcessor.ErrorMessage.INVALID_POLICY;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.ToscaTemplateProcessor.ErrorMessage.INVALID_TOSCA_TEMPLATE;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.ToscaTemplateProcessor.ErrorMessage.MISSING_ENTRY;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.ToscaTemplateProcessor.ErrorMessage.MISSING_POLICY;
-import static org.onap.policy.gui.editors.apex.rest.handling.converter.tosca.ToscaTemplateProcessor.ErrorMessage.ONLY_ONE_POLICY_ALLOWED;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import org.junit.Test;
-import org.onap.policy.common.utils.coder.StandardCoder;
-
-public class ToscaTemplateProcessorTest {
-
- private final ToscaTemplateProcessor toscaTemplateProcessor = new ToscaTemplateProcessor(new StandardCoder());
- private final Path testResourcesPath = Paths.get("src", "test", "resources", "processor");
-
- @Test
- public void testProcessSuccess() throws IOException {
- final String fileName = "ToscaTemplate.json";
- final ProcessedTemplate process;
- try (final FileInputStream fileInputStream = readFileAsStream(fileName)) {
- process = toscaTemplateProcessor.process(fileInputStream);
- }
- assertThat("Template should be valid", process.isValid(), is(true));
- final String expectedContent = readFileAsString(fileName);
- assertThat("Content should be the same", process.getContent(), is(expectedContent));
- }
-
- @Test
- public void testProcessMissingPoliciesEntry() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream("ToscaTemplate-missing-policies.json")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false, List.of(MISSING_ENTRY.getMessage(POLICIES.getKey())));
- }
-
- @Test
- public void testProcessMissingTopologyTemplate() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream("ToscaTemplate-missing-topology-template.json")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false,
- List.of(MISSING_ENTRY.getMessage(TOPOLOGY_TEMPLATE.getKey())));
- }
-
- @Test
- public void testProcessMissingPolicy() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream("ToscaTemplate-missing-policy.json")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false, List.of(MISSING_POLICY.getMessage()));
- }
-
- @Test
- public void testProcessMissingToscaDefinitionsVersion() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream(
- "ToscaTemplate-missing-tosca-definitions-version.json")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false,
- List.of(MISSING_ENTRY.getMessage(TOSCA_DEFINITIONS_VERSION.getKey())));
- }
-
- @Test
- public void testProcessMissingProperties() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream("ToscaTemplate-missing-properties.json")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false, List.of(MISSING_ENTRY.getMessage(PROPERTIES.getKey())));
- }
-
- @Test
- public void testProcessMoreThanOnePolicy() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream("ToscaTemplate-more-than-one-policy.json")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false, List.of(ONLY_ONE_POLICY_ALLOWED.getMessage()));
- }
-
- @Test
- public void testProcessInvalidToscaTemplate() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream("ToscaTemplate-invalid.jsonbad")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false, List.of(INVALID_TOSCA_TEMPLATE.getMessage()));
- }
-
- @Test
- public void testProcessInvalidEntryToscaDefinitionsVersion() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream("ToscaTemplate-invalid-toscaDefinitions.json")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false,
- List.of(INVALID_ENTRY.getMessage(TOSCA_DEFINITIONS_VERSION.getKey())));
- }
-
- @Test
- public void testProcessInvalidEntryTopologyTemplate() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream(
- "ToscaTemplate-invalidEntry-topologyTemplate.json")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false,
- List.of(INVALID_ENTRY.getMessage(TOPOLOGY_TEMPLATE.getKey())));
- }
-
- @Test
- public void testProcessInvalidEntryPolicies() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream("ToscaTemplate-invalidEntry-policies.json")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false, List.of(INVALID_ENTRY.getMessage(POLICIES.getKey())));
- }
-
- @Test
- public void testProcessInvalidPolicy() throws IOException {
- ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream("ToscaTemplate-invalidPolicy1.json")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false, List.of(INVALID_POLICY.getMessage()));
-
- try (final FileInputStream fileInputStream = readFileAsStream("ToscaTemplate-invalidPolicy2.json")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false, List.of(INVALID_POLICY.getMessage()));
- }
-
- @Test
- public void testProcessInvalidEntryProperties() throws IOException {
- final ProcessedTemplate processedTemplate;
- try (final FileInputStream fileInputStream = readFileAsStream("ToscaTemplate-invalidEntry-properties.json")) {
- processedTemplate = toscaTemplateProcessor.process(fileInputStream);
- }
- assertProcessedTemplate(processedTemplate, false, List.of(INVALID_ENTRY.getMessage(PROPERTIES.getKey())));
- }
-
- private void assertProcessedTemplate(final ProcessedTemplate process, boolean isValid,
- final List<String> expectedErrorList) {
- assertThat("Template should be valid", process.isValid(), is(isValid));
- if (isValid || expectedErrorList == null) {
- return;
- }
- assertThat("Should contains the expected quantity of errors", process.getErrorSet().size(),
- is(expectedErrorList.size()));
- expectedErrorList.forEach(errorMsg -> assertThat("Should contains a specific error message",
- process.getErrorSet(), contains(errorMsg)));
- }
-
- private FileInputStream readFileAsStream(final String fileName) throws FileNotFoundException {
- final Path path = Paths.get(testResourcesPath.toString(), fileName);
- return new FileInputStream(path.toFile());
- }
-
- private String readFileAsString(final String fileName) throws IOException {
- final Path path = Paths.get(testResourcesPath.toString(), fileName);
- return Files.readString(path);
- }
-
-} \ No newline at end of file
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/UploadPluginClientTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/UploadPluginClientTest.java
deleted file mode 100644
index ab9445e..0000000
--- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/UploadPluginClientTest.java
+++ /dev/null
@@ -1,71 +0,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=========================================================
- */
-
-package org.onap.policy.gui.editors.apex.rest.handling.plugin.upload;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Invocation.Builder;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.onap.policy.gui.editors.apex.rest.UploadPluginConfigParameters;
-import org.onap.policy.gui.editors.apex.rest.handling.config.PolicyUploadPluginConfigKey;
-
-public class UploadPluginClientTest {
-
- private UploadPluginClient uploadPluginClient;
-
- @Mock
- private Client client;
-
- private static final String url = "aUrl";
-
- /**
- * Init the mocks and system properties.
- */
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- System.setProperty(PolicyUploadPluginConfigKey.URL.getKey(), url);
- final UploadPluginConfigParameters uploadPluginConfigParameters = new UploadPluginConfigParameters();
- uploadPluginClient = new UploadPluginClient(client, uploadPluginConfigParameters);
- }
-
- @Test
- public void upload() {
- final Builder mockBuilder = mock(Builder.class);
- final WebTarget mockWebTarget = mock(WebTarget.class);
- final Response mockResponse = mock(Response.class);
- doReturn(mockWebTarget).when(client).target(url);
- doReturn(mockBuilder).when(mockWebTarget).request(MediaType.APPLICATION_JSON);
- when(mockBuilder.post(any())).thenReturn(mockResponse);
- final Response actualResponse = uploadPluginClient.upload(new UploadPolicyRequestDto());
- assertEquals(mockResponse, actualResponse);
- }
-} \ No newline at end of file
diff --git a/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.json b/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.json
index 81c2226..9e3ea51 100644
--- a/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.json
+++ b/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.json
@@ -1,708 +1,825 @@
{
- "apexPolicyModel" : {
- "key" : {
- "name" : "PolicyModel",
- "version" : "0.0.1"
- },
- "keyInformation" : {
- "key" : {
- "name" : "KeyInfoMapKey",
- "version" : "0.0.1"
- },
- "keyInfoMap" : {
- "entry" : [ {
- "key" : {
- "name" : "ContextSchemas",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "ContextSchemas",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e000",
- "description" : "Generated description for concept referred to by key \"ContextSchemas:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "KeyInfoMapKey",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "KeyInfoMapKey",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e001",
- "description" : "Generated description for concept referred to by key \"KeyInfoMapKey:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "MapType",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MapType",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e002",
- "description" : "Generated description for concept referred to by key \"MapType:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "PolicyModel",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "PolicyModel",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e003",
- "description" : "Generated description for concept referred to by key \"PolicyModel:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "StringType",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "StringType",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e004",
- "description" : "Generated description for concept referred to by key \"StringType:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "context",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "context",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e005",
- "description" : "Generated description for concept referred to by key \"context:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "contextAlbum0",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "contextAlbum0",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e006",
- "description" : "Generated description for concept referred to by key \"contextAlbum0:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "contextAlbum1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "contextAlbum1",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e007",
- "description" : "Generated description for concept referred to by key \"contextAlbum1:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e008",
- "description" : "Generated description for concept referred to by key \"eventContextItem0:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e009",
- "description" : "Generated description for concept referred to by key \"eventContextItem1:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "events",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "events",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e010",
- "description" : "Generated description for concept referred to by key \"events:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "inEvent",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "inEvent",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e011",
- "description" : "Generated description for concept referred to by key \"inEvent:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "outEvent0",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "outEvent0",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e012",
- "description" : "Generated description for concept referred to by key \"outEvent0:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "outEvent1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "outEvent1",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e013",
- "description" : "Generated description for concept referred to by key \"outEvent1:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "policies",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "policies",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e014",
- "description" : "Generated description for concept referred to by key \"policies:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "policy",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "policy",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e015",
- "description" : "Generated description for concept referred to by key \"policy:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "task",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "task",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e016",
- "description" : "Generated description for concept referred to by key \"task:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "tasks",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "tasks",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e017",
- "description" : "Generated description for concept referred to by key \"tasks:0.0.1\""
- }
- } ]
- }
- },
- "policies" : {
- "key" : {
- "name" : "policies",
- "version" : "0.0.1"
- },
- "policyMap" : {
- "entry" : [ {
- "key" : {
- "name" : "policy",
- "version" : "0.0.1"
- },
- "value" : {
- "policyKey" : {
- "name" : "policy",
- "version" : "0.0.1"
- },
- "template" : "FREEFORM",
- "state" : {
- "entry" : [ {
- "key" : "state",
- "value" : {
- "stateKey" : {
- "parentKeyName" : "policy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "NULL",
- "localName" : "state"
- },
- "trigger" : {
- "name" : "inEvent",
- "version" : "0.0.1"
- },
- "stateOutputs" : {
- "entry" : [ {
- "key" : "stateOutput0",
- "value" : {
- "key" : {
- "parentKeyName" : "policy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "state",
- "localName" : "stateOutput0"
+ "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "topology_template": {
+ "policies": [
+ {
+ "onap.policies.native.apex.Vcpe": {
+ "type": "onap.policies.native.Apex",
+ "type_version": "1.0.0",
+ "properties": {
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "/home/apexuser/examples/models/ONAPvCPE/ONAPvCPEPolicyModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ },
+ "contextParameters": {
+ "parameterClassName": "org.onap.policy.apex.context.parameters.ContextParameters",
+ "schemaParameters": {
+ "Avro": {
+ "parameterClassName": "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
+ },
+ "Java": {
+ "parameterClassName": "org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters",
+ "jsonAdapters": {
+ "Instant": {
+ "adaptedClass": "java.time.Instant",
+ "adaptorClass": "org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter"
+ }
+ }
+ }
+ }
+ }
+ },
+ "policy_type_impl": {
+ "apexPolicyModel": {
+ "key": {
+ "name": "PolicyModel",
+ "version": "0.0.1"
},
- "outgoingEvent" : {
- "name" : "outEvent0",
- "version" : "0.0.1"
+ "keyInformation": {
+ "key": {
+ "name": "KeyInfoMapKey",
+ "version": "0.0.1"
+ },
+ "keyInfoMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "ContextSchemas",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ContextSchemas",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e000",
+ "description": "Generated description for concept referred to by key \"ContextSchemas:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "KeyInfoMapKey",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "KeyInfoMapKey",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e001",
+ "description": "Generated description for concept referred to by key \"KeyInfoMapKey:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "MapType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MapType",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e002",
+ "description": "Generated description for concept referred to by key \"MapType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "PolicyModel",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "PolicyModel",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e003",
+ "description": "Generated description for concept referred to by key \"PolicyModel:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "StringType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "StringType",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e004",
+ "description": "Generated description for concept referred to by key \"StringType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "context",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "context",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e005",
+ "description": "Generated description for concept referred to by key \"context:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "contextAlbum0",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "contextAlbum0",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e006",
+ "description": "Generated description for concept referred to by key \"contextAlbum0:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "contextAlbum1",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "contextAlbum1",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e007",
+ "description": "Generated description for concept referred to by key \"contextAlbum1:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e008",
+ "description": "Generated description for concept referred to by key \"eventContextItem0:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e009",
+ "description": "Generated description for concept referred to by key \"eventContextItem1:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "events",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "events",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e010",
+ "description": "Generated description for concept referred to by key \"events:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "inEvent",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "inEvent",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e011",
+ "description": "Generated description for concept referred to by key \"inEvent:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "outEvent0",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "outEvent0",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e012",
+ "description": "Generated description for concept referred to by key \"outEvent0:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "outEvent1",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "outEvent1",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e013",
+ "description": "Generated description for concept referred to by key \"outEvent1:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "policies",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "policies",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e014",
+ "description": "Generated description for concept referred to by key \"policies:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "policy",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "policy",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e015",
+ "description": "Generated description for concept referred to by key \"policy:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "task",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "task",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e016",
+ "description": "Generated description for concept referred to by key \"task:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "tasks",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "tasks",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e017",
+ "description": "Generated description for concept referred to by key \"tasks:0.0.1\""
+ }
+ }
+ ]
+ }
},
- "nextState" : {
- "parentKeyName" : "NULL",
- "parentKeyVersion" : "0.0.0",
- "parentLocalName" : "NULL",
- "localName" : "NULL"
- }
- }
- } ]
- },
- "contextAlbumReference" : [ {
- "name" : "contextAlbum0",
- "version" : "0.0.1"
- }, {
- "name" : "contextAlbum1",
- "version" : "0.0.1"
- } ],
- "taskSelectionLogic" : {
- "key" : "taskSelectionLogic",
- "logicFlavour" : "MVEL",
- "logic" : "Some TS logic"
- },
- "stateFinalizerLogicMap" : {
- "entry" : [ ]
- },
- "defaultTask" : {
- "name" : "task",
- "version" : "0.0.1"
- },
- "taskReferences" : {
- "entry" : [ {
- "key" : {
- "name" : "task",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "parentKeyName" : "policy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "state",
- "localName" : "task"
+ "policies": {
+ "key": {
+ "name": "policies",
+ "version": "0.0.1"
+ },
+ "policyMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "policy",
+ "version": "0.0.1"
+ },
+ "value": {
+ "policyKey": {
+ "name": "policy",
+ "version": "0.0.1"
+ },
+ "template": "FREEFORM",
+ "state": {
+ "entry": [
+ {
+ "key": "state",
+ "value": {
+ "stateKey": {
+ "parentKeyName": "policy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "state"
+ },
+ "trigger": {
+ "name": "inEvent",
+ "version": "0.0.1"
+ },
+ "stateOutputs": {
+ "entry": [
+ {
+ "key": "stateOutput0",
+ "value": {
+ "key": {
+ "parentKeyName": "policy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "state",
+ "localName": "stateOutput0"
+ },
+ "outgoingEvent": {
+ "name": "outEvent0",
+ "version": "0.0.1"
+ },
+ "nextState": {
+ "parentKeyName": "NULL",
+ "parentKeyVersion": "0.0.0",
+ "parentLocalName": "NULL",
+ "localName": "NULL"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [
+ {
+ "name": "contextAlbum0",
+ "version": "0.0.1"
+ },
+ {
+ "name": "contextAlbum1",
+ "version": "0.0.1"
+ }
+ ],
+ "taskSelectionLogic": {
+ "key": "taskSelectionLogic",
+ "logicFlavour": "MVEL",
+ "logic": "Some TS logic"
+ },
+ "stateFinalizerLogicMap": {
+ "entry": [
+ ]
+ },
+ "defaultTask": {
+ "name": "task",
+ "version": "0.0.1"
+ },
+ "taskReferences": {
+ "entry": [
+ {
+ "key": {
+ "name": "task",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "policy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "state",
+ "localName": "task"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "policy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "state",
+ "localName": "stateOutput0"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ },
+ "firstState": "state"
+ }
+ }
+ ]
+ }
+ },
+ "tasks": {
+ "key": {
+ "name": "tasks",
+ "version": "0.0.1"
+ },
+ "taskMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "task",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "task",
+ "version": "0.0.1"
+ },
+ "inputFields": {
+ "entry": [
+ {
+ "key": "IEPAR0",
+ "value": {
+ "key": "IEPAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "IEPAR1",
+ "value": {
+ "key": "IEPAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
+ }
+ }
+ ]
+ },
+ "outputFields": {
+ "entry": [
+ {
+ "key": "OE0PAR0",
+ "value": {
+ "key": "OE0PAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE0PAR1",
+ "value": {
+ "key": "OE0PAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE1PAR0",
+ "value": {
+ "key": "OE1PAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE1PAR1",
+ "value": {
+ "key": "OE1PAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
+ }
+ }
+ ]
+ },
+ "taskParameters": {
+ "entry": [
+ {
+ "key": "taskParameter0",
+ "value": {
+ "key": {
+ "parentKeyName": "task",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "taskParameter0"
+ },
+ "defaultValue": "Task parameter 0 value"
+ }
+ },
+ {
+ "key": "taskParameter1",
+ "value": {
+ "key": {
+ "parentKeyName": "task",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "taskParameter1"
+ },
+ "defaultValue": "Task parameter 1 value"
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [
+ {
+ "name": "contextAlbum0",
+ "version": "0.0.1"
+ },
+ {
+ "name": "contextAlbum1",
+ "version": "0.0.1"
+ }
+ ],
+ "taskLogic": {
+ "key": "taskLogic",
+ "logicFlavour": "MVEL",
+ "logic": "Some task logic"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "events": {
+ "key": {
+ "name": "events",
+ "version": "0.0.1"
+ },
+ "eventMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "inEvent",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "inEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.model.policymodel.events",
+ "source": "Source",
+ "target": "Target",
+ "parameter": {
+ "entry": [
+ {
+ "key": "IEPAR0",
+ "value": {
+ "key": "IEPAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "IEPAR1",
+ "value": {
+ "key": "IEPAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "outEvent0",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "outEvent0",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.model.policymodel.events",
+ "source": "Source",
+ "target": "Target",
+ "parameter": {
+ "entry": [
+ {
+ "key": "OE0PAR0",
+ "value": {
+ "key": "OE0PAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE0PAR1",
+ "value": {
+ "key": "OE0PAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE1PAR0",
+ "value": {
+ "key": "OE1PAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE1PAR1",
+ "value": {
+ "key": "OE1PAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "outEvent1",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "outEvent1",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.model.policymodel.events",
+ "source": "Source",
+ "target": "Target",
+ "parameter": {
+ "entry": [
+ {
+ "key": "OE1PAR0",
+ "value": {
+ "key": "OE1PAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE1PAR1",
+ "value": {
+ "key": "OE1PAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ },
+ "albums": {
+ "key": {
+ "name": "context",
+ "version": "0.0.1"
+ },
+ "albums": {
+ "entry": [
+ {
+ "key": {
+ "name": "contextAlbum0",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "contextAlbum0",
+ "version": "0.0.1"
+ },
+ "scope": "APPLICATION",
+ "isWritable": true,
+ "itemSchema": {
+ "name": "MapType",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "contextAlbum1",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "contextAlbum1",
+ "version": "0.0.1"
+ },
+ "scope": "GLOBAL",
+ "isWritable": false,
+ "itemSchema": {
+ "name": "StringType",
+ "version": "0.0.1"
+ }
+ }
+ }
+ ]
+ }
},
- "outputType" : "DIRECT",
- "output" : {
- "parentKeyName" : "policy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "state",
- "localName" : "stateOutput0"
+ "schemas": {
+ "key": {
+ "name": "ContextSchemas",
+ "version": "0.0.1"
+ },
+ "schemas": {
+ "entry": [
+ {
+ "key": {
+ "name": "MapType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MapType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A"
+ }
+ },
+ {
+ "key": {
+ "name": "StringType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "StringType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "org.onap.policy.apex.model.policymodel.concepts.TestContextItem000"
+ }
+ },
+ {
+ "key": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.String"
+ }
+ },
+ {
+ "key": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.Long"
+ }
+ }
+ ]
+ }
}
- }
- } ]
- }
- }
- } ]
- },
- "firstState" : "state"
- }
- } ]
- }
- },
- "tasks" : {
- "key" : {
- "name" : "tasks",
- "version" : "0.0.1"
- },
- "taskMap" : {
- "entry" : [ {
- "key" : {
- "name" : "task",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "task",
- "version" : "0.0.1"
- },
- "inputFields" : {
- "entry" : [ {
- "key" : "IEPAR0",
- "value" : {
- "key" : "IEPAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "IEPAR1",
- "value" : {
- "key" : "IEPAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- } ]
- },
- "outputFields" : {
- "entry" : [ {
- "key" : "OE0PAR0",
- "value" : {
- "key" : "OE0PAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE0PAR1",
- "value" : {
- "key" : "OE0PAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE1PAR0",
- "value" : {
- "key" : "OE1PAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE1PAR1",
- "value" : {
- "key" : "OE1PAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- } ]
- },
- "taskParameters" : {
- "entry" : [ {
- "key" : "taskParameter0",
- "value" : {
- "key" : {
- "parentKeyName" : "task",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "NULL",
- "localName" : "taskParameter0"
- },
- "defaultValue" : "Task parameter 0 value"
- }
- }, {
- "key" : "taskParameter1",
- "value" : {
- "key" : {
- "parentKeyName" : "task",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "NULL",
- "localName" : "taskParameter1"
- },
- "defaultValue" : "Task parameter 1 value"
- }
- } ]
- },
- "contextAlbumReference" : [ {
- "name" : "contextAlbum0",
- "version" : "0.0.1"
- }, {
- "name" : "contextAlbum1",
- "version" : "0.0.1"
- } ],
- "taskLogic" : {
- "key" : "taskLogic",
- "logicFlavour" : "MVEL",
- "logic" : "Some task logic"
- }
- }
- } ]
- }
- },
- "events" : {
- "key" : {
- "name" : "events",
- "version" : "0.0.1"
- },
- "eventMap" : {
- "entry" : [ {
- "key" : {
- "name" : "inEvent",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "inEvent",
- "version" : "0.0.1"
- },
- "nameSpace" : "org.onap.policy.apex.model.policymodel.events",
- "source" : "Source",
- "target" : "Target",
- "parameter" : {
- "entry" : [ {
- "key" : "IEPAR0",
- "value" : {
- "key" : "IEPAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "IEPAR1",
- "value" : {
- "key" : "IEPAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- } ]
- }
- }
- }, {
- "key" : {
- "name" : "outEvent0",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "outEvent0",
- "version" : "0.0.1"
- },
- "nameSpace" : "org.onap.policy.apex.model.policymodel.events",
- "source" : "Source",
- "target" : "Target",
- "parameter" : {
- "entry" : [ {
- "key" : "OE0PAR0",
- "value" : {
- "key" : "OE0PAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE0PAR1",
- "value" : {
- "key" : "OE0PAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE1PAR0",
- "value" : {
- "key" : "OE1PAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE1PAR1",
- "value" : {
- "key" : "OE1PAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- } ]
- }
- }
- }, {
- "key" : {
- "name" : "outEvent1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "outEvent1",
- "version" : "0.0.1"
- },
- "nameSpace" : "org.onap.policy.apex.model.policymodel.events",
- "source" : "Source",
- "target" : "Target",
- "parameter" : {
- "entry" : [ {
- "key" : "OE1PAR0",
- "value" : {
- "key" : "OE1PAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE1PAR1",
- "value" : {
- "key" : "OE1PAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
+ }
+ }
}
- } ]
- }
- }
- } ]
- }
- },
- "albums" : {
- "key" : {
- "name" : "context",
- "version" : "0.0.1"
- },
- "albums" : {
- "entry" : [ {
- "key" : {
- "name" : "contextAlbum0",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "contextAlbum0",
- "version" : "0.0.1"
- },
- "scope" : "APPLICATION",
- "isWritable" : true,
- "itemSchema" : {
- "name" : "MapType",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : {
- "name" : "contextAlbum1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "contextAlbum1",
- "version" : "0.0.1"
- },
- "scope" : "GLOBAL",
- "isWritable" : false,
- "itemSchema" : {
- "name" : "StringType",
- "version" : "0.0.1"
- }
- }
- } ]
- }
- },
- "schemas" : {
- "key" : {
- "name" : "ContextSchemas",
- "version" : "0.0.1"
- },
- "schemas" : {
- "entry" : [ {
- "key" : {
- "name" : "MapType",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MapType",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A"
- }
- }, {
- "key" : {
- "name" : "StringType",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "StringType",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "org.onap.policy.apex.model.policymodel.concepts.TestContextItem000"
- }
- }, {
- "key" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.String"
- }
- }, {
- "key" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.Long"
- }
- } ]
- }
- }
- }
-} \ No newline at end of file
+ }
+ }
+ }
+ ]
+ }
+}
diff --git a/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.yaml b/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.yaml
new file mode 100644
index 0000000..201085c
--- /dev/null
+++ b/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.yaml
@@ -0,0 +1,538 @@
+---
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+topology_template:
+ policies:
+ - onap.policies.native.apex.Vcpe:
+ type: onap.policies.native.Apex
+ type_version: 1.0.0
+ properties:
+ engineServiceParameters:
+ name: MyApexEngine
+ version: 0.0.1
+ id: 45
+ instanceCount: 4
+ deploymentPort: 12561
+ policyModelFileName: "/home/apexuser/examples/models/ONAPvCPE/ONAPvCPEPolicyModel.json"
+ engineParameters:
+ executorParameters:
+ JAVASCRIPT:
+ parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters
+ contextParameters:
+ parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters
+ schemaParameters:
+ Avro:
+ parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters
+ Java:
+ parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters
+ jsonAdapters:
+ Instant:
+ adaptedClass: java.time.Instant
+ adaptorClass: org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter
+ policy_type_impl:
+ apexPolicyModel:
+ key:
+ name: PolicyModel
+ version: 0.0.1
+ keyInformation:
+ key:
+ name: KeyInfoMapKey
+ version: 0.0.1
+ keyInfoMap:
+ entry:
+ - key:
+ name: ContextSchemas
+ version: 0.0.1
+ value:
+ key:
+ name: ContextSchemas
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e000
+ description: Generated description for concept referred to by
+ key "ContextSchemas:0.0.1"
+ - key:
+ name: KeyInfoMapKey
+ version: 0.0.1
+ value:
+ key:
+ name: KeyInfoMapKey
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e001
+ description: Generated description for concept referred to by
+ key "KeyInfoMapKey:0.0.1"
+ - key:
+ name: MapType
+ version: 0.0.1
+ value:
+ key:
+ name: MapType
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e002
+ description: Generated description for concept referred to by
+ key "MapType:0.0.1"
+ - key:
+ name: PolicyModel
+ version: 0.0.1
+ value:
+ key:
+ name: PolicyModel
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e003
+ description: Generated description for concept referred to by
+ key "PolicyModel:0.0.1"
+ - key:
+ name: StringType
+ version: 0.0.1
+ value:
+ key:
+ name: StringType
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e004
+ description: Generated description for concept referred to by
+ key "StringType:0.0.1"
+ - key:
+ name: context
+ version: 0.0.1
+ value:
+ key:
+ name: context
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e005
+ description: Generated description for concept referred to by
+ key "context:0.0.1"
+ - key:
+ name: contextAlbum0
+ version: 0.0.1
+ value:
+ key:
+ name: contextAlbum0
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e006
+ description: Generated description for concept referred to by
+ key "contextAlbum0:0.0.1"
+ - key:
+ name: contextAlbum1
+ version: 0.0.1
+ value:
+ key:
+ name: contextAlbum1
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e007
+ description: Generated description for concept referred to by
+ key "contextAlbum1:0.0.1"
+ - key:
+ name: eventContextItem0
+ version: 0.0.1
+ value:
+ key:
+ name: eventContextItem0
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e008
+ description: Generated description for concept referred to by
+ key "eventContextItem0:0.0.1"
+ - key:
+ name: eventContextItem1
+ version: 0.0.1
+ value:
+ key:
+ name: eventContextItem1
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e009
+ description: Generated description for concept referred to by
+ key "eventContextItem1:0.0.1"
+ - key:
+ name: events
+ version: 0.0.1
+ value:
+ key:
+ name: events
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e010
+ description: Generated description for concept referred to by
+ key "events:0.0.1"
+ - key:
+ name: inEvent
+ version: 0.0.1
+ value:
+ key:
+ name: inEvent
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e011
+ description: Generated description for concept referred to by
+ key "inEvent:0.0.1"
+ - key:
+ name: outEvent0
+ version: 0.0.1
+ value:
+ key:
+ name: outEvent0
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e012
+ description: Generated description for concept referred to by
+ key "outEvent0:0.0.1"
+ - key:
+ name: outEvent1
+ version: 0.0.1
+ value:
+ key:
+ name: outEvent1
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e013
+ description: Generated description for concept referred to by
+ key "outEvent1:0.0.1"
+ - key:
+ name: policies
+ version: 0.0.1
+ value:
+ key:
+ name: policies
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e014
+ description: Generated description for concept referred to by
+ key "policies:0.0.1"
+ - key:
+ name: policy
+ version: 0.0.1
+ value:
+ key:
+ name: policy
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e015
+ description: Generated description for concept referred to by
+ key "policy:0.0.1"
+ - key:
+ name: task
+ version: 0.0.1
+ value:
+ key:
+ name: task
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e016
+ description: Generated description for concept referred to by
+ key "task:0.0.1"
+ - key:
+ name: tasks
+ version: 0.0.1
+ value:
+ key:
+ name: tasks
+ version: 0.0.1
+ UUID: 0ce9168c-e6df-414f-9646-6da464b6e017
+ description: Generated description for concept referred to by
+ key "tasks:0.0.1"
+ policies:
+ key:
+ name: policies
+ version: 0.0.1
+ policyMap:
+ entry:
+ - key:
+ name: policy
+ version: 0.0.1
+ value:
+ policyKey:
+ name: policy
+ version: 0.0.1
+ template: FREEFORM
+ state:
+ entry:
+ - key: state
+ value:
+ stateKey:
+ parentKeyName: policy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: state
+ trigger:
+ name: inEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: stateOutput0
+ value:
+ key:
+ parentKeyName: policy
+ parentKeyVersion: 0.0.1
+ parentLocalName: state
+ localName: stateOutput0
+ outgoingEvent:
+ name: outEvent0
+ version: 0.0.1
+ nextState:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ contextAlbumReference:
+ - name: contextAlbum0
+ version: 0.0.1
+ - name: contextAlbum1
+ version: 0.0.1
+ taskSelectionLogic:
+ key: taskSelectionLogic
+ logicFlavour: MVEL
+ logic: Some TS logic
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: task
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: task
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: policy
+ parentKeyVersion: 0.0.1
+ parentLocalName: state
+ localName: task
+ outputType: DIRECT
+ output:
+ parentKeyName: policy
+ parentKeyVersion: 0.0.1
+ parentLocalName: state
+ localName: stateOutput0
+ firstState: state
+ tasks:
+ key:
+ name: tasks
+ version: 0.0.1
+ taskMap:
+ entry:
+ - key:
+ name: task
+ version: 0.0.1
+ value:
+ key:
+ name: task
+ version: 0.0.1
+ inputFields:
+ entry:
+ - key: IEPAR0
+ value:
+ key: IEPAR0
+ fieldSchemaKey:
+ name: eventContextItem0
+ version: 0.0.1
+ - key: IEPAR1
+ value:
+ key: IEPAR1
+ fieldSchemaKey:
+ name: eventContextItem1
+ version: 0.0.1
+ outputFields:
+ entry:
+ - key: OE0PAR0
+ value:
+ key: OE0PAR0
+ fieldSchemaKey:
+ name: eventContextItem0
+ version: 0.0.1
+ - key: OE0PAR1
+ value:
+ key: OE0PAR1
+ fieldSchemaKey:
+ name: eventContextItem1
+ version: 0.0.1
+ - key: OE1PAR0
+ value:
+ key: OE1PAR0
+ fieldSchemaKey:
+ name: eventContextItem0
+ version: 0.0.1
+ - key: OE1PAR1
+ value:
+ key: OE1PAR1
+ fieldSchemaKey:
+ name: eventContextItem1
+ version: 0.0.1
+ taskParameters:
+ entry:
+ - key: taskParameter0
+ value:
+ key:
+ parentKeyName: task
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: taskParameter0
+ defaultValue: Task parameter 0 value
+ - key: taskParameter1
+ value:
+ key:
+ parentKeyName: task
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: taskParameter1
+ defaultValue: Task parameter 1 value
+ contextAlbumReference:
+ - name: contextAlbum0
+ version: 0.0.1
+ - name: contextAlbum1
+ version: 0.0.1
+ taskLogic:
+ key: taskLogic
+ logicFlavour: MVEL
+ logic: Some task logic
+ events:
+ key:
+ name: events
+ version: 0.0.1
+ eventMap:
+ entry:
+ - key:
+ name: inEvent
+ version: 0.0.1
+ value:
+ key:
+ name: inEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.model.policymodel.events
+ source: Source
+ target: Target
+ parameter:
+ entry:
+ - key: IEPAR0
+ value:
+ key: IEPAR0
+ fieldSchemaKey:
+ name: eventContextItem0
+ version: 0.0.1
+ - key: IEPAR1
+ value:
+ key: IEPAR1
+ fieldSchemaKey:
+ name: eventContextItem1
+ version: 0.0.1
+ - key:
+ name: outEvent0
+ version: 0.0.1
+ value:
+ key:
+ name: outEvent0
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.model.policymodel.events
+ source: Source
+ target: Target
+ parameter:
+ entry:
+ - key: OE0PAR0
+ value:
+ key: OE0PAR0
+ fieldSchemaKey:
+ name: eventContextItem0
+ version: 0.0.1
+ - key: OE0PAR1
+ value:
+ key: OE0PAR1
+ fieldSchemaKey:
+ name: eventContextItem1
+ version: 0.0.1
+ - key: OE1PAR0
+ value:
+ key: OE1PAR0
+ fieldSchemaKey:
+ name: eventContextItem0
+ version: 0.0.1
+ - key: OE1PAR1
+ value:
+ key: OE1PAR1
+ fieldSchemaKey:
+ name: eventContextItem1
+ version: 0.0.1
+ - key:
+ name: outEvent1
+ version: 0.0.1
+ value:
+ key:
+ name: outEvent1
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.model.policymodel.events
+ source: Source
+ target: Target
+ parameter:
+ entry:
+ - key: OE1PAR0
+ value:
+ key: OE1PAR0
+ fieldSchemaKey:
+ name: eventContextItem0
+ version: 0.0.1
+ - key: OE1PAR1
+ value:
+ key: OE1PAR1
+ fieldSchemaKey:
+ name: eventContextItem1
+ version: 0.0.1
+ albums:
+ key:
+ name: context
+ version: 0.0.1
+ albums:
+ entry:
+ - key:
+ name: contextAlbum0
+ version: 0.0.1
+ value:
+ key:
+ name: contextAlbum0
+ version: 0.0.1
+ scope: APPLICATION
+ isWritable: true
+ itemSchema:
+ name: MapType
+ version: 0.0.1
+ - key:
+ name: contextAlbum1
+ version: 0.0.1
+ value:
+ key:
+ name: contextAlbum1
+ version: 0.0.1
+ scope: GLOBAL
+ isWritable: false
+ itemSchema:
+ name: StringType
+ version: 0.0.1
+ schemas:
+ key:
+ name: ContextSchemas
+ version: 0.0.1
+ schemas:
+ entry:
+ - key:
+ name: MapType
+ version: 0.0.1
+ value:
+ key:
+ name: MapType
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A
+ - key:
+ name: StringType
+ version: 0.0.1
+ value:
+ key:
+ name: StringType
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: org.onap.policy.apex.model.policymodel.concepts.TestContextItem000
+ - key:
+ name: eventContextItem0
+ version: 0.0.1
+ value:
+ key:
+ name: eventContextItem0
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: java.lang.String
+ - key:
+ name: eventContextItem1
+ version: 0.0.1
+ value:
+ key:
+ name: eventContextItem1
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: java.lang.Long