summaryrefslogtreecommitdiffstats
path: root/gui-editors/gui-editor-apex/src/test
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-07-16 10:24:08 +0100
committerliamfallon <liam.fallon@est.tech>2020-07-17 14:46:26 +0100
commit2de08a64e959788f288d82cd4410fee9424a11bc (patch)
tree93d90b4de43e6e52c7059e842cf8c5ba4d10ecca /gui-editors/gui-editor-apex/src/test
parentee41415476b6ea1775a2f689eecb8713abf81f0c (diff)
Move apex policy editor to policy-gui
This review moves the code for the apex policy editor from the apex repo to the GUI repo. The docker part of the build will be moved in the next review because it is intertwined with the other two legacy apex GUIs and needs to be disentangled. Subsequent reviews on the apex repo will remove this code from there. Issue-ID: POLICY-2621 Change-Id: Ib9a43f463b839201656208a48ab48869a19f963a 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.java410
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ExceptionsTest.java43
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/RestInterfaceTest.java206
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResourceTest.java1347
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeansTest.java70
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/bean/DummyBeanBase.java50
-rw-r--r--gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.json708
7 files changed, 2834 insertions, 0 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
new file mode 100644
index 0000000..1dc47cd
--- /dev/null
+++ b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ApexEditorStartupTest.java
@@ -0,0 +1,410 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.assertThatThrownBy;
+import static org.awaitility.Awaitility.await;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.concurrent.TimeUnit;
+import org.junit.Test;
+import org.onap.policy.gui.editors.apex.rest.ApexEditorMain.EditorState;
+
+/**
+ * Test Apex Editor Startup.
+ */
+public class ApexEditorStartupTest {
+ // CHECKSTYLE:OFF: MagicNumber
+
+ /**
+ * Test no args.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testNoArgs() throws IOException, InterruptedException {
+ 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 "));
+ }
+
+ /**
+ * Test bad arg 0.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testBadArg0() throws IOException, InterruptedException {
+ 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]");
+ }
+
+ /**
+ * Test bad arg 1.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testBadArg1() throws IOException, InterruptedException {
+ 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]");
+ }
+
+ /**
+ * Test bad arg 2.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ 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");
+ }
+
+ /**
+ * Test bad arg 3.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ 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");
+ }
+
+ /**
+ * Test bad arg 4.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testBadArg4() throws IOException, InterruptedException {
+ 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. "
+ + "Illegal character in hostname at index 7: http://+++++:18989/apexservices/");
+ }
+
+ /**
+ * Test help 0.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testHelp0() throws IOException, InterruptedException {
+ final String[] args = new String[] { "--help" };
+
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("usage: org.onap.policy.gui.editors.apex.rest.ApexEditorMain [options...]");
+ }
+
+ /**
+ * Test help 1.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testHelp1() throws IOException, InterruptedException {
+ final String[] args = new String[] { "-h" };
+
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("usage: org.onap.policy.gui.editors.apex.rest.ApexEditorMain [options...]");
+ }
+
+ /**
+ * Test port arg.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testPortArgShJo() throws IOException, InterruptedException {
+ final String[] args = new String[] { "-p12321" };
+
+ 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 "));
+ }
+
+ /**
+ * Test port arg.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testPortArgShSe() throws IOException, InterruptedException {
+ final String[] args = new String[] { "-p", "12321" };
+
+ 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 "));
+ }
+
+ /**
+ * Test port arg.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testPortArgSpace() throws IOException, InterruptedException {
+ 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\"");
+ }
+
+ /**
+ * Test bad port arg 0.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testBadPortArgs0() throws IOException, InterruptedException {
+ 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");
+ }
+
+ /**
+ * Test bad port arg 1023.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testBadPortArgs1023() throws IOException, InterruptedException {
+ 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");
+ }
+
+ /**
+ * Test bad port arg 65536.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testBadPortArgs65536() throws IOException, InterruptedException {
+ 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");
+ }
+
+ /**
+ * Test TTL arg 0.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testTtlArg0() throws IOException, InterruptedException {
+ final String[] args = new String[] { "-t10" };
+
+ 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 "));
+ }
+
+ /**
+ * Test TTL arg 10.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testTtlArg1() throws IOException, InterruptedException {
+ final String[] args = new String[] { "-t", "10", "-l", "localhost" };
+
+ 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 "));
+ }
+
+ /**
+ * Test port TTL arg 0.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testPortTtlArg0() throws IOException, InterruptedException {
+ final String[] args = new String[] { "-t", "10", "-p", "12321" };
+
+ 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 "));
+ }
+
+ /**
+ * Test port TTL arg 10.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException if the test is interrupted
+ */
+ @Test
+ public void testPortTtlArg1() throws IOException, InterruptedException {
+ final String[] args = new String[] { "--time-to-live", "10", "--port", "12321", "--listen", "127.0.0.1" };
+
+ 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 "));
+ }
+
+ /**
+ * Run the editor for tests.
+ *
+ * @param args the args
+ * @return the output string
+ * @throws InterruptedException if the test is interrupted
+ */
+ private String runEditor(final String[] args) throws InterruptedException {
+ final ByteArrayOutputStream outBaStream = new ByteArrayOutputStream();
+ final PrintStream outStream = new PrintStream(outBaStream);
+
+ final ApexEditorMain editorMain = new ApexEditorMain(args, outStream);
+
+ // This test must be started in a thread because we want to intercept the output
+ // in cases where the editor is
+ // started infinitely
+ final Runnable testThread = new Runnable() {
+ @Override
+ public void run() {
+ editorMain.init();
+ }
+ };
+ new Thread(testThread).start();
+ await().atMost(15000, TimeUnit.MILLISECONDS).until(() -> !(editorMain.getState().equals(EditorState.READY)
+ || editorMain.getState().equals(EditorState.INITIALIZING)));
+ editorMain.shutdown();
+ final String outString = outBaStream.toString();
+ System.out.println(outString);
+ return outString;
+ }
+}
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ExceptionsTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ExceptionsTest.java
new file mode 100644
index 0000000..9c83fdc
--- /dev/null
+++ b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ExceptionsTest.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import org.junit.Test;
+
+/**
+ * Test Apex Editor Exceptions.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class ExceptionsTest {
+
+ @Test
+ public void test() {
+ assertNotNull(new ApexEditorException("Message"));
+ assertNotNull(new ApexEditorException("Message", "Object of Exception"));
+ assertNotNull(new ApexEditorException("Message", new IOException()));
+ assertNotNull(new ApexEditorException("Message", new IOException(), "Object of Exception"));
+ }
+}
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
new file mode 100644
index 0000000..238e3b9
--- /dev/null
+++ b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/RestInterfaceTest.java
@@ -0,0 +1,206 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.awaitility.Awaitility.await;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.concurrent.TimeUnit;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation.Builder;
+import javax.ws.rs.client.WebTarget;
+import javax.xml.bind.JAXBException;
+import org.eclipse.persistence.jpa.jpql.Assert;
+import org.junit.AfterClass;
+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.utils.resources.ResourceUtils;
+import org.onap.policy.gui.editors.apex.rest.ApexEditorMain.EditorState;
+
+/**
+ * The RestInterface Test.
+ */
+public class RestInterfaceTest {
+ // CHECKSTYLE:OFF: MagicNumber
+
+ private static final String TESTMODELFILE = "models/PolicyModel.json";
+ private static final String TESTPORTNUM = "18989";
+ private static final long MAX_WAIT = 15000; // 15 sec
+ private static final InputStream SYSIN = System.in;
+ private static final String[] EDITOR_MAIN_ARGS = new String[] { "-p", TESTPORTNUM };
+
+ private static ApexEditorMain editorMain;
+ private static WebTarget target;
+
+ private static AxPolicyModel localmodel = null;
+ private static String localmodelString = null;
+
+ /**
+ * Sets up the tests.
+ *
+ * @throws Exception if an error happens
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ // Start the editor
+ editorMain = new ApexEditorMain(EDITOR_MAIN_ARGS, System.out);
+ // prevent a stray stdin value from killing the editor
+ final ByteArrayInputStream input = new ByteArrayInputStream("".getBytes());
+ System.setIn(input);
+ // Init the editor in a separate thread
+ final Runnable testThread = new Runnable() {
+ @Override
+ public void run() {
+ editorMain.init();
+ }
+ };
+ new Thread(testThread).start();
+ // wait until editorMain is in state RUNNING
+ await().atMost(MAX_WAIT, TimeUnit.MILLISECONDS).until(() -> !(editorMain.getState().equals(EditorState.READY)
+ || editorMain.getState().equals(EditorState.INITIALIZING)));
+
+ if (editorMain.getState().equals(EditorState.STOPPED)) {
+ Assert.fail("Rest endpoint (" + editorMain + ") shut down before it could be used");
+ }
+
+ // create the client
+ final Client c = ClientBuilder.newClient();
+ // Create the web target
+ 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);
+
+ // initialize a session ID
+ createNewSession();
+ }
+
+ /**
+ * Clean up streams.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ */
+ @AfterClass
+ public static void cleanUpStreams() throws IOException, InterruptedException {
+ editorMain.shutdown();
+ // wait until editorMain is in state STOPPED
+ await().atMost(MAX_WAIT, TimeUnit.MILLISECONDS).until(() -> editorMain.getState().equals(EditorState.STOPPED));
+ System.setIn(SYSIN);
+ }
+
+ /**
+ * Test to see that the message create Model with model id -1 .
+ */
+ @Test
+ public void createSession() {
+ createNewSession();
+ }
+
+ /**
+ * Creates a new session.
+ *
+ * @return the session ID
+ */
+ private static int createNewSession() {
+ final ApexApiResult responseMsg = target.path("editor/-1/Session/Create").request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, responseMsg.getResult());
+ assertEquals(1, responseMsg.getMessages().size());
+ return Integer.parseInt(responseMsg.getMessages().get(0));
+ }
+
+ /**
+ * Upload policy.
+ *
+ * @param sessionId the session ID
+ * @param modelAsJsonString the model as json string
+ */
+ private void uploadPolicy(final int sessionId, final String modelAsJsonString) {
+ final Builder requestbuilder = target.path("editor/" + sessionId + "/Model/Load").request();
+ final ApexApiResult responseMsg = requestbuilder.put(Entity.json(modelAsJsonString), ApexApiResult.class);
+ assertTrue(responseMsg.isOk());
+ }
+
+ /**
+ * 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
+ **/
+ @Test
+ public void testUploadThenGet() throws ApexException, JAXBException {
+
+ final int sessionId = createNewSession();
+
+ uploadPolicy(sessionId, localmodelString);
+
+ final ApexApiResult responseMsg = target.path("editor/" + sessionId + "/Policy/Get")
+ .queryParam("name", "policy").queryParam("version", "0.0.1").request().get(ApexApiResult.class);
+ assertTrue(responseMsg.isOk());
+
+ // The string in responseMsg.Messages[0] is a JSON representation of a AxPolicy
+ // 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
+
+}
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
new file mode 100644
index 0000000..934ca7e
--- /dev/null
+++ b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResourceTest.java
@@ -0,0 +1,1347 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+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.utils.resources.TextFileUtils;
+
+/**
+ * Test Apex Editor Rest Resource.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class ApexEditorRestResourceTest extends JerseyTest {
+ @Override
+ protected Application configure() {
+ return new ResourceConfig(ApexEditorRestResource.class);
+ }
+
+ @Test
+ public void testSessionCreate() {
+ ApexApiResult result = target("editor/-2/Session/Create").request().get(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+
+ result = target("editor/-1/Session/Create").request().get(ApexApiResult.class);
+ assertEquals(Result.SUCCESS, result.getResult());
+ final int sessionId = Integer.valueOf(result.getMessages().get(0));
+
+ result = target("editor/-1/Session/Create").request().get(ApexApiResult.class);
+ assertEquals(Result.SUCCESS, result.getResult());
+
+ final int corruptSessionId = ApexEditorRestResource.createCorruptSession();
+
+ target("editor/" + corruptSessionId + "/Model/Analyse").request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/Model/Analyse").request().get(ApexApiResult.class);
+ assertEquals(Result.SUCCESS, result.getResult());
+ result = target("editor/-12345/Model/Analyse").request().get(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+ result = target("editor/12345/Model/Analyse").request().get(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Model/Validate").request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/Model/Validate").request().get(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+ result = target("editor/-12345/Model/Validate").request().get(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+ result = target("editor/12345/Model/Validate").request().get(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+
+ final String modelString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002699\","
+ + "\"description\" : \"A description of the model\"" + "}";
+ final Entity<String> csEntity = Entity.entity(modelString, MediaType.APPLICATION_JSON);
+ result = target("editor/-12345/Model/Create").request().post(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/-12345/Model/Create").request().post(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/1234545/Model/Create").request().post(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Model/Create").request().post(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Model/Create").request().post(csEntity, ApexApiResult.class);
+
+ result = target("editor/-12345/Model/Update").request().put(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/-12345/Model/Update").request().put(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/1234545/Model/Update").request().put(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Model/Update").request().put(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Model/Update").request().put(csEntity, ApexApiResult.class);
+
+ result = target("editor/" + corruptSessionId + "/Model/GetKey").request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/Model/GetKey").request().get(ApexApiResult.class);
+ assertEquals(Result.SUCCESS, result.getResult());
+ result = target("editor/-12345/Model/GetKey").request().get(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+ result = target("editor/12345/Model/GetKey").request().get(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+
+ result = target("editor/" + corruptSessionId + "/Model/Get").request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/Model/Get").request().get(ApexApiResult.class);
+ assertEquals(Result.SUCCESS, result.getResult());
+ result = target("editor/-12345/Model/Get").request().get(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+ result = target("editor/12345/Model/Get").request().get(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+
+ String resultString = target("editor/" + corruptSessionId + "/Model/Download").request().get(String.class);
+ assertEquals("", resultString);
+
+ resultString = target("editor/" + sessionId + "/Model/Download").request().get(String.class);
+ assertNotNull(resultString);
+
+ resultString = target("editor/-12345/Model/Download").request().get(String.class);
+ assertEquals("", resultString);
+
+ resultString = target("editor/12345/Model/Download").request().get(String.class);
+ assertEquals("", resultString);
+
+ result = target("editor/" + corruptSessionId + "/KeyInformation/Get").request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/KeyInformation/Get").request().get(ApexApiResult.class);
+ assertEquals(Result.SUCCESS, result.getResult());
+ result = target("editor/-12345/KeyInformation/Get").request().get(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+ result = target("editor/12345/KeyInformation/Get").request().get(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+
+ result = target("editor/" + corruptSessionId + "/Model/Delete").request().delete(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/Model/Delete").request().delete(ApexApiResult.class);
+ assertEquals(Result.SUCCESS, result.getResult());
+ result = target("editor/-12345/Model/Delete").request().delete(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+ result = target("editor/12345/Model/Delete").request().delete(ApexApiResult.class);
+ assertEquals(Result.FAILED, result.getResult());
+ }
+
+ @Test
+ public void testContextSchema() throws IOException {
+ ApexApiResult result = target("editor/-1/Session/Create").request().get(ApexApiResult.class);
+ assertEquals(Result.SUCCESS, result.getResult());
+ final int sessionId = Integer.valueOf(result.getMessages().get(0));
+
+ final int corruptSessionId = ApexEditorRestResource.createCorruptSession();
+
+ result = target("editor/-12345/Validate/ContextSchema").request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Validate/ContextSchema").request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/Validate/ContextSchema").request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ result = target("editor/" + sessionId + "/Validate/ContextSchema").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ result = target("editor/" + sessionId + "/Validate/ContextSchema").queryParam("name", "%%%$£")
+ .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");
+
+ Entity<String> modelEntity = Entity.entity("Somewhere over the rainbow", MediaType.APPLICATION_JSON);
+ result = target("editor/" + -12345 + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + 12345 + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ modelEntity = Entity.entity("", MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ modelEntity = Entity.entity(modelString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/ContextSchema/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/ContextSchema/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+
+ String csString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ + "\"schemaFlavour\" : \"Java\"," + "\"schemaDefinition\" : \"java.lang.String\","
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ Entity<String> csEntity = Entity.entity(csString, MediaType.APPLICATION_JSON);
+ result = target("editor/-12345/ContextSchema/Create").request().post(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/1234545/ContextSchema/Create").request().post(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/ContextSchema/Create").request().post(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/ContextSchema/Create").request().post(csEntity, ApexApiResult.class);
+
+ csString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ + "\"schemaFlavour\" : \"Java\"," + "\"schemaDefinition\" : \"my.perfect.String\","
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ csEntity = Entity.entity(csString, MediaType.APPLICATION_JSON);
+ result = target("editor/-12345/ContextSchema/Update").request().put(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/1234545/ContextSchema/Update").request().put(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/ContextSchema/Update").request().put(csEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/ContextSchema/Update").request().put(csEntity, ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/ContextSchema/Get").queryParam("name", "Hello")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/ContextSchema/Get").queryParam("name", "NonExistant")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+ result = target("editor/-123345/ContextSchema/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/123345/ContextSchema/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ target("editor/" + corruptSessionId + "/ContextSchema/Get").queryParam("name", "Hello")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/Validate/ContextSchema").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/ContextSchema/Delete").queryParam("name", "Hello")
+ .queryParam("version", "0.0.2").request().delete(ApexApiResult.class);
+
+ result = target("editor/-123345/ContextSchema/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/123345/ContextSchema/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/ContextSchema/Delete").queryParam("name", "Hello")
+ .queryParam("version", "0.0.2").request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/ContextSchema/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ }
+
+ @Test
+ public void testContextAlbum() throws IOException {
+ ApexApiResult result = target("editor/-1/Session/Create").request().get(ApexApiResult.class);
+ assertEquals(Result.SUCCESS, result.getResult());
+ final int sessionId = Integer.valueOf(result.getMessages().get(0));
+ final int corruptSessionId = ApexEditorRestResource.createCorruptSession();
+
+ result = target("editor/-12345/Validate/ContextAlbum").request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Validate/ContextAlbum").request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/Validate/ContextAlbum").request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ result = target("editor/" + sessionId + "/Validate/ContextAlbum").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ result = target("editor/" + sessionId + "/Validate/ContextAlbum").queryParam("name", "%%%$£")
+ .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");
+
+ Entity<String> modelEntity = Entity.entity("Somewhere over the rainbow", MediaType.APPLICATION_JSON);
+ result = target("editor/" + -12345 + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + 12345 + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ modelEntity = Entity.entity("", MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ modelEntity = Entity.entity(modelString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/ContextAlbum/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ String caString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ + "\"scope\" : \"Domain\"," + "\"writeable\" : false,"
+ + "\"itemSchema\" : {\"name\" : \"StringType\", \"version\" : \"0.0.1\"},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ Entity<String> caEntity = Entity.entity(caString, MediaType.APPLICATION_JSON);
+ result = target("editor/-12345/ContextAlbum/Create").request().post(caEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/1234545/ContextAlbum/Create").request().post(caEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/ContextAlbum/Create").request().post(caEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/ContextAlbum/Create").request().post(caEntity, ApexApiResult.class);
+
+ caString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ + "\"scope\" : \"Global\"," + "\"writeable\" : false,"
+ + "\"itemSchema\" : {\"name\" : \"StringType\", \"version\" : \"0.0.1\"},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ caEntity = Entity.entity(caString, MediaType.APPLICATION_JSON);
+ result = target("editor/-12345/ContextAlbum/Update").request().put(caEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/1234545/ContextAlbum/Update").request().put(caEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/ContextAlbum/Update").request().put(caEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/ContextAlbum/Update").request().put(caEntity, ApexApiResult.class);
+
+ target("editor/" + corruptSessionId + "/ContextAlbum/Get").queryParam("name", "Hello")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/ContextAlbum/Get").queryParam("name", "Hello")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/ContextAlbum/Get").queryParam("name", "IDontExist")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+ result = target("editor/-123345/ContextAlbum/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/123345/ContextAlbum/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ result = target("editor/" + sessionId + "/Validate/ContextAlbum").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/ContextAlbum/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+
+ result = target("editor/-123345/ContextAlbum/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/123345/ContextAlbum/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/ContextAlbum/Delete").queryParam("name", "Hello")
+ .queryParam("version", "0.0.2").request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/ContextAlbum/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ }
+
+ @Test
+ public void testEvent() throws IOException {
+ final int corruptSessionId = ApexEditorRestResource.createCorruptSession();
+
+ ApexApiResult result = target("editor/-1/Session/Create").request().get(ApexApiResult.class);
+ assertEquals(Result.SUCCESS, result.getResult());
+ final int sessionId = Integer.valueOf(result.getMessages().get(0));
+
+ result = target("editor/-12345/Validate/Event").request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ result = target("editor/" + sessionId + "/Validate/Event").request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Validate/Event").request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/Validate/Event").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ result = target("editor/" + sessionId + "/Validate/Event").queryParam("name", "%%%$£")
+ .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");
+
+ Entity<String> modelEntity = Entity.entity("Somewhere over the rainbow", MediaType.APPLICATION_JSON);
+ result = target("editor/" + -12345 + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + 12345 + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ modelEntity = Entity.entity("", MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ modelEntity = Entity.entity(modelString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Event/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ String entityString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ + "\"namespace\" : \"somewhere.over.the.rainbow\"," + "\"source\" : \"beginning\","
+ + "\"target\" : \"end\"," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ Entity<String> entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/-12345/Event/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/1234545/Event/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Event/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Event/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Event/Create").request().post(entity, ApexApiResult.class);
+
+ entityString = "{" + "\"name\" : \"Hiya\"," + "\"version\" : \"0.0.2\","
+ + "\"namespace\" : \"somewhere.over.the.rainbow\"," + "\"source\" : \"beginning\","
+ + "\"target\" : \"end\"," + "\"parameters\" : {},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Event/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"HowsItGoing\"," + "\"version\" : \"0.0.2\","
+ + "\"namespace\" : \"somewhere.over.the.rainbow\"," + "\"source\" : \"beginning\","
+ + "\"target\" : \"end\","
+ + "\"parameters\" : {\"Par0\" : {\"name\" : \"StringType\", \"version\" : \"0.0.1\", "
+ + "\"localName\" : \"Par0\", \"optional\" : false}},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Event/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hi\"," + "\"version\" : \"0.0.2\","
+ + "\"namespace\" : \"somewhere.over.the.rainbow\"," + "\"source\" : \"beginning\","
+ + "\"target\" : \"end\"," + "\"parameters\" : {\"Par0\" : null},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Event/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"GoodDay\"," + "\"version\" : \"0.0.2\","
+ + "\"namespace\" : \"somewhere.over.the.rainbow\"," + "\"source\" : \"beginning\","
+ + "\"target\" : \"end\","
+ + "\"parameters\" : {\"Par0\" : {\"name\" : \"NonExistantType\", \"version\" : \"0.0.1\", "
+ + "\"localName\" : \"Par0\", \"optional\" : false}},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Event/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ + "\"namespace\" : \"somewhere.over.someone.elses.rainbow\"," + "\"source\" : \"start\","
+ + "\"target\" : \"finish\"," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/-12345/Event/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/1234545/Event/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Event/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Event/Update").request().put(entity, ApexApiResult.class);
+
+ entityString = "{" + "\"name\" : null," + "\"version\" : \"0.0.2\","
+ + "\"namespace\" : \"somewhere.over.someone.elses.rainbow\"," + "\"source\" : \"start\","
+ + "\"target\" : \"finish\"," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Event/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"NonExistantEvent\"," + "\"version\" : \"0.0.2\","
+ + "\"namespace\" : \"somewhere.over.someone.elses.rainbow\"," + "\"source\" : \"start\","
+ + "\"target\" : \"finish\"," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Event/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ result = target("editor/" + sessionId + "/Event/Get").queryParam("name", "Hello")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Event/Get").queryParam("name", "IDontExist")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+ result = target("editor/-123345/Event/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/123345/Event/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Event/Get").queryParam("name", "Hello")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/Validate/Event").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/-12345/Validate/Event").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/12345/Validate/Event").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Event/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+
+ result = target("editor/-123345/Event/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/123345/Event/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Event/Delete").queryParam("name", "Hello")
+ .queryParam("version", "0.0.2").request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Event/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ }
+
+ @Test
+ public void testTask() throws IOException {
+ final int corruptSessionId = ApexEditorRestResource.createCorruptSession();
+
+ ApexApiResult result = target("editor/-1/Session/Create").request().get(ApexApiResult.class);
+ assertEquals(Result.SUCCESS, result.getResult());
+ final int sessionId = Integer.valueOf(result.getMessages().get(0));
+
+ result = target("editor/-12345/Validate/Task").request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ result = target("editor/" + sessionId + "/Validate/Task").request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ try {
+ target("editor/" + corruptSessionId + "/Validate/Task").request().get(ApexApiResult.class);
+ } catch (final Exception e) {
+ assertEquals("HTTP 500 Request failed.", e.getMessage());
+ }
+
+ result = target("editor/" + sessionId + "/Validate/Task").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ result = target("editor/" + sessionId + "/Validate/Task").queryParam("name", "%%%$£")
+ .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");
+
+ Entity<String> modelEntity = Entity.entity("Somewhere over the rainbow", MediaType.APPLICATION_JSON);
+ result = target("editor/" + -12345 + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + 12345 + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ modelEntity = Entity.entity("", MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ modelEntity = Entity.entity(modelString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Event/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ String entityString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ Entity<String> entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/-12345/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/1234545/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+
+ entityString = "{" + "\"name\" : \"Hiya\"," + "\"version\" : \"0.0.2\","
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"HowsItGoing\"," + "\"version\" : \"0.0.2\","
+ + "\"inputFields\" : {\"IField0\" : {\"name\" : \"StringType\", \"version\" : \"0.0.1\", "
+ + "\"localName\" : \"IField0\", \"optional\" : false}},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hi\"," + "\"version\" : \"0.0.2\","
+ + "\"inputFields\" : {\"IField0\" : null},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"GoodDay\"," + "\"version\" : \"0.0.2\","
+ + "\"inputFields\" : {\"IField0\" : {\"name\" : \"NonExistantType\", \"version\" : \"0.0.1\", "
+ + "\"localName\" : \"IField0\", \"optional\" : false}},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Howdy\"," + "\"version\" : \"0.0.2\","
+ + "\"inputFields\" : {\"IField0\" : {\"name\" : \"NonExistantType\", \"version\" : \"0.0.1\", "
+ + "\"localName\" : \"NotIField0\", \"optional\" : false}},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"HowsItGoing2\"," + "\"version\" : \"0.0.2\","
+ + "\"outputFields\" : {\"OField0\" : {\"name\" : \"StringType\", \"version\" : \"0.0.1\", "
+ + "\"localName\" : \"OField0\", \"optional\" : false}},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hi2\"," + "\"version\" : \"0.0.2\","
+ + "\"outputFields\" : {\"OField0\" : null},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"GoodDay2\"," + "\"version\" : \"0.0.2\","
+ + "\"outputFields\" : {\"OField0\" : {\"name\" : \"NonExistantType\", \"version\" : \"0.0.1\","
+ + " \"localName\" : \"OField0\", \"optional\" : false}},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Howdy2\"," + "\"version\" : \"0.0.2\","
+ + "\"outputFields\" : {\"OField0\" : {\"name\" : \"NonExistantType\", \"version\" : \"0.0.1\", "
+ + "\"localName\" : \"NotOField0\", \"optional\" : false}},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"HowsItGoing3\"," + "\"version\" : \"0.0.2\","
+ + "\"taskLogic\" : {\"logicFlavour\" : \"LemonAndLime\", \"logic\" : \"lots of lemons,"
+ + " lots of lime\"}," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hi3\"," + "\"version\" : \"0.0.2\","
+ + "\"taskLogic\" : null," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"GoodDay3\"," + "\"version\" : \"0.0.2\","
+ + "\"namespace\" : \"somewhere.over.the.rainbow\"," + "\"source\" : \"beginning\","
+ + "\"target\" : \"end\","
+ + "\"taskLogic\" : {\"logicFlavour\" : \"UNDEFINED\", \"logic\" : \"lots of lemons,"
+ + " lots of lime\"}," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Howdy3\"," + "\"version\" : \"0.0.2\","
+ + "\"taskLogic\" : {\"logicFlavour\" : \"LemonAndLime\", \"logic\" : null},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"HowsItGoing4\"," + "\"version\" : \"0.0.2\","
+ + "\"parameters\" : {\"Par0\" : {\"parameterName\" : \"Par0\", "
+ + "\"defaultValue\" : \"Parameter Defaultvalue\"}},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hi4\"," + "\"version\" : \"0.0.2\","
+ + "\"parameters\" : {\"Par0\" : null},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"GoodDay4\"," + "\"version\" : \"0.0.2\","
+ + "\"parameters\" : {\"Par0\" : {\"parameterName\" : \"NotPar0\", \"defaultValue\" : "
+ + "\"Parameter Defaultvalue\"}}," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Howdy4\"," + "\"version\" : \"0.0.2\","
+ + "\"parameters\" : {\"Par0\" : {\"parameterName\" : \"MyParameter\", \"defaultValue\" : null}},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"HowsItGoing5\"," + "\"version\" : \"0.0.2\","
+ + "\"contexts\" : [{\"name\" : \"contextAlbum0\", \"version\" : \"0.0.1\"}],"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hi5\"," + "\"version\" : \"0.0.2\","
+ + "\"contexts\" : []," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"GoodDay5\"," + "\"version\" : \"0.0.2\","
+ + "\"contexts\" : [{\"name\" : \"NonExistantType\", \"version\" : \"0.0.1\"}],"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Howdy5\"," + "\"version\" : \"0.0.2\","
+ + "\"contexts\" : [{\"name\" : null, \"version\" : \"0.0.1\"}],"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/-12345/Task/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/1234545/Task/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Task/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Task/Update").request().put(entity, ApexApiResult.class);
+
+ entityString = "{" + "\"name\" : null," + "\"version\" : \"0.0.2\","
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"NonExistantEvent\"," + "\"version\" : \"0.0.2\","
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Task/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ result = target("editor/" + sessionId + "/Task/Get").queryParam("name", "Hello")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Task/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Task/Get").queryParam("name", "IDontExist")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+ result = target("editor/-123345/Task/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/123345/Task/Get").queryParam("name", (String) null).queryParam("version", (String) null)
+ .request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Task/Get").queryParam("name", "Hello")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/Validate/Event").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/-12345/Validate/Event").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/12345/Validate/Event").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Task/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+
+ result = target("editor/-123345/Task/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/123345/Task/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Task/Delete").queryParam("name", "Hello")
+ .queryParam("version", "0.0.2").request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Task/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ }
+
+ @Test
+ public void testPolicy() throws IOException {
+ final int corruptSessionId = ApexEditorRestResource.createCorruptSession();
+
+ ApexApiResult result = target("editor/-1/Session/Create").request().get(ApexApiResult.class);
+ assertEquals(Result.SUCCESS, result.getResult());
+ final int sessionId = Integer.valueOf(result.getMessages().get(0));
+
+ result = target("editor/-12345/Model/Validate").request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ result = target("editor/" + sessionId + "/Model/Validate").request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Model/Validate").request().get(ApexApiResult.class);
+ result = target("editor/" + sessionId + "/Model/Validate").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ result = target("editor/" + sessionId + "/Model/Validate").queryParam("name", "%%%$£")
+ .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");
+
+ Entity<String> modelEntity = Entity.entity("Somewhere over the rainbow", MediaType.APPLICATION_JSON);
+ result = target("editor/" + -12345 + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + 12345 + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ modelEntity = Entity.entity("", MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ modelEntity = Entity.entity(modelString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Model/Load").request().put(modelEntity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Event/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ String entityString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"}," + " \"stateOutputs\" : {"
+ + " \"so0\" : {" + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ Entity<String> entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/-12345/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/1234545/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+
+ entityString = "{" + "\"name\" : \"GoodTaSeeYa\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : null," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"HelloAnother\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"}," + " \"stateOutputs\" : {"
+ + " \"so0\" : {" + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello2\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : null," + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"stateOutputs\" : {" + " \"so0\" : {"
+ + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello3\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : null," + " \"stateOutputs\" : {" + " \"so0\" : {"
+ + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello4\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"}," + " \"stateOutputs\" : null,"
+ + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello5\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"}," + " \"stateOutputs\" : {"
+ + " \"so0\" : {" + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : null" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello6\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"IDontExist\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"}," + " \"stateOutputs\" : {"
+ + " \"so0\" : {" + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello7\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : null" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello8\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"}," + " \"stateOutputs\" : {"
+ + " \"so0\" : {"
+ + " \"event\" : {\"name\" : \"IDontExist\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello9\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"}," + " \"stateOutputs\" : {"
+ + " \"so0\" : {" + " \"event\" : null," + " \"nextState\" : null" + " }"
+ + " }," + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ System.err.println(result);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello10\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"}," + " \"stateOutputs\" : {"
+ + " \"so0\" : {" + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"IDontExist\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello11\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"}," + " \"stateOutputs\" : {"
+ + " \"so0\" : {" + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : null," + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\""
+ + " }" + " }" + " }" + "}," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello12\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"taskSelectionLogic\" : {\"logicFlavour\" : \"LemonAndLime\", \"logic\" : \"lots of lemons, "
+ + "lots of lime\"}," + " \"stateOutputs\" : {" + " \"so0\" : {"
+ + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {"
+ + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }"
+ + "}," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello13\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"taskSelectionLogic\" : {\"logicFlavour\" : \"LemonAndLime\", \"logic\" : null},"
+ + " \"stateOutputs\" : {" + " \"so0\" : {"
+ + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {"
+ + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }"
+ + "}," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello14\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"taskSelectionLogic\" : {\"logicFlavour\" : \"LemonAndLime\", \"logic\" : \"lots of lemons, "
+ + "lots of lime\"},"
+ + " \"contexts\" : [{\"name\" : \"contextAlbum0\", \"version\" : \"0.0.1\"}],"
+ + " \"stateOutputs\" : {" + " \"so0\" : {"
+ + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {"
+ + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }"
+ + "}," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello15\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"taskSelectionLogic\" : {\"logicFlavour\" : \"LemonAndLime\", \"logic\" : \"lots of lemons, "
+ + "lots of lime\"}," + " \"contexts\" : [{\"name\" : \"IDontExist\", \"version\" : \"0.0.1\"}],"
+ + " \"stateOutputs\" : {" + " \"so0\" : {"
+ + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {"
+ + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }"
+ + "}," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello16\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"taskSelectionLogic\" : {\"logicFlavour\" : \"LemonAndLime\", \"logic\" : \"lots of lemons, "
+ + "lots of lime\"}," + " \"contexts\" : [null]," + " \"stateOutputs\" : {"
+ + " \"so0\" : {"
+ + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {"
+ + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }"
+ + "}," + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello17\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"taskSelectionLogic\" : {\"logicFlavour\" : \"LemonAndLime\", \"logic\" : \"lots of lemons, "
+ + "lots of lime\"},"
+ + " \"contexts\" : [{\"name\" : \"contextAlbum0\", \"version\" : \"0.0.1\"}],"
+ + " \"stateOutputs\" : {" + " \"so0\" : {"
+ + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {"
+ + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " },"
+ + " \"finalizers\" : {"
+ + " \"sf0\" : {\"logicFlavour\" : \"LemonAndLime\", \"logic\" : \"lots of lemons, "
+ + "lots of lime\"}" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello18\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"taskSelectionLogic\" : {\"logicFlavour\" : \"LemonAndLime\", \"logic\" : \"lots of lemons, "
+ + "lots of lime\"},"
+ + " \"contexts\" : [{\"name\" : \"contextAlbum0\", \"version\" : \"0.0.1\"}],"
+ + " \"stateOutputs\" : {" + " \"so0\" : {"
+ + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {"
+ + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " },"
+ + " \"finalizers\" : {" + " \"sf0\" : null" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"Hello19\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"taskSelectionLogic\" : {\"logicFlavour\" : \"LemonAndLime\", \"logic\" : \"lots of lemons, "
+ + "lots of lime\"},"
+ + " \"contexts\" : [{\"name\" : \"contextAlbum0\", \"version\" : \"0.0.1\"}],"
+ + " \"stateOutputs\" : {" + " \"so0\" : {"
+ + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {"
+ + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " },"
+ + " \"finalizers\" : {"
+ + " \"sf0\" : {\"logicFlavour\" : \"LemonAndLime\", \"logic\" : null}" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"HelloAnother\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"}," + " \"stateOutputs\" : {"
+ + " \"so0\" : {" + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A better description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/-12345/Policy/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/1234545/Policy/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Policy/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ result = target("editor/" + sessionId + "/Policy/Update").queryParam("firstStatePeriodic", "true").request()
+ .put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Policy/Update").request().put(entity, ApexApiResult.class);
+
+ entityString = "{" + "\"name\" : null," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"}," + " \"stateOutputs\" : {"
+ + " \"so0\" : {" + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A better description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ entityString = "{" + "\"name\" : \"IDontExist\"," + "\"version\" : \"0.0.2\","
+ + "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
+ + "\"states\" : {" + " \"state\" : {" + " \"name\" : \"state\","
+ + " \"trigger\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"defaultTask\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"}," + " \"stateOutputs\" : {"
+ + " \"so0\" : {" + " \"event\" : {\"name\" : \"inEvent\", \"version\" : \"0.0.1\"},"
+ + " \"nextState\" : null" + " }" + " }," + " \"tasks\" : {" + " \"tr0\" : {"
+ + " \"task\" : {\"name\" : \"task\", \"version\" : \"0.0.1\"},"
+ + " \"outputType\" : \"DIRECT\"," + " \"outputName\" : \"so0\"" + " }" + " }" + " }" + "},"
+ + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
+ + "\"description\" : \"A better description of hello\"" + "}";
+ entity = Entity.entity(entityString, MediaType.APPLICATION_JSON);
+ result = target("editor/" + sessionId + "/Policy/Update").request().put(entity, ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ result = target("editor/" + sessionId + "/Policy/Get").queryParam("name", "Hello")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Policy/Get").queryParam("name", "IDontExist")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+ result = target("editor/" + sessionId + "/Policy/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/-123345/Policy/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/123345/Policy/Get").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Policy/Get").queryParam("name", "Hello")
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+
+ result = target("editor/" + sessionId + "/Validate/Event").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/-12345/Validate/Event").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/12345/Validate/Event").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().get(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+
+ target("editor/" + corruptSessionId + "/Policy/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+
+ result = target("editor/-123345/Policy/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/123345/Policy/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = target("editor/" + sessionId + "/Policy/Delete").queryParam("name", "Hello")
+ .queryParam("version", "0.0.2").request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = target("editor/" + sessionId + "/Policy/Delete").queryParam("name", (String) null)
+ .queryParam("version", (String) null).request().delete(ApexApiResult.class);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ }
+}
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeansTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeansTest.java
new file mode 100644
index 0000000..c8c0971
--- /dev/null
+++ b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeansTest.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.bean;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+
+/**
+ * Test the beans.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class BeansTest {
+
+ @Test
+ public void testBeans() {
+ assertNotNull(new BeanEvent().toString());
+ assertNotNull(new BeanState().toString());
+ assertNotNull(new BeanContextAlbum().toString());
+ assertNotNull(new BeanPolicy().toString());
+ assertNotNull(new BeanContextSchema().toString());
+ assertNotNull(new BeanField().toString());
+ assertNotNull(new BeanModel().toString());
+ assertNotNull(new BeanLogic().toString());
+ assertNotNull(new BeanStateOutput().toString());
+ assertNotNull(new BeanTaskParameter().toString());
+ assertNotNull(new BeanKeyRef().toString());
+ assertNotNull(new BeanStateTaskRef().toString());
+ assertNotNull(new BeanTask().toString());
+
+ final BeanState beanState = new BeanState();
+ assertNull(beanState.getName());
+ beanState.setDefaultTask(new BeanKeyRef());
+ assertNotNull(beanState.getDefaultTask());
+
+ final BeanEvent beanEvent = new BeanEvent();
+ assertNull(beanEvent.get("name"));
+
+ final DummyBeanBase beanFake = new DummyBeanBase();
+ assertNull(beanFake.get("name"));
+ assertNull(beanFake.get("field1"));
+
+ assertThatThrownBy(() -> beanFake.get("iDontExist")).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> beanFake.get("nome")).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> beanFake.get("field2")).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> beanFake.get("field3")).isInstanceOf(IllegalArgumentException.class);
+ }
+}
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/bean/DummyBeanBase.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/bean/DummyBeanBase.java
new file mode 100644
index 0000000..edb240b
--- /dev/null
+++ b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/bean/DummyBeanBase.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.bean;
+
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * The Event Bean.
+ */
+@XmlType
+public class DummyBeanBase extends BeanBase {
+ private String name = null;
+ private String version = null;
+ private String field1 = null;
+ private int field2 = 0;
+ private int field3 = 0;
+
+ public String getName() {
+ field1 = name;
+ return field1;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public int getField2() {
+ field3 = field2;
+ return field3;
+ }
+}
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
new file mode 100644
index 0000000..81c2226
--- /dev/null
+++ b/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.json
@@ -0,0 +1,708 @@
+{
+ "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"
+ }
+ } ]
+ }
+ }
+ }
+} \ No newline at end of file