From 4e3bb539cd8a678d8ea1e861c0cf04d472d50d9d Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Fri, 21 Dec 2018 15:36:35 +0900 Subject: Rename test classes in apex-pdp/model,core Make test classes name consitence by adding 'Test' at end of junit test classes and adding 'Support' or 'Dummy' at start of util or dummy type of test classes Issue-ID: POLICY-1263 Change-Id: I6cb8d09799d7abd1b50ead1edbc4986649ad4ba7 Signed-off-by: Parshad Patel --- .../apex/model/modelapi/ApexApiResultTest.java | 81 ++ .../modelapi/ApexEditorApiContextAlbumTest.java | 174 ++++ .../modelapi/ApexEditorApiContextSchemaTest.java | 153 +++ .../model/modelapi/ApexEditorApiEventTest.java | 197 ++++ .../model/modelapi/ApexEditorApiKeyInfoTest.java | 137 +++ .../model/modelapi/ApexEditorApiPolicyTest.java | 1023 ++++++++++++++++++++ .../apex/model/modelapi/ApexEditorApiTaskTest.java | 485 ++++++++++ .../apex/model/modelapi/ApexModelApiTest.java | 259 +++++ .../apex/model/modelapi/ModelFacadeTest.java | 110 +++ .../model/modelapi/ModelHandlerFacadeTest.java | 148 +++ .../modelapi/TestApexEditorApiContextAlbum.java | 174 ---- .../modelapi/TestApexEditorApiContextSchema.java | 153 --- .../model/modelapi/TestApexEditorApiEvent.java | 197 ---- .../model/modelapi/TestApexEditorApiKeyInfo.java | 137 --- .../model/modelapi/TestApexEditorApiPolicy.java | 1023 -------------------- .../apex/model/modelapi/TestApexEditorApiTask.java | 485 ---------- .../apex/model/modelapi/TestApexModelApi.java | 259 ----- .../policy/apex/model/modelapi/TestApiResult.java | 81 -- .../apex/model/modelapi/TestModelFacade.java | 110 --- .../model/modelapi/TestModelHandlerFacade.java | 148 --- 20 files changed, 2767 insertions(+), 2767 deletions(-) create mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexApiResultTest.java create mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java create mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java create mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java create mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java create mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java create mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java create mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java create mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java create mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java delete mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiContextAlbum.java delete mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiContextSchema.java delete mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiEvent.java delete mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiKeyInfo.java delete mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiPolicy.java delete mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiTask.java delete mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexModelApi.java delete mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApiResult.java delete mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestModelFacade.java delete mode 100644 model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestModelHandlerFacade.java (limited to 'model/model-api/src') diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexApiResultTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexApiResultTest.java new file mode 100644 index 000000000..43a9fa42e --- /dev/null +++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexApiResultTest.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.model.modelapi; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.Arrays; + +import org.junit.Test; +import org.onap.policy.apex.model.modelapi.ApexApiResult.Result; + +/** + * Test API results. + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class ApexApiResultTest { + + @Test + public void testApiResult() { + assertNotNull(new ApexApiResult()); + + for (final Result result : Result.values()) { + assertNotNull(new ApexApiResult(result)); + } + + assertNotNull(new ApexApiResult(Result.SUCCESS, "Result Message")); + assertNotNull(new ApexApiResult(Result.FAILED, new IOException("IO Exception message"))); + assertNotNull(new ApexApiResult(Result.FAILED, "Result Message", new IOException("IO Exception message"))); + + final ApexApiResult result = + new ApexApiResult(Result.FAILED, "Result Message", new IOException("IO Exception message")); + + assertFalse(result.isOk()); + assertTrue(result.isNok()); + assertEquals(Result.FAILED, result.getResult()); + assertEquals("Result Message\nIO Exception message\njava.io.IOExce", result.getMessage().substring(0, 50)); + + final ApexApiResult result2 = new ApexApiResult(Result.SUCCESS); + result2.addMessage(null); + assertEquals("", result2.getMessage()); + result2.addMessage(""); + assertEquals("", result2.getMessage()); + result2.addMessage("funky message"); + assertEquals("funky message\n", result2.getMessage()); + + result2.setResult(Result.OTHER_ERROR); + assertEquals(Result.OTHER_ERROR, result2.getResult()); + + final String[] messages = {"First Message", "Second Message", "Third Message"}; + result2.setMessages(Arrays.asList(messages)); + assertEquals("First Message", result2.getMessages().get(0)); + assertEquals("Second Message", result2.getMessages().get(1)); + assertEquals("Third Message", result2.getMessages().get(2)); + + assertEquals("result: OTHER_ERROR\nFirst Message\nSecond Message\nThird Message\n", result2.toString()); + assertEquals("{\n" + "\"result\": \"OTHER_ERROR\",\n" + "\"messages\": [\n" + "\"First Message\",\n" + + "\"Second Message\",\n" + "\"Third Message\"]\n" + "}\n", result2.toJson()); + } +} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java new file mode 100644 index 000000000..0d442e95f --- /dev/null +++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.model.modelapi; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Context album for API tests. + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class ApexEditorApiContextAlbumTest { + @Test + public void testContextAlbumCrud() { + final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); + + ApexApiResult result = apexModel.validateContextAlbum(null, null); + assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); + + result = apexModel.validateContextAlbum("%%%$£", null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createContextAlbum("MyMap002", "0.0.2", "APPLICATION", "true", "MapType", "0.0.1", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createContextAlbum("MyMap012", "0.1.2", "ZOOBY", "false", "MapType", "0.0.1", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createContextAlbum("MyMap012", "0.1.4", "UNDEFINED", null, "MapType", "0.0.1", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createContextAlbum("MyMap012", null, null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "+++", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapZooby", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", "--++", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", "0.0.2", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createContextAlbum("MyMap002", "0.0.2", "APPLICATION", "true", "MapType", null, + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createContextAlbum("MyMap011", "0.1.2", "APPLICATION", "true", "MapType", "0.0.1", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.deleteContextAlbum("MyMap012", "0.1.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createContextAlbum("MyMap012", "0.1.2", "ZOOBY", "false", "MapType", "0.0.1", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.validateContextAlbum(null, null); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModel.updateContextAlbum(null, null, null, null, null, null, null, null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + result = apexModel.updateContextAlbum("MyMap002", "0.0.2", null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateContextAlbum("MyMap002", "0.0.2", "ZOOBY", "true", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateContextAlbum("MyMap002", "0.0.2", null, null, null, null, + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateContextAlbum("MyMap012", null, null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateContextAlbum("MyMap012", null, null, "true", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateContextAlbum("MyMap015", null, null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updateContextAlbum("MyMap014", "0.1.5", null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", "StringType", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", "String", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", "StringType", "0.0.2", null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", "StringType", "0.0.1", null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "Hello", "StringType", "0.0.1", null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listContextAlbum("@£%%$", null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.listContextAlbum(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listContextAlbum("MyMap012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listContextAlbum("MyMap012", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listContextAlbum("MyMap012", "0.2.5"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listContextAlbum("MyMap014", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteContextAlbum("@£%%$", null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.deleteContextAlbum("MyMap012", "0.1.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteContextAlbum("MyMap012oooo", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listContextAlbum("MyMap012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 3); + + result = apexModel.deleteContextAlbum("MyMap012", "0.1.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listContextAlbum("MyMap012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 2); + + result = apexModel.deleteContextAlbum("MyMap012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listContextAlbum("MyMap012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteContextAlbum(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(4, result.getMessages().size()); + + result = apexModel.listContextAlbum(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(0, result.getMessages().size()); + } +} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java new file mode 100644 index 000000000..9f297203b --- /dev/null +++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java @@ -0,0 +1,153 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.model.modelapi; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Context schema for API tests. + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class ApexEditorApiContextSchemaTest { + @Test + public void testContextSchemaCrud() { + final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); + + ApexApiResult result = apexModel.validateContextSchemas(null, null); + assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); + + result = apexModel.validateContextSchemas("%%%$£", null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listContextSchemas(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createContextSchema("Hello", "0.0.2", "Java", "java.lang.String", + "1fa2e430-f2b2-11e6-bc64-92361f002671", "A description of hello"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createContextSchema("Hello", "0.1.2", "Java", "java.lang.String", + "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of hola"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createContextSchema("Hello", "0.1.4", "Java", "java.lang.String", + "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of connichi wa"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createContextSchema("Hello", null, "Java", "java.lang.String", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createContextSchema("Hello", null, "Java", "java.lang.String", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.deleteContextSchema("Hello", "0.1.4"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createContextSchema("Hello", "0.1.4", "Java", "java.lang.String", + "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of connichi wa"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createContextSchema("Hello2", null, null, "java.lang.String", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createContextSchema("Hello2", null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createContextSchema("Hello2", null, "Java", "java.lang.String", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createContextSchema("Hello", "0.1.2", "Java", "java.lang.Float", + "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of hola"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + + result = apexModel.deleteContextSchema("Hello", "0.1.4"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createContextSchema("Hello", "0.1.4", "Java", "java.lang.String", + "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of connichi wa"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.validateContextSchemas(null, null); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModel.updateContextSchema(null, null, null, null, null, null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.updateContextSchema("Hello", "0.0.2", null, null, null, "An updated description of hello"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateContextSchema("Hello", "0.0.2", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateContextSchema("Hello", "0.1.2", "Java", "java.lang.Integer", + "1fa2e430-f2b2-11e6-bc64-92361f002673", "A further updated description of hola"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.updateContextSchema("Hello2", "0.0.2", null, null, null, "An updated description of hello"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listContextSchemas("@£%%$", null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.listContextSchemas("Hello", "0.1.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 2); + + result = apexModel.listContextSchemas("Hello", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 4); + + result = apexModel.listContextSchemas(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 9); + + result = apexModel.deleteContextSchema("@£%%$", null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.deleteContextSchema("Hello", "0.1.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteContextSchema("Hellooooo", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listContextSchemas("Hello", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 4); + + result = apexModel.deleteContextSchema("Hello", "0.1.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listContextSchemas("Hello", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 3); + + result = apexModel.deleteContextSchema("Hello", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listContextSchemas("Hello", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listContextSchemas(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.deleteContextSchema(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(5, result.getMessages().size()); + + result = apexModel.listContextSchemas(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(0, result.getMessages().size()); + } +} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java new file mode 100644 index 000000000..6bb85a634 --- /dev/null +++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java @@ -0,0 +1,197 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.model.modelapi; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Test events for API tests. + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class ApexEditorApiEventTest { + @Test + public void testEventCrud() { + final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); + + ApexApiResult result = apexModel.validateEvent(null, null); + assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); + + result = apexModel.validateEvent("%%%$£", null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createEvent("MyEvent012", "0.1.2", "My Namespace", "My Source", "my target", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createEvent("MyEvent012", "0.1.4", "My Namespace", "My Source", "my target", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createEvent("@£$%^", "0.2.5", "My Namespace", "My Source", "my target", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.deleteEvent("MyEvent012", "0.1.4"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createEvent("MyEvent012", "0.1.4", "My Namespace", "My Source", "my target", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.validateEvent(null, null); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModel.updateContextSchema(null, null, null, null, null, null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + result = apexModel.updateEvent("MyEvent012", "0.1.2", "Another Namespace", null, "Another target", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateEvent("MyEvent012", null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateEvent("MyEvent015", null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updateEvent("MyEvent014", "0.1.5", null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updateEvent("@£$%^^", "0.6.9", null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.listEvent("@£$%", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listEvent(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listEvent("MyEvent012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listEvent("MyEvent012", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listEvent("MyEvent012", "0.2.5"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listEvent("MyEvent123", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteEvent("@£$%^", "0.1.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deleteEvent("MyEvent012", "0.1.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteEvent("MyEvent012oooo", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listEvent("MyEvent012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 3); + + result = apexModel.deleteEvent("MyEvent012", "0.1.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listEvent("MyEvent012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 2); + + result = apexModel.deleteEvent("MyEvent012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listEvent("MyEvent012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createEventPar("MyEvent123", null, "NewPar00", null, null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createEventPar("MyEvent002", "4.5.6", "NewPar00", null, null, true); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createEventPar("MyEvent002", "0.1.4", "NewPar00", null, null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar00", null, null, true); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar00", "eventContextItem0", null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar00", "eventContextItem0", null, true); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar01", "eventContextItem0", "0.0.1", false); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar02", "eventContextItem0", "0.0.2", true); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createEventPar("MyEvent002", null, "NewPar02", "eventContextItem0", null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createEventPar("MyEvent002", null, "NewPar03", "eventContextItem0", null, true); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listEventPar("@£%%$", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listEventPar("MyEvent002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listEventPar("MyEvent002", "0.0.1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listEventPar("MyEvent002", "0.0.2", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listEventPar("MyEvent002", "0.0.2", "NewPar01"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listEventPar("MyEvent002", "0.0.2", "NewPar02"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listEventPar("MyEvent002", "0.0.2", "NewPar04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteEventPar("@££%%%", "0.0.2", "NewPar04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deleteEventPar("NonExistantEvent", "0.0.2", "NewPar04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(4, apexModel.listEventPar("MyEvent002", null, null).getMessages().size()); + result = apexModel.deleteEventPar("MyEvent002", "0.0.2", "NewPar04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(4, apexModel.listEventPar("MyEvent002", null, null).getMessages().size()); + result = apexModel.deleteEventPar("MyEvent002", null, "NewPar02"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(3, apexModel.listEventPar("MyEvent002", null, null).getMessages().size()); + result = apexModel.deleteEventPar("MyEvent002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listEventPar("MyEvent002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deleteEventPar("MyEvent002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listEventPar("MyEvent002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteEvent(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(4, result.getMessages().size()); + + result = apexModel.listEvent(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(0, result.getMessages().size()); + } +} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java new file mode 100644 index 000000000..3635abbe0 --- /dev/null +++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java @@ -0,0 +1,137 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.model.modelapi; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Key information for API tests. + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class ApexEditorApiKeyInfoTest { + + @Test + public void testKeyInfoCrud() { + final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); + + ApexApiResult result = apexModel.validateKeyInformation(null, null); + assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); + + result = apexModel.validateKeyInformation("%%%$£", null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createKeyInformation(null, null, null, null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.createKeyInformation("Hello", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002671", + "A description of hello"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createKeyInformation("Hello", "0.1.2", "1fa2e430-f2b2-11e6-bc64-92361f002672", + "A description of hola"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createKeyInformation("Hello", "0.1.4", "1fa2e430-f2b2-11e6-bc64-92361f002672", + "A description of connichi wa"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createKeyInformation("Hello", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createKeyInformation("Hello", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + + result = apexModel.createKeyInformation("Hello", "0.1.2", "1fa2e430-f2b2-11e6-bc64-92361f002672", + "A description of hola"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + + result = apexModel.validateKeyInformation(null, null); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModel.updateKeyInformation(null, null, null, null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.updateKeyInformation("Hello", "0.0.2", null, "An updated description of hello"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateKeyInformation("Hello", "0.0.2", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateKeyInformation("Hello", "0.1.2", "1fa2e430-f2b2-11e6-bc64-92361f002673", + "A further updated description of hola"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.updateKeyInformation("Hello2", "0.0.2", null, "An updated description of hello"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listKeyInformation(null, null); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModel.listKeyInformation("%%%$$", null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.listKeyInformation("Hello", "0.1.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 2); + + result = apexModel.listKeyInformation("Hello", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 4); + + result = apexModel.deleteKeyInformation("Hello", "0.1.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteKeyInformation("Hellooooo", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listKeyInformation("Hello", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 4); + + result = apexModel.listKeyInformation(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 22); + + result = apexModel.deleteKeyInformation("%%%$$", null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.deleteKeyInformation("Hello", "0.1.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listKeyInformation("Hello", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 3); + + result = apexModel.deleteKeyInformation("Hello", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listKeyInformation("Hello", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteKeyInformation(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(18, result.getMessages().size()); + + result = apexModel.listKeyInformation(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(0, result.getMessages().size()); + } +} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java new file mode 100644 index 000000000..4c54b2062 --- /dev/null +++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java @@ -0,0 +1,1023 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.model.modelapi; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Test policies for API tests. + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class ApexEditorApiPolicyTest { + @Test + public void myTestPolicyCrud() { + final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); + + ApexApiResult result = apexModel.validatePolicy(null, null); + assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); + + result = apexModel.validatePolicy("%%%$£", null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createPolicy("MyPolicy002", "0.0.2", "SomeTemplate", "AState", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicy("MyPolicy002", "0.0.2", "SomeTemplate", "AState", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createPolicy("MyPolicy012", null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicy("MyPolicy012", null, "SomeTemplate", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicy("MyPolicy013", null, null, "AState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicy("MyPolicy012", null, "SomeTemplate", "AState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicy("MyPolicy002", "0.0.2", "SomeTemplate", "AState", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createPolicy("MyPolicy012", "0.1.2", "SomeTemplate", "AState", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicy("MyTestPolicy", "0.0.1", "SomeTemplate", "TestState", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.deletePolicy("MyPolicy002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicy("MyPolicy002", "0.0.2", "SomeTemplate", "AState", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.validatePolicy(null, null); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModel.updatePolicy("@£$$", "0.0.2", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.updatePolicy("MyPolicy002", "0.0.2", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicy("MyPolicy002", "0.0.1", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicy("MyPolicy002", "0.0.2", "SomeOtherTemplate", "BState", + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicy("MyPolicy012", null, "SomeOtherTemplate", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicy("MyPolicy012", null, null, "CState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicy("MyPolicy012", null, "SomeOtherTemplate", "BState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicy("MyPolicy015", null, "SomeOtherTemplate", "DState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicy("MyPolicy014", "0.1.5", "SomeOtherTemplate", "EState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listPolicy("@£$%%", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicy(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(6, result.getMessages().size()); + result = apexModel.listPolicy("MyPolicy012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, result.getMessages().size()); + result = apexModel.listPolicy("MyPolicy012", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicy("MyPolicy012", "0.2.5"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicy("MyPolicy014", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deletePolicy("@£$%", "0.1.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.deletePolicy("MyPolicy012", "0.1.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deletePolicy("MyPolicy012oooo", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listPolicy("MyPolicy012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 2); + + result = apexModel.deletePolicy("MyPolicy002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 1); + + result = apexModel.listPolicy("MyPolicy012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 2); + + result = apexModel.deletePolicy("MyPolicy012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 2); + + result = apexModel.createPolicyState(null, null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyState("MyPolicy123", null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyState("MyPolicy123", null, "AState", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyState("MyTestPolicy", "0.0.2", "AState", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyState("MyTestPolicy", null, "AState", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "ATrigger", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", "0.0.2", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", null, "ATask", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", null, "task", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", null, "task", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", null, "task", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "AState", "inEvent", "0.0.1", "task", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "BState", "inEvent", "0.0.1", "task", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "CState", "inEvent", "0.0.1", "task", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "DState", "inEvent", "0.0.1", "task", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.updatePolicyState(null, null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.updatePolicyState("MyPolicy123", null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.updatePolicyState("MyPolicy123", null, "AState", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyState("MyTestPolicy", "0.0.2", "AState", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyState("MyTestPolicy", null, "ZState", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "ATrigger", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", "0.0.2", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", "0.0.2", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", null, "ATask", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", null, "task", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", null, "task", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", null, "task", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyState("MyTestPolicy", "0.0.1", "AState", "inEvent", "0.0.1", "task", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyState("MyTestPolicy", "0.0.1", "BState", "inEvent", "0.0.1", "task", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyState("MyTestPolicy", "0.0.1", "CState", "inEvent", "0.0.1", "task", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyState("MyTestPolicy", "0.0.1", "DState", "inEvent", "0.0.1", "task", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listPolicyState("MyTestPolicy", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(4, result.getMessages().size()); + result = apexModel.listPolicyState(null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyState("SomeOtherPolicy", "0.0.1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyState("SomeOtherPolicy", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyState("MyTestPolicy", "0.0.2", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyState("MyTestPolicy", "0.0.1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(4, result.getMessages().size()); + result = apexModel.listPolicyState("MyTestPolicy", "0.0.1", "CState"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyState("MyTestPolicy", null, "CState"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyState("MyTestPolicy", "0.0.1", "AState"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyState("MyTestPolicy", "0.0.1", "EState"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deletePolicyState("@£$$", "0.0.2", "Trigger04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + assertEquals(4, apexModel.listPolicyState("MyTestPolicy", null, null).getMessages().size()); + result = apexModel.deletePolicyState("MyTestPolicy", "0.0.2", "Trigger04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(4, apexModel.listPolicyState("MyTestPolicy", null, null).getMessages().size()); + result = apexModel.deletePolicyState("MyTestPolicy", null, "CState"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deletePolicyState("MyTestPolicy", null, "ZState"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(3, apexModel.listPolicyState("MyTestPolicy", null, null).getMessages().size()); + result = apexModel.deletePolicyState("MyTestPolicy", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listPolicyState("MyTestPolicy", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyState("MyTestPolicy", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "TestState1", "inEvent", "0.0.1", "task", + "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "TestState2", "outEvent0", "0.0.1", "task", + "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "TestState3", "outEvent1", "0.0.1", "task", + "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createPolicyStateTaskSelectionLogic(null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, "SomeState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "1.2.3", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "NewTSL00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "UNDEFINED", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "MVEL", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + + result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "JAVA", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "JYTHON", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", "JAVASCRIPT", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", "JRUBY", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.updatePolicyStateTaskSelectionLogic(null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState99", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy2", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy1", "0.0.2", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "NonExistantState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "", + "Some Other Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "MVEL", + "Some Other Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyPolicy012", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", null, + "Some Other Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyPolicy015", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyPolicy014", "0.1.5", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listPolicyStateTaskSelectionLogic(null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateTaskSelectionLogic("zooby", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateTaskSelectionLogic("zooby", null, "looby"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskSelectionLogic("zooby", null, "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", null, "looby"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.2", "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + + result = apexModel.deletePolicyStateTaskSelectionLogic(null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateTaskSelectionLogic("zooby", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateTaskSelectionLogic("zooby", null, "looby"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateTaskSelectionLogic("zooby", null, "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", null, "looby"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.2", "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", null, + "Some Other Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", "JRUBY", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createPolicyStateOutput(null, null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", null, "SomeState", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", null, "SomeState", "SomeOutput", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "1.2.3", "TestState1", "SomeOutput", null, null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", null, null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", + "SomeDummyEvent", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", "inEvent", + "1.2.3", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", "inEvent", + "0.0.1", "SomeDummyNextState"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", "inEvent", + "0.0.1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent", + "0.0.1", "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent", + "0.0.1", "TestState2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent", + "0.0.1", "TestState2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "AnotherOtherOutput", + "outEvent0", "0.0.1", "TestState3"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "YetAnotherOtherOutput", + "outEvent0", "0.0.1", "TestState3"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listPolicyStateOutput(null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateOutput("MyTestPolicy", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.2", "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateOutput("MyTestPolicy", null, "SomeState", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, result.getMessages().size()); + result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, result.getMessages().size()); + result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "YetAnotherOtherOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "YetAnotherOtherOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState3", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deletePolicyStateOutput(null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateOutput("MyTestPolicy", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateOutput("MyTestPolicy", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateOutput("MyTestPolicy", "0.0.2", "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateOutput("MyTestPolicy", null, "SomeState", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateOutput("MyTestPolicy", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateOutput("MyTestPolicy", "0.0.1", "TestState3", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateOutput("MyTestPolicy", "0.0.1", "TestState3", "DummyOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateOutput("MyTestPolicy", null, "TestState1", null); + assertEquals(2, result.getMessages().size()); + result = apexModel.deletePolicyStateOutput("MyTestPolicy", null, "TestState1", "SomeOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyStateOutput("MyTestPolicy", null, "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.deletePolicyStateOutput("MyTestPolicy", null, "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyStateOutput("MyTestPolicy", null, "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateOutput("MyTestPolicy", null, "TestState2", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, result.getMessages().size()); + result = apexModel.deletePolicyStateOutput("MyTestPolicy", null, "TestState2", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, result.getMessages().size()); + result = apexModel.listPolicyStateOutput("MyTestPolicy", null, "TestState2", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", "inEvent", + "0.0.1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent", + "0.0.1", "TestState1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent", + "0.0.1", "TestState2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "AnotherOtherOutput", + "outEvent0", "0.0.1", "TestState3"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "YetAnotherOtherOutput", + "outEvent0", "0.0.1", "TestState3"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createPolicyStateFinalizerLogic(null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "SomeState", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "SomeState", "SFLName01", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "1.2.3", "TestState1", "SFLName01", null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName01", null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName01", + "NewTSL00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName02", + "UNDEFINED", "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName03", "MVEL", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName03", "MVEL", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName04", "JAVA", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName05", "JYTHON", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06", + "JAVASCRIPT", "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName07", "JRUBY", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.updatePolicyStateFinalizerLogic(null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, "TestState99", "SomeSFLName", null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy2", null, "TestState1", "SomeSFLName", null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy1", "0.0.2", "TestState1", "SomeSFLName", null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "NonEistantSFL", null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06", null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06", "", + "Some Other Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06", "MVEL", + "Some Other Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyStateFinalizerLogic("MyPolicy012", null, "TestState1", "SFLName06", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06", null, + "Some Other Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updatePolicyStateFinalizerLogic("MyPolicy015", null, "TestState1", "SFLName06", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updatePolicyStateFinalizerLogic("MyPolicy014", "0.1.5", "TestState1", "SFLName06", null, + null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listPolicyStateFinalizerLogic(null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", "0.0.2", "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "SomeState", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateFinalizerLogic("zooby", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateFinalizerLogic("zooby", null, "looby", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateFinalizerLogic("zooby", null, "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "looby", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", "0.0.2", "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(6, result.getMessages().size()); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + + result = apexModel.deletePolicyStateFinalizerLogic(null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.2", "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", null, "SomeState", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateFinalizerLogic("zooby", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateFinalizerLogic("zooby", null, "looby", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateFinalizerLogic("zooby", null, "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", null, "looby", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.2", "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(5, result.getMessages().size()); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName02"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName02"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName02"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(4, result.getMessages().size()); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(4, result.getMessages().size()); + result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName02", + "UNDEFINED", "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName03", "MVEL", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName04", "JAVA", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName05", "JYTHON", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06", + "JAVASCRIPT", "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName07", "JRUBY", + "Some Policy Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createTask("TestTask0", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTask("TestTask1", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTask("TestTask2", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTask("TestTask3", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTask("TestTask4", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createPolicyStateTaskRef(null, null, null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, null, null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "SomeState", null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "SomeState", null, null, null, null, + "DummyOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "1.2.3", "SomeState", null, null, null, null, + "DummyOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateTaskRef("AnyOldPolicy", "1.2.3", "SomeState", null, null, null, null, + "DummyOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", null, + null, null, "DummyOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", + "SomeTask", "Zooby|", null, "DummyOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", + "SomeTask", "0.0.1", null, "DummyOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", "task", + "0.0.1", null, "DummyOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", "task", + "0.0.1", "Some Policy Logic", "DummyOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", "task", + "0.0.1", "DIRECT", "DummyOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", "task", + "0.0.1", "LOGIC", "DummyOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", "task", + "0.0.1", "DIRECT", "SFLName07"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", "task", + "0.0.1", "LOGIC", "SomeOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", "task", + "0.0.1", "DIRECT", "SomeOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", + "NonExistantTask", "0.0.1", "DIRECT", "SomeOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", "task", + "0.0.1", "LOGIC", "SFLName07"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", + "TestTask0", "0.0.1", "LOGIC", "SFLName07"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", + "TestTask1", "0.0.1", "DIRECT", "SomeOtherOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", + "TestTask2", "0.0.1", "LOGIC", "SFLName07"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", + "TestTask3", "0.0.1", "DIRECT", "SomeOtherOutput"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, "TestTask4", "0.0.1", + "LOGIC", "SFLName07"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, "TestTask4", "0.0.1", + "LOGIC", "SFLName07"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "TestState1", "TestTask4", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", + "TestTask4", "0.0.1", "FUNKY", "SFLName07"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", + "TestTask4", "0.0.1", "UNDEFINED", "SFLName07"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", + "TestTask4", "0.0.1", "LOGIC", "SFLName07"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, "TestTask0", "0.0.1", + "LOGIC", "SFLName07"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + + result = apexModel.listPolicyStateTaskRef(null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", "0.0.1", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", "0.0.2", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "SomeState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", "0.0.1", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateTaskRef("zooby", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateTaskRef("zooby", null, "looby", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskRef("zooby", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "looby", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", "0.0.2", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(12, result.getMessages().size()); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeOldTask", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "task", "1.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "task", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, result.getMessages().size()); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "task", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, result.getMessages().size()); + + result = apexModel.deletePolicyStateTaskRef(null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.1", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.2", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "SomeState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.1", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateTaskRef("zooby", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateTaskRef("zooby", null, "looby", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateTaskRef("zooby", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "looby", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.2", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.2", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "ADummyTask", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "task", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(12, result.getMessages().size()); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "TestState1", "TestTask0", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(10, result.getMessages().size()); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "TestState1", "TestTask2", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(8, result.getMessages().size()); + result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(4, result.getMessages().size()); + result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createPolicyStateContextRef(null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", null, "SomeState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", null, "SomeState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "1.2.3", "SomeState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateContextRef("AnyOldPolicy", "1.2.3", "SomeState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTask", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTask", "Zooby|"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTask", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "task", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateContextRef("MyPolicy123", null, null, "AContextMap00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateContextRef("MyPolicy123", null, "TestState1", "AContextMap00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "4.5.6", "TestState1", "AContextMap00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.1.4", "TestState1", "AContextMap00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "AContextMap00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", ""); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", null, "TestState1", "contextAlbum0", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + + result = apexModel.listPolicyStateContextRef(null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.2", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, "SomeState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateContextRef("zooby", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateContextRef("zooby", null, "looby", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateContextRef("zooby", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, "looby", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.2", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, result.getMessages().size()); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.2", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, result.getMessages().size()); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "AContextMap04", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "1.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deletePolicyStateContextRef(null, null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.1", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.2", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "SomeState", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.1", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateContextRef("zooby", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateContextRef("zooby", null, "looby", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateContextRef("zooby", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "looby", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.2", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.2", "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "ADummyContextMap", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "AContextMap04", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "TestState1", "contextAlbum0", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "TestState1", "contextAlbum0", "0.1.5"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "TestState1", "contextAlbum1", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, "TestState1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deletePolicy(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(3, result.getMessages().size()); + + result = apexModel.listPolicy(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(0, result.getMessages().size()); + } +} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java new file mode 100644 index 000000000..050025537 --- /dev/null +++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java @@ -0,0 +1,485 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.model.modelapi; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Test tasks for API tests. + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class ApexEditorApiTaskTest { + @Test + public void testTaskCrud() { + final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); + + ApexApiResult result = apexModel.validateTask(null, null); + assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); + + result = apexModel.validateTask("%%%$£", null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.createTask("@^^$^^$", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", + "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", + "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", + "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createTask("MyTask012", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTask("MyTask012", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.listTask(null, null); + result = apexModel.createTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", + "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createTask("MyTask012", "0.1.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", + "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.deleteTask("MyTask002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", + "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.validateTask(null, null); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModel.updateTask("@$$$£", "0.0.2", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.updateTask("MyTask002", "0.0.2", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateTask("MyTask002", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updateTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", + "A description of 002"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateTask("MyTask012", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateTask("MyTask012", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateTask("MyTask012", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateTask("MyTask015", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updateTask("MyTask014", "0.1.5", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listTask("£@£@@£@£", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listTask(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTask("MyTask012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTask("MyTask012", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTask("MyTask012", "0.2.5"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listTask("MyTask014", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteTask("@£££@", "0.1.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deleteTask("MyTask012", "0.1.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deleteTask("MyTask012oooo", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listTask("MyTask012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 2); + + result = apexModel.deleteTask("MyTask012", "0.1.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listTask("MyTask012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertTrue(result.getMessages().size() == 1); + + result = apexModel.deleteTask("MyTask012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listTask("MyTask012", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.updateTaskLogic("MyTask002", null, "NewLogic00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskLogic("MyTask123", null, "NewLogic00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createTaskLogic("MyTask002", "4.5.6", "NewLogic00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createTaskLogic("MyTask002", "0.1.4", "NewLogic00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createTaskLogic("MyTask002", "0.0.2", "NewLogic00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createTaskLogic("MyTask002", "0.0.2", "UNDEFINED", "Some Task Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskLogic("MyTask002", "0.0.2", "MVEL", "Some Task Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskLogic("MyTask002", "0.0.2", "JAVA", "Some Task Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskLogic("MyTask002", "0.0.2", "JYTHON", "Some Task Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskLogic("MyTask002", null, "JAVASCRIPT", "Some Task Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskLogic("MyTask002", null, "JRUBY", "Some Task Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.updateTaskLogic("MyTask002", "0.0.2", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateTaskLogic("MyTask002", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updateTaskLogic("MyTask002", "0.0.2", "", "Some Other Task Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.updateTaskLogic("MyTask002", "0.0.2", "MVEL", "Some Other Task Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateTaskLogic("MyTask012", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updateTaskLogic("MyTask002", null, null, "Some Other Task Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateTaskLogic("MyTask002", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.updateTaskLogic("MyTask015", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.updateTaskLogic("MyTask014", "0.1.5", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.listTaskLogic("MyTask002", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskLogic("MyTask002", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listTaskLogic("MyTask002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskLogic("MyTask002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskLogic("MyTask002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskLogic(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.deleteTaskLogic("@£@£@£", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deleteTaskLogic("NonExistantTask", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + assertEquals(1, apexModel.listTaskLogic("MyTask002", null).getMessages().size()); + result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskLogic("MyTask002", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(1, apexModel.listTaskLogic("MyTask002", null).getMessages().size()); + result = apexModel.createTaskLogic("MyTask002", null, "JRUBY", "Some Task Logic"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskLogic("MyTask002", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskInputField("MyTask123", null, "NewField00", null, null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskInputField("MyTask002", "4.5.6", "NewField00", null, null, true); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskInputField("MyTask002", "0.1.4", "NewField00", null, null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField00", null, null, true); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, true); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField01", "eventContextItem0", "0.0.1", + false); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField02", "eventContextItem0", "0.0.2", true); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createTaskInputField("MyTask002", null, "NewField02", "eventContextItem0", null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskInputField("MyTask002", null, "NewField03", "eventContextItem0", null, true); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listTaskInputField("@£$%", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listTaskInputField("MyTask002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskInputField("MyTask002", "0.0.1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listTaskInputField("MyTask002", "0.0.2", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskInputField("MyTask002", "0.0.2", "NewField01"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskInputField("MyTask002", "0.0.2", "NewField02"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskInputField("MyTask002", "0.0.2", "NewField04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteTaskInputField("@£$%", "0.0.2", "NewField04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deleteTaskInputField("NonExistantTask", "0.0.2", "NewField04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(4, apexModel.listTaskInputField("MyTask002", null, null).getMessages().size()); + result = apexModel.deleteTaskInputField("MyTask002", "0.0.2", "NewField04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(4, apexModel.listTaskInputField("MyTask002", null, null).getMessages().size()); + result = apexModel.deleteTaskInputField("MyTask002", null, "NewField02"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(3, apexModel.listTaskInputField("MyTask002", null, null).getMessages().size()); + result = apexModel.deleteTaskInputField("MyTask002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskInputField("MyTask002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deleteTaskInputField("MyTask002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskOutputField("MyTask123", null, "NewField00", null, null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskOutputField("MyTask002", "4.5.6", "NewField00", null, null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskOutputField("MyTask002", "0.1.4", "NewField00", null, null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField00", null, null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField01", "eventContextItem0", "0.0.1", + false); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField02", "eventContextItem0", "0.0.2", + false); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createTaskOutputField("MyTask002", null, "NewField02", "eventContextItem0", null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskOutputField("MyTask002", null, "NewField03", "eventContextItem0", null, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.listTaskOutputField("@£$%", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listTaskOutputField("MyTask002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskOutputField("MyTask002", "0.0.1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listTaskOutputField("MyTask002", "0.0.2", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskOutputField("MyTask002", "0.0.2", "NewField01"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskOutputField("MyTask002", "0.0.2", "NewField02"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskOutputField("MyTask002", "0.0.2", "NewField04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteTaskOutputField("@£$%", "0.0.2", "NewField04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deleteTaskOutputField("NonExistantTask", "0.0.2", "NewField04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(4, apexModel.listTaskOutputField("MyTask002", null, null).getMessages().size()); + result = apexModel.deleteTaskOutputField("MyTask002", "0.0.2", "NewField04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(4, apexModel.listTaskOutputField("MyTask002", null, null).getMessages().size()); + result = apexModel.deleteTaskOutputField("MyTask002", null, "NewField02"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(3, apexModel.listTaskOutputField("MyTask002", null, null).getMessages().size()); + result = apexModel.deleteTaskOutputField("MyTask002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskOutputField("MyTask002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deleteTaskOutputField("MyTask002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskParameter("MyTask123", null, "NewPar00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskParameter("MyTask002", "4.5.6", "NewPar00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskParameter("MyTask002", "0.1.4", "NewPar00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar00", "eventContextItem0"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar00", "eventContextItem0"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar01", "eventContextItem0"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar02", "eventContextItem0"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar02", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar03", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createTaskParameter("MyTask002", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createTaskParameter("MyTask002", null, null, "Default value"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.listTaskParameter("@£$%", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listTaskParameter("MyTask002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskParameter("MyTask002", "0.0.3", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listTaskParameter("MyTask002", "0.0.2", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskParameter("MyTask002", "0.0.2", "NewPar01"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskParameter("MyTask002", "0.0.2", "NewPar02"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskParameter("MyTask002", "0.0.2", "NewPar04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteTaskParameter("@£$%", "0.0.2", "NewPar04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deleteTaskParameter("NonExistantTask", "0.0.2", "NewPar04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(3, apexModel.listTaskParameter("MyTask002", null, null).getMessages().size()); + result = apexModel.deleteTaskParameter("MyTask002", "0.0.2", "NewPar04"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(3, apexModel.listTaskParameter("MyTask002", null, null).getMessages().size()); + result = apexModel.deleteTaskParameter("MyTask002", null, "NewPar02"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, apexModel.listTaskParameter("MyTask002", null, null).getMessages().size()); + result = apexModel.deleteTaskParameter("MyTask002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.listTaskParameter("MyTask002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deleteTaskParameter("MyTask002", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskContextRef("@£$$", null, "AContextMap00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.createTaskContextRef("MyTask123", null, "AContextMap00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createTaskContextRef("MyTask123", null, "AContextMap00", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createTaskContextRef("MyTask123", null, "AContextMap00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createTaskContextRef("MyTask002", "4.5.6", "AContextMap00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createTaskContextRef("MyTask002", "0.1.4", "AContextMap00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "AContextMap00", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "contextAlbum2", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "contextAlbum1", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + result = apexModel.createTaskContextRef("MyTask002", null, "contextAlbum0", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); + + result = apexModel.listTaskContextRef("@£$%", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.listTaskContextRef("MyTask002", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, result.getMessages().size()); + result = apexModel.listTaskContextRef("MyTask002", "0.0.1", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listTaskContextRef("MyTask002", "0.0.2", null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, result.getMessages().size()); + result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "AContextMap04", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "contextAlbum1", "0.0.1"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "contextAlbum1", "0.0.2"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteTaskContextRef("@£$%", "0.0.2", "AContextMap04", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + result = apexModel.deleteTaskContextRef("NonExistantTask", "0.0.2", "AContextMap04", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + assertEquals(2, apexModel.listTaskContextRef("MyTask002", null, null, null).getMessages().size()); + result = apexModel.deleteTaskContextRef("MyTask002", "0.0.2", "AContextMap04", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deleteTaskContextRef("MyTask002", null, "contextAlbum0", "0.0.3"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deleteTaskContextRef("MyTask002", null, "contextAlbum0", "0.1.5"); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + result = apexModel.deleteTaskContextRef("MyTask002", null, "contextAlbum0", null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.deleteTaskContextRef("MyTask002", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(1, result.getMessages().size()); + result = apexModel.listTaskContextRef("MyTask002", null, null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); + + result = apexModel.deleteTask(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(2, result.getMessages().size()); + + result = apexModel.listTask(null, null); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + assertEquals(0, result.getMessages().size()); + } +} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java new file mode 100644 index 000000000..462b1cd8b --- /dev/null +++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java @@ -0,0 +1,259 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.model.modelapi; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.util.UUID; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.apex.model.basicmodel.dao.DaoParameters; +import org.onap.policy.apex.model.modelapi.impl.ApexModelImpl; +import org.onap.policy.apex.model.utilities.TextFileUtils; + +/** + * Test the apex model API. + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class ApexModelApiTest { + private Connection connection; + + @Before + public void setup() throws Exception { + Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); + connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true"); + } + + @After + public void teardown() throws Exception { + connection.close(); + new File("derby.log").delete(); + } + + @Test + public void testApexModelLoadFromFile() { + final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); + + ApexApiResult result = apexModel.loadFromFile("src/main/resources/models/PolicyModel.json"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.deleteModel(); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.xml"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.deleteModel(); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.junk"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + assertTrue(result.getMessages().get(0).equals("format of input for Apex concept is neither JSON nor XML")); + } + + @Test + public void testApexModelSaveToFile() throws IOException { + final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); + + ApexApiResult result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + final File tempJsonModelFile = File.createTempFile("ApexModelTest", ".json"); + result = apexModel.saveToFile(tempJsonModelFile.getCanonicalPath(), false); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + final ApexModel jsonApexModel = new ApexModelFactory().createApexModel(null, false); + result = jsonApexModel.loadFromFile(tempJsonModelFile.getCanonicalPath()); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + tempJsonModelFile.delete(); + + final File tempXmlModelFile = File.createTempFile("ApexModelTest", ".xml"); + result = apexModel.saveToFile(tempXmlModelFile.getCanonicalPath(), true); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + final ApexModel xmlApexModel = new ApexModelFactory().createApexModel(null, false); + result = xmlApexModel.loadFromFile(tempXmlModelFile.getCanonicalPath()); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + tempXmlModelFile.delete(); + } + + @Test + public void testApexModelDatabase() throws IOException { + final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); + + ApexApiResult result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + final DaoParameters DaoParameters = new DaoParameters(); + DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); + DaoParameters.setPersistenceUnit("DAOTest"); + + result = apexModel.saveToDatabase(DaoParameters); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.deleteModel(); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.loadFromDatabase("PolicyModel", "0.0.1", DaoParameters); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.deleteModel(); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.loadFromDatabase("PolicyModel", null, DaoParameters); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.deleteModel(); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.loadFromDatabase("VPNPolicyModel", "0.0.1", DaoParameters); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + } + + @Test + public void testApexModelUrl() throws IOException { + ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); + + ApexApiResult result = null; + + try { + result = apexModel.readFromUrl(null); + fail("expecting an IllegalArgumentException"); + } catch (final Exception e) { + assertTrue(e instanceof IllegalArgumentException); + } + + try { + result = apexModel.writeToUrl(null, true); + fail("expecting an IllegalArgumentException"); + } catch (final Exception e) { + assertTrue(e instanceof IllegalArgumentException); + } + + result = apexModel.readFromUrl("zooby/looby"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.writeToUrl("zooby/looby", true); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.readFromUrl("zooby://zooby/looby"); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + result = apexModel.writeToUrl("zooby://zooby/looby", false); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + + apexModel = new ApexModelFactory().createApexModel(null, false); + + final File tempJsonModelFile = File.createTempFile("ApexModelTest", ".json"); + result = apexModel.saveToFile(tempJsonModelFile.getCanonicalPath(), false); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + final String tempFileUrlString = tempJsonModelFile.toURI().toString(); + result = apexModel.readFromUrl(tempFileUrlString); + assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); + + result = apexModel.writeToUrl(tempFileUrlString, false); + assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); + assertTrue(result.getMessages().get(0).equals("protocol doesn't support output")); + + tempJsonModelFile.delete(); + } + + @Test + public void testApexModelMisc() throws IOException { + final ApexModelImpl apexModelImpl = (ApexModelImpl) new ApexModelFactory().createApexModel(null, false); + + ApexApiResult result = null; + + result = apexModelImpl.getModelKey(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.listModel(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.createModel("ModelName", "0.0.1", null, null); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.updateModel("ModelName", "0.0.1", UUID.randomUUID().toString(), "Model Description"); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + apexModelImpl.deleteModel(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + final String modelString = TextFileUtils.getTextFileAsString("src/test/resources/models/PolicyModel.json"); + result = apexModelImpl.loadFromString(modelString); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + final File tempFile = File.createTempFile("ApexModel", "json"); + tempFile.deleteOnExit(); + TextFileUtils.putStringAsFile(modelString, tempFile); + + apexModelImpl.deleteModel(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.loadFromFile(tempFile.getCanonicalPath()); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.saveToFile(null, false); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.analyse(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.validate(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.compare(tempFile.getCanonicalPath(), true, true); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.compareWithString(modelString, true, true); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.split("policy"); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.split(tempFile.getCanonicalPath(), "policy"); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.merge(tempFile.getCanonicalPath(), true); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModelImpl.mergeWithString(modelString, true); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + assertNotEquals(0, apexModelImpl.hashCode()); + assertNotNull(apexModelImpl.clone()); + assertNotNull(apexModelImpl.build()); + } +} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java new file mode 100644 index 000000000..d5b845658 --- /dev/null +++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.model.modelapi; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.util.Properties; +import java.util.UUID; + +import org.junit.Test; +import org.onap.policy.apex.model.modelapi.impl.ModelFacade; + +public class ModelFacadeTest { + + @Test + public void testModelFacade() { + try { + new ModelFacade(null, null, false); + fail("test should throw an exception here"); + } catch (final Exception e) { + assertEquals("apexModel may not be null", e.getMessage()); + } + + final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); + + try { + new ModelFacade(apexModel, null, false); + fail("test should throw an exception here"); + } catch (final Exception e) { + assertEquals("apexProperties may not be null", e.getMessage()); + } + + final Properties modelProperties = new Properties(); + final ModelFacade mf = new ModelFacade(apexModel, modelProperties, false); + + ApexApiResult result = mf.createModel(null, null, null, null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mf.createModel("ModelName", null, null, null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mf.createModel("ModelName", "0.0.1", null, null); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + modelProperties.setProperty("DEFAULT_CONCEPT_VERSION", ""); + result = mf.createModel("ModelName", null, null, null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + modelProperties.setProperty("DEFAULT_CONCEPT_VERSION", "£$£$£$"); + result = mf.createModel("ModelName", null, null, null); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + modelProperties.setProperty("DEFAULT_CONCEPT_VERSION", "0.0.1"); + result = mf.createModel("ModelName", null, null, null); + assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult()); + result = mf.deleteModel(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + result = mf.createModel("ModelName", null, null, null); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = mf.updateModel("ModelName", null, UUID.randomUUID().toString(), "New Description"); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = mf.updateModel("ModelName", "0.0.1", UUID.randomUUID().toString(), "New Description"); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + modelProperties.remove("DEFAULT_CONCEPT_VERSION"); + result = mf.updateModel("ModelName", null, UUID.randomUUID().toString(), "New Description"); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mf.updateModel(null, null, UUID.randomUUID().toString(), "New Description"); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mf.deleteModel(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + result = mf.updateModel("name", "0.0.1", UUID.randomUUID().toString(), "New Description"); + assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); + + result = mf.getModelKey(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = mf.listModel(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + assertEquals("AxPolicyModel:(AxPolicyModel:(key=AxArtifactKey:(n", result.getMessage().substring(0, 50)); + + result = mf.deleteModel(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + assertNotNull(mf); + } +} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java new file mode 100644 index 000000000..9bbba1d99 --- /dev/null +++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java @@ -0,0 +1,148 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.model.modelapi; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.IOException; +import java.util.Properties; + +import org.junit.Test; +import org.onap.policy.apex.model.basicmodel.dao.DaoParameters; +import org.onap.policy.apex.model.modelapi.impl.ModelHandlerFacade; +import org.onap.policy.apex.model.utilities.TextFileUtils; + +/** + * Test the model handler facade. + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class ModelHandlerFacadeTest { + + @Test + public void testModelHandlerFacade() throws IOException { + try { + new ModelHandlerFacade(null, null, false); + fail("test should throw an exception here"); + } catch (final Exception e) { + assertEquals("apexModel may not be null", e.getMessage()); + } + + final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); + + try { + new ModelHandlerFacade(apexModel, null, false); + fail("test should throw an exception here"); + } catch (final Exception e) { + assertEquals("apexProperties may not be null", e.getMessage()); + } + + final Properties modelProperties = new Properties(); + final ModelHandlerFacade mhf = new ModelHandlerFacade(apexModel, modelProperties, false); + assertNotNull(mhf); + + ApexApiResult result = mhf.loadFromFile("src/test/resources/models/PolicyModel.json"); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = mhf.loadFromFile("src/test/resources/models/PolicyModel.json"); + assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult()); + + final String modelString = TextFileUtils.getTextFileAsString("src/test/resources/models/PolicyModel.json"); + + result = apexModel.deleteModel(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = mhf.loadFromString(modelString); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = mhf.loadFromString(modelString); + assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult()); + + final DaoParameters DaoParameters = new DaoParameters(); + result = mhf.loadFromDatabase("SomeModel", null, DaoParameters); + assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult()); + + result = apexModel.deleteModel(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = mhf.loadFromDatabase("SomeModel", null, DaoParameters); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mhf.saveToDatabase(DaoParameters); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mhf.readFromUrl("blah://somewhere/over/the/rainbow"); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mhf.loadFromString(modelString); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = mhf.readFromUrl("http://somewhere/over/the/rainbow"); + assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult()); + + final File tempFile = File.createTempFile("ApexModel", "json"); + tempFile.deleteOnExit(); + + result = mhf.writeToUrl("File:///" + tempFile.getCanonicalPath(), false); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mhf.validate(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = apexModel.deleteModel(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + result = mhf.validate(); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mhf.compare("src/test/resources/models/NonExistant.json", true, true); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mhf.compareWithString("zooby", true, true); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mhf.split("FailSplit", "NonExistantPolicy"); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mhf.split("NonExistantPolicy"); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mhf.merge("src/test/resources/models/NonExistant.json", false); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.deleteModel(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + result = mhf.merge("src/test/resources/models/PolicyModel.json", false); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = mhf.loadFromFile("src/test/resources/models/PolicyModel.json"); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + + result = mhf.mergeWithString("@£@$@£", true); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + + result = apexModel.deleteModel(); + assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); + result = mhf.mergeWithString(modelString, false); + assertEquals(ApexApiResult.Result.FAILED, result.getResult()); + } +} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiContextAlbum.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiContextAlbum.java deleted file mode 100644 index f1b8fc84b..000000000 --- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiContextAlbum.java +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.modelapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Context album for API tests. - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class TestApexEditorApiContextAlbum { - @Test - public void testContextAlbumCrud() { - final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - - ApexApiResult result = apexModel.validateContextAlbum(null, null); - assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); - - result = apexModel.validateContextAlbum("%%%$£", null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createContextAlbum("MyMap002", "0.0.2", "APPLICATION", "true", "MapType", "0.0.1", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createContextAlbum("MyMap012", "0.1.2", "ZOOBY", "false", "MapType", "0.0.1", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createContextAlbum("MyMap012", "0.1.4", "UNDEFINED", null, "MapType", "0.0.1", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createContextAlbum("MyMap012", null, null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "+++", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapZooby", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", "--++", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", "0.0.2", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createContextAlbum("MyMap002", "0.0.2", "APPLICATION", "true", "MapType", null, - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createContextAlbum("MyMap011", "0.1.2", "APPLICATION", "true", "MapType", "0.0.1", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.deleteContextAlbum("MyMap012", "0.1.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createContextAlbum("MyMap012", "0.1.2", "ZOOBY", "false", "MapType", "0.0.1", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.validateContextAlbum(null, null); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModel.updateContextAlbum(null, null, null, null, null, null, null, null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - result = apexModel.updateContextAlbum("MyMap002", "0.0.2", null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateContextAlbum("MyMap002", "0.0.2", "ZOOBY", "true", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateContextAlbum("MyMap002", "0.0.2", null, null, null, null, - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateContextAlbum("MyMap012", null, null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateContextAlbum("MyMap012", null, null, "true", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateContextAlbum("MyMap015", null, null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updateContextAlbum("MyMap014", "0.1.5", null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", "StringType", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", "String", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", "StringType", "0.0.2", null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", "StringType", "0.0.1", null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "Hello", "StringType", "0.0.1", null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listContextAlbum("@£%%$", null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.listContextAlbum(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listContextAlbum("MyMap012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listContextAlbum("MyMap012", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listContextAlbum("MyMap012", "0.2.5"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listContextAlbum("MyMap014", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteContextAlbum("@£%%$", null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.deleteContextAlbum("MyMap012", "0.1.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteContextAlbum("MyMap012oooo", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listContextAlbum("MyMap012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 3); - - result = apexModel.deleteContextAlbum("MyMap012", "0.1.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listContextAlbum("MyMap012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 2); - - result = apexModel.deleteContextAlbum("MyMap012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listContextAlbum("MyMap012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteContextAlbum(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(4, result.getMessages().size()); - - result = apexModel.listContextAlbum(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(0, result.getMessages().size()); - } -} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiContextSchema.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiContextSchema.java deleted file mode 100644 index 25ab6df6b..000000000 --- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiContextSchema.java +++ /dev/null @@ -1,153 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.modelapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Context schema for API tests. - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class TestApexEditorApiContextSchema { - @Test - public void testContextSchemaCrud() { - final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - - ApexApiResult result = apexModel.validateContextSchemas(null, null); - assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); - - result = apexModel.validateContextSchemas("%%%$£", null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listContextSchemas(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createContextSchema("Hello", "0.0.2", "Java", "java.lang.String", - "1fa2e430-f2b2-11e6-bc64-92361f002671", "A description of hello"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createContextSchema("Hello", "0.1.2", "Java", "java.lang.String", - "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of hola"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createContextSchema("Hello", "0.1.4", "Java", "java.lang.String", - "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of connichi wa"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createContextSchema("Hello", null, "Java", "java.lang.String", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createContextSchema("Hello", null, "Java", "java.lang.String", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.deleteContextSchema("Hello", "0.1.4"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createContextSchema("Hello", "0.1.4", "Java", "java.lang.String", - "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of connichi wa"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createContextSchema("Hello2", null, null, "java.lang.String", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createContextSchema("Hello2", null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createContextSchema("Hello2", null, "Java", "java.lang.String", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createContextSchema("Hello", "0.1.2", "Java", "java.lang.Float", - "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of hola"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - - result = apexModel.deleteContextSchema("Hello", "0.1.4"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createContextSchema("Hello", "0.1.4", "Java", "java.lang.String", - "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of connichi wa"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.validateContextSchemas(null, null); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModel.updateContextSchema(null, null, null, null, null, null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.updateContextSchema("Hello", "0.0.2", null, null, null, "An updated description of hello"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateContextSchema("Hello", "0.0.2", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateContextSchema("Hello", "0.1.2", "Java", "java.lang.Integer", - "1fa2e430-f2b2-11e6-bc64-92361f002673", "A further updated description of hola"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.updateContextSchema("Hello2", "0.0.2", null, null, null, "An updated description of hello"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listContextSchemas("@£%%$", null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.listContextSchemas("Hello", "0.1.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 2); - - result = apexModel.listContextSchemas("Hello", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 4); - - result = apexModel.listContextSchemas(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 9); - - result = apexModel.deleteContextSchema("@£%%$", null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.deleteContextSchema("Hello", "0.1.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteContextSchema("Hellooooo", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listContextSchemas("Hello", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 4); - - result = apexModel.deleteContextSchema("Hello", "0.1.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listContextSchemas("Hello", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 3); - - result = apexModel.deleteContextSchema("Hello", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listContextSchemas("Hello", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listContextSchemas(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.deleteContextSchema(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(5, result.getMessages().size()); - - result = apexModel.listContextSchemas(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(0, result.getMessages().size()); - } -} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiEvent.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiEvent.java deleted file mode 100644 index b25c52c9c..000000000 --- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiEvent.java +++ /dev/null @@ -1,197 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.modelapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Test events for API tests. - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class TestApexEditorApiEvent { - @Test - public void testEventCrud() { - final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - - ApexApiResult result = apexModel.validateEvent(null, null); - assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); - - result = apexModel.validateEvent("%%%$£", null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createEvent("MyEvent012", "0.1.2", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createEvent("MyEvent012", "0.1.4", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createEvent("@£$%^", "0.2.5", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.deleteEvent("MyEvent012", "0.1.4"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createEvent("MyEvent012", "0.1.4", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.validateEvent(null, null); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModel.updateContextSchema(null, null, null, null, null, null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - result = apexModel.updateEvent("MyEvent012", "0.1.2", "Another Namespace", null, "Another target", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateEvent("MyEvent012", null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateEvent("MyEvent015", null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updateEvent("MyEvent014", "0.1.5", null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updateEvent("@£$%^^", "0.6.9", null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.listEvent("@£$%", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listEvent(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listEvent("MyEvent012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listEvent("MyEvent012", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listEvent("MyEvent012", "0.2.5"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listEvent("MyEvent123", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteEvent("@£$%^", "0.1.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deleteEvent("MyEvent012", "0.1.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteEvent("MyEvent012oooo", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listEvent("MyEvent012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 3); - - result = apexModel.deleteEvent("MyEvent012", "0.1.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listEvent("MyEvent012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 2); - - result = apexModel.deleteEvent("MyEvent012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listEvent("MyEvent012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createEventPar("MyEvent123", null, "NewPar00", null, null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createEventPar("MyEvent002", "4.5.6", "NewPar00", null, null, true); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createEventPar("MyEvent002", "0.1.4", "NewPar00", null, null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar00", null, null, true); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar00", "eventContextItem0", null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar00", "eventContextItem0", null, true); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar01", "eventContextItem0", "0.0.1", false); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar02", "eventContextItem0", "0.0.2", true); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createEventPar("MyEvent002", null, "NewPar02", "eventContextItem0", null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createEventPar("MyEvent002", null, "NewPar03", "eventContextItem0", null, true); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listEventPar("@£%%$", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listEventPar("MyEvent002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listEventPar("MyEvent002", "0.0.1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listEventPar("MyEvent002", "0.0.2", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listEventPar("MyEvent002", "0.0.2", "NewPar01"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listEventPar("MyEvent002", "0.0.2", "NewPar02"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listEventPar("MyEvent002", "0.0.2", "NewPar04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteEventPar("@££%%%", "0.0.2", "NewPar04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deleteEventPar("NonExistantEvent", "0.0.2", "NewPar04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(4, apexModel.listEventPar("MyEvent002", null, null).getMessages().size()); - result = apexModel.deleteEventPar("MyEvent002", "0.0.2", "NewPar04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(4, apexModel.listEventPar("MyEvent002", null, null).getMessages().size()); - result = apexModel.deleteEventPar("MyEvent002", null, "NewPar02"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(3, apexModel.listEventPar("MyEvent002", null, null).getMessages().size()); - result = apexModel.deleteEventPar("MyEvent002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listEventPar("MyEvent002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deleteEventPar("MyEvent002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listEventPar("MyEvent002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteEvent(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(4, result.getMessages().size()); - - result = apexModel.listEvent(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(0, result.getMessages().size()); - } -} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiKeyInfo.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiKeyInfo.java deleted file mode 100644 index 9dae13272..000000000 --- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiKeyInfo.java +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.modelapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Key information for API tests. - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class TestApexEditorApiKeyInfo { - - @Test - public void testKeyInfoCrud() { - final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - - ApexApiResult result = apexModel.validateKeyInformation(null, null); - assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); - - result = apexModel.validateKeyInformation("%%%$£", null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createKeyInformation(null, null, null, null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.createKeyInformation("Hello", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002671", - "A description of hello"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createKeyInformation("Hello", "0.1.2", "1fa2e430-f2b2-11e6-bc64-92361f002672", - "A description of hola"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createKeyInformation("Hello", "0.1.4", "1fa2e430-f2b2-11e6-bc64-92361f002672", - "A description of connichi wa"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createKeyInformation("Hello", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createKeyInformation("Hello", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - - result = apexModel.createKeyInformation("Hello", "0.1.2", "1fa2e430-f2b2-11e6-bc64-92361f002672", - "A description of hola"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - - result = apexModel.validateKeyInformation(null, null); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModel.updateKeyInformation(null, null, null, null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.updateKeyInformation("Hello", "0.0.2", null, "An updated description of hello"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateKeyInformation("Hello", "0.0.2", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateKeyInformation("Hello", "0.1.2", "1fa2e430-f2b2-11e6-bc64-92361f002673", - "A further updated description of hola"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.updateKeyInformation("Hello2", "0.0.2", null, "An updated description of hello"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listKeyInformation(null, null); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModel.listKeyInformation("%%%$$", null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.listKeyInformation("Hello", "0.1.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 2); - - result = apexModel.listKeyInformation("Hello", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 4); - - result = apexModel.deleteKeyInformation("Hello", "0.1.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteKeyInformation("Hellooooo", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listKeyInformation("Hello", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 4); - - result = apexModel.listKeyInformation(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 22); - - result = apexModel.deleteKeyInformation("%%%$$", null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.deleteKeyInformation("Hello", "0.1.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listKeyInformation("Hello", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 3); - - result = apexModel.deleteKeyInformation("Hello", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listKeyInformation("Hello", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteKeyInformation(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(18, result.getMessages().size()); - - result = apexModel.listKeyInformation(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(0, result.getMessages().size()); - } -} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiPolicy.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiPolicy.java deleted file mode 100644 index 9295ffa5f..000000000 --- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiPolicy.java +++ /dev/null @@ -1,1023 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.modelapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Test policies for API tests. - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class TestApexEditorApiPolicy { - @Test - public void myTestPolicyCrud() { - final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - - ApexApiResult result = apexModel.validatePolicy(null, null); - assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); - - result = apexModel.validatePolicy("%%%$£", null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createPolicy("MyPolicy002", "0.0.2", "SomeTemplate", "AState", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicy("MyPolicy002", "0.0.2", "SomeTemplate", "AState", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createPolicy("MyPolicy012", null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicy("MyPolicy012", null, "SomeTemplate", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicy("MyPolicy013", null, null, "AState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicy("MyPolicy012", null, "SomeTemplate", "AState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicy("MyPolicy002", "0.0.2", "SomeTemplate", "AState", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createPolicy("MyPolicy012", "0.1.2", "SomeTemplate", "AState", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicy("MyTestPolicy", "0.0.1", "SomeTemplate", "TestState", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.deletePolicy("MyPolicy002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicy("MyPolicy002", "0.0.2", "SomeTemplate", "AState", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.validatePolicy(null, null); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModel.updatePolicy("@£$$", "0.0.2", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.updatePolicy("MyPolicy002", "0.0.2", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicy("MyPolicy002", "0.0.1", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicy("MyPolicy002", "0.0.2", "SomeOtherTemplate", "BState", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicy("MyPolicy012", null, "SomeOtherTemplate", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicy("MyPolicy012", null, null, "CState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicy("MyPolicy012", null, "SomeOtherTemplate", "BState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicy("MyPolicy015", null, "SomeOtherTemplate", "DState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicy("MyPolicy014", "0.1.5", "SomeOtherTemplate", "EState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listPolicy("@£$%%", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicy(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(6, result.getMessages().size()); - result = apexModel.listPolicy("MyPolicy012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, result.getMessages().size()); - result = apexModel.listPolicy("MyPolicy012", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicy("MyPolicy012", "0.2.5"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicy("MyPolicy014", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deletePolicy("@£$%", "0.1.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.deletePolicy("MyPolicy012", "0.1.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deletePolicy("MyPolicy012oooo", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listPolicy("MyPolicy012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 2); - - result = apexModel.deletePolicy("MyPolicy002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 1); - - result = apexModel.listPolicy("MyPolicy012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 2); - - result = apexModel.deletePolicy("MyPolicy012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 2); - - result = apexModel.createPolicyState(null, null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyState("MyPolicy123", null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyState("MyPolicy123", null, "AState", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyState("MyTestPolicy", "0.0.2", "AState", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyState("MyTestPolicy", null, "AState", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "ATrigger", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", "0.0.2", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", null, "ATask", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", null, "task", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", null, "task", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyState("MyTestPolicy", null, "AState", "inEvent", null, "task", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "AState", "inEvent", "0.0.1", "task", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "BState", "inEvent", "0.0.1", "task", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "CState", "inEvent", "0.0.1", "task", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "DState", "inEvent", "0.0.1", "task", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.updatePolicyState(null, null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.updatePolicyState("MyPolicy123", null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.updatePolicyState("MyPolicy123", null, "AState", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyState("MyTestPolicy", "0.0.2", "AState", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyState("MyTestPolicy", null, "ZState", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "ATrigger", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", "0.0.2", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", "0.0.2", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", null, "ATask", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", null, "task", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", null, "task", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyState("MyTestPolicy", null, "AState", "inEvent", null, "task", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyState("MyTestPolicy", "0.0.1", "AState", "inEvent", "0.0.1", "task", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyState("MyTestPolicy", "0.0.1", "BState", "inEvent", "0.0.1", "task", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyState("MyTestPolicy", "0.0.1", "CState", "inEvent", "0.0.1", "task", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyState("MyTestPolicy", "0.0.1", "DState", "inEvent", "0.0.1", "task", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listPolicyState("MyTestPolicy", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(4, result.getMessages().size()); - result = apexModel.listPolicyState(null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyState("SomeOtherPolicy", "0.0.1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyState("SomeOtherPolicy", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyState("MyTestPolicy", "0.0.2", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyState("MyTestPolicy", "0.0.1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(4, result.getMessages().size()); - result = apexModel.listPolicyState("MyTestPolicy", "0.0.1", "CState"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyState("MyTestPolicy", null, "CState"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyState("MyTestPolicy", "0.0.1", "AState"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyState("MyTestPolicy", "0.0.1", "EState"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deletePolicyState("@£$$", "0.0.2", "Trigger04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - assertEquals(4, apexModel.listPolicyState("MyTestPolicy", null, null).getMessages().size()); - result = apexModel.deletePolicyState("MyTestPolicy", "0.0.2", "Trigger04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(4, apexModel.listPolicyState("MyTestPolicy", null, null).getMessages().size()); - result = apexModel.deletePolicyState("MyTestPolicy", null, "CState"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deletePolicyState("MyTestPolicy", null, "ZState"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(3, apexModel.listPolicyState("MyTestPolicy", null, null).getMessages().size()); - result = apexModel.deletePolicyState("MyTestPolicy", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listPolicyState("MyTestPolicy", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyState("MyTestPolicy", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "TestState1", "inEvent", "0.0.1", "task", - "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "TestState2", "outEvent0", "0.0.1", "task", - "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "TestState3", "outEvent1", "0.0.1", "task", - "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createPolicyStateTaskSelectionLogic(null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, "SomeState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "1.2.3", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "NewTSL00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "UNDEFINED", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "MVEL", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - - result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "JAVA", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "JYTHON", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", "JAVASCRIPT", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", "JRUBY", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.updatePolicyStateTaskSelectionLogic(null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState99", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy2", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy1", "0.0.2", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "NonExistantState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "", - "Some Other Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "MVEL", - "Some Other Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyPolicy012", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", null, - "Some Other Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyPolicy015", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyPolicy014", "0.1.5", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listPolicyStateTaskSelectionLogic(null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateTaskSelectionLogic("zooby", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateTaskSelectionLogic("zooby", null, "looby"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskSelectionLogic("zooby", null, "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", null, "looby"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.2", "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - - result = apexModel.deletePolicyStateTaskSelectionLogic(null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateTaskSelectionLogic("zooby", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateTaskSelectionLogic("zooby", null, "looby"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateTaskSelectionLogic("zooby", null, "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", null, "looby"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.2", "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", null, - "Some Other Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", "JRUBY", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createPolicyStateOutput(null, null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", null, "SomeState", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", null, "SomeState", "SomeOutput", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "1.2.3", "TestState1", "SomeOutput", null, null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", null, null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", - "SomeDummyEvent", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", "inEvent", - "1.2.3", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", "inEvent", - "0.0.1", "SomeDummyNextState"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", "inEvent", - "0.0.1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent", - "0.0.1", "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent", - "0.0.1", "TestState2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent", - "0.0.1", "TestState2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "AnotherOtherOutput", - "outEvent0", "0.0.1", "TestState3"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "YetAnotherOtherOutput", - "outEvent0", "0.0.1", "TestState3"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listPolicyStateOutput(null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateOutput("MyTestPolicy", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.2", "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateOutput("MyTestPolicy", null, "SomeState", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, result.getMessages().size()); - result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, result.getMessages().size()); - result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "YetAnotherOtherOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "YetAnotherOtherOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState3", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deletePolicyStateOutput(null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateOutput("MyTestPolicy", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateOutput("MyTestPolicy", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateOutput("MyTestPolicy", "0.0.2", "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateOutput("MyTestPolicy", null, "SomeState", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateOutput("MyTestPolicy", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateOutput("MyTestPolicy", "0.0.1", "TestState3", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateOutput("MyTestPolicy", "0.0.1", "TestState3", "DummyOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateOutput("MyTestPolicy", null, "TestState1", null); - assertEquals(2, result.getMessages().size()); - result = apexModel.deletePolicyStateOutput("MyTestPolicy", null, "TestState1", "SomeOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyStateOutput("MyTestPolicy", null, "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.deletePolicyStateOutput("MyTestPolicy", null, "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyStateOutput("MyTestPolicy", null, "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateOutput("MyTestPolicy", null, "TestState2", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, result.getMessages().size()); - result = apexModel.deletePolicyStateOutput("MyTestPolicy", null, "TestState2", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, result.getMessages().size()); - result = apexModel.listPolicyStateOutput("MyTestPolicy", null, "TestState2", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", "inEvent", - "0.0.1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent", - "0.0.1", "TestState1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent", - "0.0.1", "TestState2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "AnotherOtherOutput", - "outEvent0", "0.0.1", "TestState3"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "YetAnotherOtherOutput", - "outEvent0", "0.0.1", "TestState3"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createPolicyStateFinalizerLogic(null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "SomeState", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "SomeState", "SFLName01", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "1.2.3", "TestState1", "SFLName01", null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName01", null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName01", - "NewTSL00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName02", - "UNDEFINED", "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName03", "MVEL", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName03", "MVEL", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName04", "JAVA", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName05", "JYTHON", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06", - "JAVASCRIPT", "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName07", "JRUBY", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.updatePolicyStateFinalizerLogic(null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, "TestState99", "SomeSFLName", null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy2", null, "TestState1", "SomeSFLName", null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy1", "0.0.2", "TestState1", "SomeSFLName", null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "NonEistantSFL", null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06", null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06", "", - "Some Other Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06", "MVEL", - "Some Other Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyStateFinalizerLogic("MyPolicy012", null, "TestState1", "SFLName06", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06", null, - "Some Other Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updatePolicyStateFinalizerLogic("MyPolicy015", null, "TestState1", "SFLName06", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updatePolicyStateFinalizerLogic("MyPolicy014", "0.1.5", "TestState1", "SFLName06", null, - null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listPolicyStateFinalizerLogic(null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", "0.0.2", "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "SomeState", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateFinalizerLogic("zooby", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateFinalizerLogic("zooby", null, "looby", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateFinalizerLogic("zooby", null, "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "looby", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", "0.0.2", "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(6, result.getMessages().size()); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - - result = apexModel.deletePolicyStateFinalizerLogic(null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.2", "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", null, "SomeState", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateFinalizerLogic("zooby", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateFinalizerLogic("zooby", null, "looby", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateFinalizerLogic("zooby", null, "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", null, "looby", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.2", "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(5, result.getMessages().size()); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName02"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName02"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName02"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(4, result.getMessages().size()); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(4, result.getMessages().size()); - result = apexModel.deletePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName02", - "UNDEFINED", "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName03", "MVEL", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName04", "JAVA", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName05", "JYTHON", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06", - "JAVASCRIPT", "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName07", "JRUBY", - "Some Policy Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createTask("TestTask0", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTask("TestTask1", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTask("TestTask2", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTask("TestTask3", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTask("TestTask4", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createPolicyStateTaskRef(null, null, null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, null, null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "SomeState", null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "SomeState", null, null, null, null, - "DummyOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "1.2.3", "SomeState", null, null, null, null, - "DummyOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateTaskRef("AnyOldPolicy", "1.2.3", "SomeState", null, null, null, null, - "DummyOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", null, - null, null, "DummyOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", - "SomeTask", "Zooby|", null, "DummyOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", - "SomeTask", "0.0.1", null, "DummyOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", "task", - "0.0.1", null, "DummyOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", "task", - "0.0.1", "Some Policy Logic", "DummyOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", "task", - "0.0.1", "DIRECT", "DummyOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", "task", - "0.0.1", "LOGIC", "DummyOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", "task", - "0.0.1", "DIRECT", "SFLName07"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", "task", - "0.0.1", "LOGIC", "SomeOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", "task", - "0.0.1", "DIRECT", "SomeOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", - "NonExistantTask", "0.0.1", "DIRECT", "SomeOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", "task", - "0.0.1", "LOGIC", "SFLName07"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", - "TestTask0", "0.0.1", "LOGIC", "SFLName07"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", - "TestTask1", "0.0.1", "DIRECT", "SomeOtherOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", - "TestTask2", "0.0.1", "LOGIC", "SFLName07"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", - "TestTask3", "0.0.1", "DIRECT", "SomeOtherOutput"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, "TestTask4", "0.0.1", - "LOGIC", "SFLName07"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, "TestTask4", "0.0.1", - "LOGIC", "SFLName07"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "TestState1", "TestTask4", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", - "TestTask4", "0.0.1", "FUNKY", "SFLName07"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", - "TestTask4", "0.0.1", "UNDEFINED", "SFLName07"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", - "TestTask4", "0.0.1", "LOGIC", "SFLName07"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, "TestTask0", "0.0.1", - "LOGIC", "SFLName07"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - - result = apexModel.listPolicyStateTaskRef(null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", "0.0.1", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", "0.0.2", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "SomeState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", "0.0.1", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateTaskRef("zooby", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateTaskRef("zooby", null, "looby", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskRef("zooby", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "looby", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", "0.0.2", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(12, result.getMessages().size()); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeOldTask", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "task", "1.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "task", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, result.getMessages().size()); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "task", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, result.getMessages().size()); - - result = apexModel.deletePolicyStateTaskRef(null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.1", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.2", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "SomeState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.1", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateTaskRef("zooby", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateTaskRef("zooby", null, "looby", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateTaskRef("zooby", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "looby", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.2", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.2", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "ADummyTask", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "task", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(12, result.getMessages().size()); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "TestState1", "TestTask0", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(10, result.getMessages().size()); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "TestState1", "TestTask2", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(8, result.getMessages().size()); - result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(4, result.getMessages().size()); - result = apexModel.listPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createPolicyStateContextRef(null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", null, "SomeState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", null, "SomeState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "1.2.3", "SomeState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateContextRef("AnyOldPolicy", "1.2.3", "SomeState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTask", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTask", "Zooby|"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTask", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "task", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateContextRef("MyPolicy123", null, null, "AContextMap00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateContextRef("MyPolicy123", null, "TestState1", "AContextMap00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "4.5.6", "TestState1", "AContextMap00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.1.4", "TestState1", "AContextMap00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "AContextMap00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", ""); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", null, "TestState1", "contextAlbum0", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - - result = apexModel.listPolicyStateContextRef(null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.2", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, "SomeState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateContextRef("zooby", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateContextRef("zooby", null, "looby", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateContextRef("zooby", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, "looby", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.2", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, result.getMessages().size()); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.2", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, result.getMessages().size()); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "AContextMap04", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "1.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deletePolicyStateContextRef(null, null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.1", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.2", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "SomeState", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.1", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateContextRef("zooby", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateContextRef("zooby", null, "looby", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateContextRef("zooby", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "looby", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.2", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.2", "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "ADummyContextMap", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "AContextMap04", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "TestState1", "contextAlbum0", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "TestState1", "contextAlbum0", "0.1.5"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "TestState1", "contextAlbum1", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.createPolicyStateContextRef("MyTestPolicy", "0.0.1", "TestState1", "contextAlbum0", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deletePolicyStateContextRef("MyTestPolicy", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listPolicyStateContextRef("MyTestPolicy", null, "TestState1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deletePolicy(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(3, result.getMessages().size()); - - result = apexModel.listPolicy(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(0, result.getMessages().size()); - } -} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiTask.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiTask.java deleted file mode 100644 index 9faa3653c..000000000 --- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexEditorApiTask.java +++ /dev/null @@ -1,485 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.modelapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Test tasks for API tests. - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class TestApexEditorApiTask { - @Test - public void testTaskCrud() { - final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - - ApexApiResult result = apexModel.validateTask(null, null); - assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); - - result = apexModel.validateTask("%%%$£", null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.createTask("@^^$^^$", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", - "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", - "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", - "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createTask("MyTask012", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTask("MyTask012", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.listTask(null, null); - result = apexModel.createTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", - "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createTask("MyTask012", "0.1.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", - "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.deleteTask("MyTask002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", - "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.validateTask(null, null); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModel.updateTask("@$$$£", "0.0.2", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.updateTask("MyTask002", "0.0.2", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateTask("MyTask002", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updateTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700", - "A description of 002"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateTask("MyTask012", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateTask("MyTask012", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateTask("MyTask012", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateTask("MyTask015", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updateTask("MyTask014", "0.1.5", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listTask("£@£@@£@£", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listTask(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTask("MyTask012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTask("MyTask012", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTask("MyTask012", "0.2.5"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listTask("MyTask014", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteTask("@£££@", "0.1.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deleteTask("MyTask012", "0.1.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deleteTask("MyTask012oooo", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listTask("MyTask012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 2); - - result = apexModel.deleteTask("MyTask012", "0.1.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listTask("MyTask012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertTrue(result.getMessages().size() == 1); - - result = apexModel.deleteTask("MyTask012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listTask("MyTask012", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.updateTaskLogic("MyTask002", null, "NewLogic00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskLogic("MyTask123", null, "NewLogic00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createTaskLogic("MyTask002", "4.5.6", "NewLogic00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createTaskLogic("MyTask002", "0.1.4", "NewLogic00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createTaskLogic("MyTask002", "0.0.2", "NewLogic00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createTaskLogic("MyTask002", "0.0.2", "UNDEFINED", "Some Task Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskLogic("MyTask002", "0.0.2", "MVEL", "Some Task Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskLogic("MyTask002", "0.0.2", "JAVA", "Some Task Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskLogic("MyTask002", "0.0.2", "JYTHON", "Some Task Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskLogic("MyTask002", null, "JAVASCRIPT", "Some Task Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskLogic("MyTask002", null, "JRUBY", "Some Task Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.updateTaskLogic("MyTask002", "0.0.2", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateTaskLogic("MyTask002", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updateTaskLogic("MyTask002", "0.0.2", "", "Some Other Task Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.updateTaskLogic("MyTask002", "0.0.2", "MVEL", "Some Other Task Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateTaskLogic("MyTask012", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updateTaskLogic("MyTask002", null, null, "Some Other Task Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateTaskLogic("MyTask002", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.updateTaskLogic("MyTask015", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.updateTaskLogic("MyTask014", "0.1.5", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.listTaskLogic("MyTask002", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskLogic("MyTask002", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listTaskLogic("MyTask002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskLogic("MyTask002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskLogic("MyTask002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskLogic(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.deleteTaskLogic("@£@£@£", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deleteTaskLogic("NonExistantTask", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - assertEquals(1, apexModel.listTaskLogic("MyTask002", null).getMessages().size()); - result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskLogic("MyTask002", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(1, apexModel.listTaskLogic("MyTask002", null).getMessages().size()); - result = apexModel.createTaskLogic("MyTask002", null, "JRUBY", "Some Task Logic"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskLogic("MyTask002", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.deleteTaskLogic("MyTask002", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskInputField("MyTask123", null, "NewField00", null, null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskInputField("MyTask002", "4.5.6", "NewField00", null, null, true); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskInputField("MyTask002", "0.1.4", "NewField00", null, null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField00", null, null, true); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, true); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField01", "eventContextItem0", "0.0.1", - false); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField02", "eventContextItem0", "0.0.2", true); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createTaskInputField("MyTask002", null, "NewField02", "eventContextItem0", null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskInputField("MyTask002", null, "NewField03", "eventContextItem0", null, true); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listTaskInputField("@£$%", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listTaskInputField("MyTask002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskInputField("MyTask002", "0.0.1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listTaskInputField("MyTask002", "0.0.2", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskInputField("MyTask002", "0.0.2", "NewField01"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskInputField("MyTask002", "0.0.2", "NewField02"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskInputField("MyTask002", "0.0.2", "NewField04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteTaskInputField("@£$%", "0.0.2", "NewField04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deleteTaskInputField("NonExistantTask", "0.0.2", "NewField04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(4, apexModel.listTaskInputField("MyTask002", null, null).getMessages().size()); - result = apexModel.deleteTaskInputField("MyTask002", "0.0.2", "NewField04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(4, apexModel.listTaskInputField("MyTask002", null, null).getMessages().size()); - result = apexModel.deleteTaskInputField("MyTask002", null, "NewField02"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(3, apexModel.listTaskInputField("MyTask002", null, null).getMessages().size()); - result = apexModel.deleteTaskInputField("MyTask002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskInputField("MyTask002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deleteTaskInputField("MyTask002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskOutputField("MyTask123", null, "NewField00", null, null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskOutputField("MyTask002", "4.5.6", "NewField00", null, null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskOutputField("MyTask002", "0.1.4", "NewField00", null, null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField00", null, null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField01", "eventContextItem0", "0.0.1", - false); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField02", "eventContextItem0", "0.0.2", - false); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createTaskOutputField("MyTask002", null, "NewField02", "eventContextItem0", null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskOutputField("MyTask002", null, "NewField03", "eventContextItem0", null, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.listTaskOutputField("@£$%", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listTaskOutputField("MyTask002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskOutputField("MyTask002", "0.0.1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listTaskOutputField("MyTask002", "0.0.2", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskOutputField("MyTask002", "0.0.2", "NewField01"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskOutputField("MyTask002", "0.0.2", "NewField02"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskOutputField("MyTask002", "0.0.2", "NewField04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteTaskOutputField("@£$%", "0.0.2", "NewField04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deleteTaskOutputField("NonExistantTask", "0.0.2", "NewField04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(4, apexModel.listTaskOutputField("MyTask002", null, null).getMessages().size()); - result = apexModel.deleteTaskOutputField("MyTask002", "0.0.2", "NewField04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(4, apexModel.listTaskOutputField("MyTask002", null, null).getMessages().size()); - result = apexModel.deleteTaskOutputField("MyTask002", null, "NewField02"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(3, apexModel.listTaskOutputField("MyTask002", null, null).getMessages().size()); - result = apexModel.deleteTaskOutputField("MyTask002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskOutputField("MyTask002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deleteTaskOutputField("MyTask002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskParameter("MyTask123", null, "NewPar00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskParameter("MyTask002", "4.5.6", "NewPar00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskParameter("MyTask002", "0.1.4", "NewPar00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar00", "eventContextItem0"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar00", "eventContextItem0"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar01", "eventContextItem0"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar02", "eventContextItem0"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar02", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createTaskParameter("MyTask002", "0.0.2", "NewPar03", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createTaskParameter("MyTask002", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createTaskParameter("MyTask002", null, null, "Default value"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.listTaskParameter("@£$%", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listTaskParameter("MyTask002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskParameter("MyTask002", "0.0.3", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listTaskParameter("MyTask002", "0.0.2", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskParameter("MyTask002", "0.0.2", "NewPar01"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskParameter("MyTask002", "0.0.2", "NewPar02"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskParameter("MyTask002", "0.0.2", "NewPar04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteTaskParameter("@£$%", "0.0.2", "NewPar04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deleteTaskParameter("NonExistantTask", "0.0.2", "NewPar04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(3, apexModel.listTaskParameter("MyTask002", null, null).getMessages().size()); - result = apexModel.deleteTaskParameter("MyTask002", "0.0.2", "NewPar04"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(3, apexModel.listTaskParameter("MyTask002", null, null).getMessages().size()); - result = apexModel.deleteTaskParameter("MyTask002", null, "NewPar02"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, apexModel.listTaskParameter("MyTask002", null, null).getMessages().size()); - result = apexModel.deleteTaskParameter("MyTask002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.listTaskParameter("MyTask002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deleteTaskParameter("MyTask002", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskContextRef("@£$$", null, "AContextMap00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.createTaskContextRef("MyTask123", null, "AContextMap00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createTaskContextRef("MyTask123", null, "AContextMap00", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createTaskContextRef("MyTask123", null, "AContextMap00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createTaskContextRef("MyTask002", "4.5.6", "AContextMap00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createTaskContextRef("MyTask002", "0.1.4", "AContextMap00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "AContextMap00", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "contextAlbum2", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "contextAlbum1", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - result = apexModel.createTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - result = apexModel.createTaskContextRef("MyTask002", null, "contextAlbum0", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_EXISTS)); - - result = apexModel.listTaskContextRef("@£$%", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.listTaskContextRef("MyTask002", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, result.getMessages().size()); - result = apexModel.listTaskContextRef("MyTask002", "0.0.1", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listTaskContextRef("MyTask002", "0.0.2", null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, result.getMessages().size()); - result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "AContextMap04", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "contextAlbum0", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "contextAlbum1", "0.0.1"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listTaskContextRef("MyTask002", "0.0.2", "contextAlbum1", "0.0.2"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteTaskContextRef("@£$%", "0.0.2", "AContextMap04", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - result = apexModel.deleteTaskContextRef("NonExistantTask", "0.0.2", "AContextMap04", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - assertEquals(2, apexModel.listTaskContextRef("MyTask002", null, null, null).getMessages().size()); - result = apexModel.deleteTaskContextRef("MyTask002", "0.0.2", "AContextMap04", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deleteTaskContextRef("MyTask002", null, "contextAlbum0", "0.0.3"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deleteTaskContextRef("MyTask002", null, "contextAlbum0", "0.1.5"); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - result = apexModel.deleteTaskContextRef("MyTask002", null, "contextAlbum0", null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.deleteTaskContextRef("MyTask002", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(1, result.getMessages().size()); - result = apexModel.listTaskContextRef("MyTask002", null, null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST)); - - result = apexModel.deleteTask(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(2, result.getMessages().size()); - - result = apexModel.listTask(null, null); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - assertEquals(0, result.getMessages().size()); - } -} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexModelApi.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexModelApi.java deleted file mode 100644 index 9e2e1ce56..000000000 --- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApexModelApi.java +++ /dev/null @@ -1,259 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.modelapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.IOException; -import java.sql.Connection; -import java.sql.DriverManager; -import java.util.UUID; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.dao.DaoParameters; -import org.onap.policy.apex.model.modelapi.impl.ApexModelImpl; -import org.onap.policy.apex.model.utilities.TextFileUtils; - -/** - * Test the apex model API. - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class TestApexModelApi { - private Connection connection; - - @Before - public void setup() throws Exception { - Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); - connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true"); - } - - @After - public void teardown() throws Exception { - connection.close(); - new File("derby.log").delete(); - } - - @Test - public void testApexModelLoadFromFile() { - final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - - ApexApiResult result = apexModel.loadFromFile("src/main/resources/models/PolicyModel.json"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.deleteModel(); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.xml"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.deleteModel(); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.junk"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - assertTrue(result.getMessages().get(0).equals("format of input for Apex concept is neither JSON nor XML")); - } - - @Test - public void testApexModelSaveToFile() throws IOException { - final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - - ApexApiResult result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - final File tempJsonModelFile = File.createTempFile("ApexModelTest", ".json"); - result = apexModel.saveToFile(tempJsonModelFile.getCanonicalPath(), false); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - final ApexModel jsonApexModel = new ApexModelFactory().createApexModel(null, false); - result = jsonApexModel.loadFromFile(tempJsonModelFile.getCanonicalPath()); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - tempJsonModelFile.delete(); - - final File tempXmlModelFile = File.createTempFile("ApexModelTest", ".xml"); - result = apexModel.saveToFile(tempXmlModelFile.getCanonicalPath(), true); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - final ApexModel xmlApexModel = new ApexModelFactory().createApexModel(null, false); - result = xmlApexModel.loadFromFile(tempXmlModelFile.getCanonicalPath()); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - tempXmlModelFile.delete(); - } - - @Test - public void testApexModelDatabase() throws IOException { - final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - - ApexApiResult result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json"); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - final DaoParameters DaoParameters = new DaoParameters(); - DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); - DaoParameters.setPersistenceUnit("DAOTest"); - - result = apexModel.saveToDatabase(DaoParameters); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.deleteModel(); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.loadFromDatabase("PolicyModel", "0.0.1", DaoParameters); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.deleteModel(); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.loadFromDatabase("PolicyModel", null, DaoParameters); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.deleteModel(); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.loadFromDatabase("VPNPolicyModel", "0.0.1", DaoParameters); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - } - - @Test - public void testApexModelUrl() throws IOException { - ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - - ApexApiResult result = null; - - try { - result = apexModel.readFromUrl(null); - fail("expecting an IllegalArgumentException"); - } catch (final Exception e) { - assertTrue(e instanceof IllegalArgumentException); - } - - try { - result = apexModel.writeToUrl(null, true); - fail("expecting an IllegalArgumentException"); - } catch (final Exception e) { - assertTrue(e instanceof IllegalArgumentException); - } - - result = apexModel.readFromUrl("zooby/looby"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.writeToUrl("zooby/looby", true); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.readFromUrl("zooby://zooby/looby"); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - result = apexModel.writeToUrl("zooby://zooby/looby", false); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - - apexModel = new ApexModelFactory().createApexModel(null, false); - - final File tempJsonModelFile = File.createTempFile("ApexModelTest", ".json"); - result = apexModel.saveToFile(tempJsonModelFile.getCanonicalPath(), false); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - final String tempFileUrlString = tempJsonModelFile.toURI().toString(); - result = apexModel.readFromUrl(tempFileUrlString); - assertTrue(result.getResult().equals(ApexApiResult.Result.SUCCESS)); - - result = apexModel.writeToUrl(tempFileUrlString, false); - assertTrue(result.getResult().equals(ApexApiResult.Result.FAILED)); - assertTrue(result.getMessages().get(0).equals("protocol doesn't support output")); - - tempJsonModelFile.delete(); - } - - @Test - public void testApexModelMisc() throws IOException { - final ApexModelImpl apexModelImpl = (ApexModelImpl) new ApexModelFactory().createApexModel(null, false); - - ApexApiResult result = null; - - result = apexModelImpl.getModelKey(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.listModel(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.createModel("ModelName", "0.0.1", null, null); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.updateModel("ModelName", "0.0.1", UUID.randomUUID().toString(), "Model Description"); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - apexModelImpl.deleteModel(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - final String modelString = TextFileUtils.getTextFileAsString("src/test/resources/models/PolicyModel.json"); - result = apexModelImpl.loadFromString(modelString); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - final File tempFile = File.createTempFile("ApexModel", "json"); - tempFile.deleteOnExit(); - TextFileUtils.putStringAsFile(modelString, tempFile); - - apexModelImpl.deleteModel(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.loadFromFile(tempFile.getCanonicalPath()); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.saveToFile(null, false); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.analyse(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.validate(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.compare(tempFile.getCanonicalPath(), true, true); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.compareWithString(modelString, true, true); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.split("policy"); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.split(tempFile.getCanonicalPath(), "policy"); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.merge(tempFile.getCanonicalPath(), true); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModelImpl.mergeWithString(modelString, true); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - assertNotEquals(0, apexModelImpl.hashCode()); - assertNotNull(apexModelImpl.clone()); - assertNotNull(apexModelImpl.build()); - } -} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApiResult.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApiResult.java deleted file mode 100644 index e2717e542..000000000 --- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestApiResult.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.modelapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.Arrays; - -import org.junit.Test; -import org.onap.policy.apex.model.modelapi.ApexApiResult.Result; - -/** - * Test API results. - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class TestApiResult { - - @Test - public void testApiResult() { - assertNotNull(new ApexApiResult()); - - for (final Result result : Result.values()) { - assertNotNull(new ApexApiResult(result)); - } - - assertNotNull(new ApexApiResult(Result.SUCCESS, "Result Message")); - assertNotNull(new ApexApiResult(Result.FAILED, new IOException("IO Exception message"))); - assertNotNull(new ApexApiResult(Result.FAILED, "Result Message", new IOException("IO Exception message"))); - - final ApexApiResult result = - new ApexApiResult(Result.FAILED, "Result Message", new IOException("IO Exception message")); - - assertFalse(result.isOk()); - assertTrue(result.isNok()); - assertEquals(Result.FAILED, result.getResult()); - assertEquals("Result Message\nIO Exception message\njava.io.IOExce", result.getMessage().substring(0, 50)); - - final ApexApiResult result2 = new ApexApiResult(Result.SUCCESS); - result2.addMessage(null); - assertEquals("", result2.getMessage()); - result2.addMessage(""); - assertEquals("", result2.getMessage()); - result2.addMessage("funky message"); - assertEquals("funky message\n", result2.getMessage()); - - result2.setResult(Result.OTHER_ERROR); - assertEquals(Result.OTHER_ERROR, result2.getResult()); - - final String[] messages = {"First Message", "Second Message", "Third Message"}; - result2.setMessages(Arrays.asList(messages)); - assertEquals("First Message", result2.getMessages().get(0)); - assertEquals("Second Message", result2.getMessages().get(1)); - assertEquals("Third Message", result2.getMessages().get(2)); - - assertEquals("result: OTHER_ERROR\nFirst Message\nSecond Message\nThird Message\n", result2.toString()); - assertEquals("{\n" + "\"result\": \"OTHER_ERROR\",\n" + "\"messages\": [\n" + "\"First Message\",\n" - + "\"Second Message\",\n" + "\"Third Message\"]\n" + "}\n", result2.toJson()); - } -} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestModelFacade.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestModelFacade.java deleted file mode 100644 index 2c937e175..000000000 --- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestModelFacade.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.modelapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import java.util.Properties; -import java.util.UUID; - -import org.junit.Test; -import org.onap.policy.apex.model.modelapi.impl.ModelFacade; - -public class TestModelFacade { - - @Test - public void testModelFacade() { - try { - new ModelFacade(null, null, false); - fail("test should throw an exception here"); - } catch (final Exception e) { - assertEquals("apexModel may not be null", e.getMessage()); - } - - final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - - try { - new ModelFacade(apexModel, null, false); - fail("test should throw an exception here"); - } catch (final Exception e) { - assertEquals("apexProperties may not be null", e.getMessage()); - } - - final Properties modelProperties = new Properties(); - final ModelFacade mf = new ModelFacade(apexModel, modelProperties, false); - - ApexApiResult result = mf.createModel(null, null, null, null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mf.createModel("ModelName", null, null, null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mf.createModel("ModelName", "0.0.1", null, null); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - modelProperties.setProperty("DEFAULT_CONCEPT_VERSION", ""); - result = mf.createModel("ModelName", null, null, null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - modelProperties.setProperty("DEFAULT_CONCEPT_VERSION", "£$£$£$"); - result = mf.createModel("ModelName", null, null, null); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - modelProperties.setProperty("DEFAULT_CONCEPT_VERSION", "0.0.1"); - result = mf.createModel("ModelName", null, null, null); - assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult()); - result = mf.deleteModel(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - result = mf.createModel("ModelName", null, null, null); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = mf.updateModel("ModelName", null, UUID.randomUUID().toString(), "New Description"); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = mf.updateModel("ModelName", "0.0.1", UUID.randomUUID().toString(), "New Description"); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - modelProperties.remove("DEFAULT_CONCEPT_VERSION"); - result = mf.updateModel("ModelName", null, UUID.randomUUID().toString(), "New Description"); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mf.updateModel(null, null, UUID.randomUUID().toString(), "New Description"); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mf.deleteModel(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - result = mf.updateModel("name", "0.0.1", UUID.randomUUID().toString(), "New Description"); - assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); - - result = mf.getModelKey(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = mf.listModel(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - assertEquals("AxPolicyModel:(AxPolicyModel:(key=AxArtifactKey:(n", result.getMessage().substring(0, 50)); - - result = mf.deleteModel(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - assertNotNull(mf); - } -} diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestModelHandlerFacade.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestModelHandlerFacade.java deleted file mode 100644 index 22ecaf631..000000000 --- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/TestModelHandlerFacade.java +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.modelapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.IOException; -import java.util.Properties; - -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.dao.DaoParameters; -import org.onap.policy.apex.model.modelapi.impl.ModelHandlerFacade; -import org.onap.policy.apex.model.utilities.TextFileUtils; - -/** - * Test the model handler facade. - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class TestModelHandlerFacade { - - @Test - public void testModelHandlerFacade() throws IOException { - try { - new ModelHandlerFacade(null, null, false); - fail("test should throw an exception here"); - } catch (final Exception e) { - assertEquals("apexModel may not be null", e.getMessage()); - } - - final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - - try { - new ModelHandlerFacade(apexModel, null, false); - fail("test should throw an exception here"); - } catch (final Exception e) { - assertEquals("apexProperties may not be null", e.getMessage()); - } - - final Properties modelProperties = new Properties(); - final ModelHandlerFacade mhf = new ModelHandlerFacade(apexModel, modelProperties, false); - assertNotNull(mhf); - - ApexApiResult result = mhf.loadFromFile("src/test/resources/models/PolicyModel.json"); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = mhf.loadFromFile("src/test/resources/models/PolicyModel.json"); - assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult()); - - final String modelString = TextFileUtils.getTextFileAsString("src/test/resources/models/PolicyModel.json"); - - result = apexModel.deleteModel(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = mhf.loadFromString(modelString); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = mhf.loadFromString(modelString); - assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult()); - - final DaoParameters DaoParameters = new DaoParameters(); - result = mhf.loadFromDatabase("SomeModel", null, DaoParameters); - assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult()); - - result = apexModel.deleteModel(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = mhf.loadFromDatabase("SomeModel", null, DaoParameters); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mhf.saveToDatabase(DaoParameters); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mhf.readFromUrl("blah://somewhere/over/the/rainbow"); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mhf.loadFromString(modelString); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = mhf.readFromUrl("http://somewhere/over/the/rainbow"); - assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult()); - - final File tempFile = File.createTempFile("ApexModel", "json"); - tempFile.deleteOnExit(); - - result = mhf.writeToUrl("File:///" + tempFile.getCanonicalPath(), false); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mhf.validate(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = apexModel.deleteModel(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - result = mhf.validate(); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mhf.compare("src/test/resources/models/NonExistant.json", true, true); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mhf.compareWithString("zooby", true, true); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mhf.split("FailSplit", "NonExistantPolicy"); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mhf.split("NonExistantPolicy"); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mhf.merge("src/test/resources/models/NonExistant.json", false); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.deleteModel(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - result = mhf.merge("src/test/resources/models/PolicyModel.json", false); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = mhf.loadFromFile("src/test/resources/models/PolicyModel.json"); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - result = mhf.mergeWithString("@£@$@£", true); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - result = apexModel.deleteModel(); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - result = mhf.mergeWithString(modelString, false); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - } -} -- cgit 1.2.3-korg