From 8534756d13531ffec9c2d7b2ffe0a53ee1d3aaef Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 10 Feb 2022 12:06:25 +0000 Subject: Collapse apex-pdp maven model submodules This review collapses all the code in six podel submodules into a single model module. There are no code changes, just files moved around. This change reduces the complexity of the code structure and speeds up the build. Issue-ID: POLICY-1820 Change-Id: Ifb644e8ec85ae6d0987378f4616fbc8a8858a9a8 Signed-off-by: liamfallon --- .../policymodel/concepts/DummyLogicReader.java | 65 --- .../model/policymodel/concepts/ExceptionsTest.java | 51 --- .../apex/model/policymodel/concepts/LogicTest.java | 161 ------- .../model/policymodel/concepts/PoliciesTest.java | 391 ----------------- .../policymodel/concepts/PolicyModelTest.java | 312 -------------- .../policymodel/concepts/StateOutputTest.java | 124 ------ .../concepts/StateTaskReferenceTest.java | 144 ------- .../apex/model/policymodel/concepts/StateTest.java | 461 --------------------- .../policymodel/concepts/TaskParameterTest.java | 110 ----- .../apex/model/policymodel/concepts/TasksTest.java | 259 ------------ .../policymodel/handling/ApexPolicyModelTest.java | 138 ------ .../policymodel/handling/PolicyAnalyserTest.java | 60 --- .../handling/PolicyLogicReaderTest.java | 84 ---- .../handling/PolicyModelComparerTest.java | 118 ------ .../handling/PolicyModelMergerTest.java | 92 ---- .../handling/PolicyModelSplitterTest.java | 76 ---- .../handling/SupportApexPolicyModelCreator.java | 406 ------------------ .../utils/SupportPolicyModelValidator.java | 48 --- .../PolicyModelComparisonDifferentTerseKeys.txt | 12 - .../PolicyModelComparisonDifferentTerseValues.txt | 12 - .../PolicyModelComparisonDifferentVerboseKeys.txt | 70 ---- ...PolicyModelComparisonDifferentVerboseValues.txt | 70 ---- .../PolicyModelComparisonIdenticalTerse.txt | 8 - .../PolicyModelComparisonIdenticalVerboseKeys.txt | 69 --- ...PolicyModelComparisonIdenticalVerboseValues.txt | 68 --- .../src/test/resources/logback-test.xml | 74 ---- ...ogicParentLocalNameLogicInstanceName.funkylogic | 21 - 27 files changed, 3504 deletions(-) delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/DummyLogicReader.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/ExceptionsTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReaderTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelMergerTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java delete mode 100644 model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/utils/SupportPolicyModelValidator.java delete mode 100644 model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt delete mode 100644 model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt delete mode 100644 model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt delete mode 100644 model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt delete mode 100644 model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt delete mode 100644 model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseKeys.txt delete mode 100644 model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt delete mode 100644 model/policy-model/src/test/resources/logback-test.xml delete mode 100644 model/policy-model/src/test/resources/path/to/apex/logic/funkylogic/LogicParentLogicParentLocalNameLogicInstanceName.funkylogic (limited to 'model/policy-model/src/test') diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/DummyLogicReader.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/DummyLogicReader.java deleted file mode 100644 index 007288343..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/DummyLogicReader.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.policymodel.concepts; - -public class DummyLogicReader implements AxLogicReader { - - /** - * {@inheritDoc}. - */ - @Override - public String getLogicPackage() { - return null; - } - - /** - * {@inheritDoc}. - */ - @Override - public AxLogicReader setLogicPackage(final String logicPackage) { - return null; - } - - /** - * {@inheritDoc}. - */ - @Override - public String getDefaultLogic() { - return null; - } - - /** - * {@inheritDoc}. - */ - @Override - public AxLogicReader setDefaultLogic(final String defaultLogic) { - return null; - } - - /** - * {@inheritDoc}. - */ - @Override - public String readLogic(final AxLogic axLogic) { - return "Dummy Logic"; - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/ExceptionsTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/ExceptionsTest.java deleted file mode 100644 index 0afb48b3c..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/ExceptionsTest.java +++ /dev/null @@ -1,51 +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.policymodel.concepts; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; -import org.junit.Test; - -/** - * Test model exceptions. - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class ExceptionsTest { - - @Test - public void test() { - assertNotNull(new PolicyException("Message")); - assertNotNull(new PolicyException("Message", new IOException())); - - final PolicyException ae = new PolicyException("Message", new IOException("IO exception message")); - assertEquals("Message\ncaused by: Message\ncaused by: IO exception message", ae.getCascadedMessage()); - - assertNotNull(new PolicyRuntimeException("Message")); - assertNotNull(new PolicyRuntimeException("Message", new IOException())); - - final PolicyRuntimeException re = - new PolicyRuntimeException("Runtime Message", new IOException("IO runtime exception message")); - assertEquals("Runtime Message\ncaused by: Runtime Message\ncaused by: IO runtime exception message", - re.getCascadedMessage()); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java deleted file mode 100644 index fbfc7c4a0..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.policymodel.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; - -/** - * Test apex logic. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class LogicTest { - - @Test - public void testLogic() { - final DummyLogicReader logicReader = new DummyLogicReader(); - - assertNotNull(new AxLogic()); - assertNotNull(new AxLogic(new AxReferenceKey())); - assertNotNull(new AxLogic(new AxReferenceKey(), "LogicFlavour", "Logic")); - assertNotNull(new AxLogic(new AxReferenceKey(), "LogicName", "LogicFlavour", "Logic")); - assertNotNull(new AxLogic(new AxReferenceKey(), "LogicFlavour", logicReader)); - - assertNotNull(new AxTaskLogic()); - assertNotNull(new AxTaskLogic(new AxReferenceKey())); - assertNotNull(new AxTaskLogic(new AxReferenceKey(), "LogicFlavour", "Logic")); - assertNotNull(new AxTaskLogic(new AxReferenceKey(), "LogicFlavour", logicReader)); - assertNotNull(new AxTaskLogic(new AxLogic())); - assertNotNull(new AxTaskLogic(new AxArtifactKey(), "LogicName", "LogicFlavour", logicReader)); - assertNotNull(new AxTaskLogic(new AxArtifactKey(), "LogicName", "LogicFlavour", "Logic")); - assertNotNull(new AxTaskLogic(new AxReferenceKey(), "LogicFlavour", logicReader)); - - assertNotNull(new AxTaskSelectionLogic()); - assertNotNull(new AxTaskSelectionLogic(new AxReferenceKey())); - assertNotNull(new AxTaskSelectionLogic(new AxReferenceKey(), "LogicFlavour", "Logic")); - assertNotNull(new AxTaskSelectionLogic(new AxReferenceKey(), "LogicName", "LogicFlavour", "Logic")); - assertNotNull(new AxTaskSelectionLogic(new AxReferenceKey(), "LogicFlavour", logicReader)); - assertNotNull(new AxTaskSelectionLogic(new AxLogic())); - assertNotNull(new AxTaskSelectionLogic(new AxReferenceKey(), "LogicFlavour", logicReader)); - assertNotNull(new AxTaskSelectionLogic(new AxReferenceKey(), "LogicName", "LogicFlavour", logicReader)); - - assertNotNull(new AxStateFinalizerLogic()); - assertNotNull(new AxStateFinalizerLogic(new AxReferenceKey())); - assertNotNull(new AxStateFinalizerLogic(new AxReferenceKey(), "LogicFlavour", "Logic")); - assertNotNull(new AxStateFinalizerLogic(new AxReferenceKey(), "LogicName", "LogicFlavour", "Logic")); - assertNotNull(new AxStateFinalizerLogic(new AxReferenceKey(), "LogicFlavour", logicReader)); - assertNotNull(new AxStateFinalizerLogic(new AxLogic())); - assertNotNull(new AxStateFinalizerLogic(new AxReferenceKey(), "LogicFlavour", logicReader)); - assertNotNull(new AxStateFinalizerLogic(new AxReferenceKey(), "LogicName", "LogicFlavour", logicReader)); - - final AxLogic logic = new AxLogic(); - - final AxReferenceKey logicKey = new AxReferenceKey("LogicParentName", "0.0.1", "PLN", "LN"); - logic.setKey(logicKey); - assertEquals("LogicParentName:0.0.1:PLN:LN", logic.getKey().getId()); - assertEquals("LogicParentName:0.0.1:PLN:LN", logic.getKeys().get(0).getId()); - - logic.setLogicFlavour("LogicFlavour"); - assertEquals("LogicFlavour", logic.getLogicFlavour()); - - logic.setLogic("Logic"); - assertEquals("Logic", logic.getLogic()); - - AxValidationResult result = new AxValidationResult(); - result = logic.validate(result); - assertEquals(AxValidationResult.ValidationResult.VALID, result.getValidationResult()); - - logic.setKey(AxReferenceKey.getNullKey()); - result = new AxValidationResult(); - result = logic.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - logic.setKey(logicKey); - result = new AxValidationResult(); - result = logic.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - assertThatThrownBy(() -> logic.setLogicFlavour(null)) - .hasMessageContaining("parameter \"logicFlavour\" is null"); - assertThatThrownBy(() -> logic.setLogicFlavour("")) - .hasMessage("parameter \"logicFlavour\": value \"\", " - + "does not match regular expression \"[A-Za-z0-9\\-_]+\""); - logic.setLogicFlavour(AxLogic.LOGIC_FLAVOUR_UNDEFINED); - result = new AxValidationResult(); - result = logic.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - logic.setLogicFlavour("LogicFlavour"); - result = new AxValidationResult(); - result = logic.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - assertThatThrownBy(() -> logic.setLogic(null)).hasMessage("logic may not be null"); - logic.setLogic(""); - result = new AxValidationResult(); - result = logic.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - logic.setLogic("Logic"); - result = new AxValidationResult(); - result = logic.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - logic.clean(); - - final AxLogic clonedLogic = new AxLogic(logic); - assertEquals("AxLogic:(key=AxReferenceKey:(parentKeyName=LogicParentName,parentKeyVersion=0.0.1," - + "parentLocalName=PLN,localName=LN),logicFlavour=LogicFlavour,logic=Logic)", - clonedLogic.toString()); - - assertNotEquals(0, logic.hashCode()); - // disabling sonar because this code tests the equals() method - assertEquals(logic, logic); // NOSONAR - assertEquals(logic, clonedLogic); - assertNotNull(logic); - assertNotEquals(logic, (Object) "Hello"); - assertNotEquals(logic, new AxLogic(AxReferenceKey.getNullKey(), "LogicFlavour", "Logic")); - assertNotEquals(logic, new AxLogic(logicKey, "AnotherLogicFlavour", "Logic")); - assertNotEquals(logic, new AxLogic(logicKey, "LogicFlavour", "AnotherLogic")); - assertEquals(logic, new AxLogic(logicKey, "LogicFlavour", "Logic")); - - assertEquals(0, logic.compareTo(logic)); - assertEquals(0, logic.compareTo(clonedLogic)); - assertNotEquals(0, logic.compareTo(new AxArtifactKey())); - assertNotEquals(0, logic.compareTo(null)); - assertNotEquals(0, logic.compareTo(new AxLogic(AxReferenceKey.getNullKey(), "LogicFlavour", "Logic"))); - assertNotEquals(0, logic.compareTo(new AxLogic(logicKey, "AnotherLogicFlavour", "Logic"))); - assertNotEquals(0, logic.compareTo(new AxLogic(logicKey, "LogicFlavour", "AnotherLogic"))); - assertEquals(0, logic.compareTo(new AxLogic(logicKey, "LogicFlavour", "Logic"))); - - assertNotNull(logic.getKeys()); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java deleted file mode 100644 index 526f5a628..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java +++ /dev/null @@ -1,391 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.policymodel.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.Map; -import java.util.TreeMap; -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.policymodel.handling.SupportApexPolicyModelCreator; - -/** - * Test apex policies. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class PoliciesTest { - - @Test - public void testPolicies() { - final TreeMap stateMap = new TreeMap<>(); - final TreeMap stateMapEmpty = new TreeMap<>(); - - assertNotNull(new AxPolicy()); - assertNotNull(new AxPolicy(new AxArtifactKey())); - assertNotNull(new AxPolicy(new AxArtifactKey(), "PolicyTemplate", stateMapEmpty, "FirstState")); - - final AxPolicy policy = new AxPolicy(); - - final AxArtifactKey policyKey = new AxArtifactKey("PolicyName", "0.0.1"); - - final AxState firstState = new AxState(new AxReferenceKey(policy.getKey(), "FirstState")); - final AxState badState = new AxState(new AxReferenceKey(policy.getKey(), "BadState")); - final AxStateOutput badStateOutput = new AxStateOutput(badState.getKey(), AxArtifactKey.getNullKey(), - new AxReferenceKey(policyKey, "BadNextState")); - badState.getStateOutputs().put(badStateOutput.getKey().getLocalName(), badStateOutput); - stateMap.put(firstState.getKey().getLocalName(), firstState); - - assertThatThrownBy(() -> policy.setKey(null)) - .hasMessage("key may not be null"); - policy.setKey(policyKey); - assertEquals("PolicyName:0.0.1", policy.getKey().getId()); - assertEquals("PolicyName:0.0.1", policy.getKeys().get(0).getId()); - - assertThatThrownBy(() -> policy.setTemplate(null)) - .hasMessage("template may not be null"); - policy.setTemplate("PolicyTemplate"); - assertEquals("PolicyTemplate", policy.getTemplate()); - - assertThatThrownBy(() -> policy.setStateMap(null)) - .hasMessage("stateMap may not be null"); - policy.setStateMap(stateMap); - assertEquals(stateMap, policy.getStateMap()); - - assertThatThrownBy(() -> policy.setFirstState(null)) - .hasMessage("firstState may not be null"); - policy.setFirstState("FirstState"); - assertEquals("FirstState", policy.getFirstState()); - - assertEquals("PolicyName:0.0.1", policy.getKeys().get(0).getId()); - - final AxPolicy policyPN = new SupportApexPolicyModelCreator().getModel().getPolicies().get("policy"); - - AxValidationResult result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final AxArtifactKey savedPolicyKey = policyPN.getKey(); - policyPN.setKey(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - policyPN.setKey(savedPolicyKey); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final String savedTemplate = policyPN.getTemplate(); - policyPN.setTemplate(""); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.OBSERVATION, result.getValidationResult()); - - policyPN.setTemplate(savedTemplate); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final Map savedStateMap = policyPN.getStateMap(); - - policyPN.setStateMap(stateMapEmpty); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - policyPN.setStateMap(savedStateMap); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - savedStateMap.put(AxKey.NULL_KEY_NAME, firstState); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - savedStateMap.remove(AxKey.NULL_KEY_NAME); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - savedStateMap.put("NullState", null); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - savedStateMap.remove("NullState"); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - savedStateMap.put("BadStateKey", firstState); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - savedStateMap.remove("BadStateKey"); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - savedStateMap.put(badState.getKey().getLocalName(), badState); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - savedStateMap.remove(badState.getKey().getLocalName()); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final String savedFirstState = policyPN.getFirstState(); - - policyPN.setFirstState(""); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - policyPN.setFirstState(savedFirstState); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - policyPN.setFirstState("NonExistantFirstState"); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - policyPN.setFirstState(savedFirstState); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final AxState clonedState = new AxState(policyPN.getStateMap().get("state")); - clonedState.getKey().setLocalName("ClonedState"); - - savedStateMap.put(clonedState.getKey().getLocalName(), clonedState); - policyPN.buildReferences(); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.WARNING, result.getValidationResult()); - - savedStateMap.remove(clonedState.getKey().getLocalName()); - result = new AxValidationResult(); - result = policyPN.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - policyPN.clean(); - - final AxPolicy clonedPolicy = new AxPolicy(policyPN); - assertEquals("AxPolicy:(key=AxArtifactKey:(name=policy,version=0.0.1),template=FREEFORM,sta", - clonedPolicy.toString().substring(0, 77)); - - assertNotEquals(0, policyPN.hashCode()); - // disabling sonar because this code tests the equals() method - assertEquals(policyPN, policyPN); // NOSONAR - assertEquals(policyPN, clonedPolicy); - assertNotNull(policyPN); - - Object helloObj = "Hello"; - assertNotEquals(policyPN, helloObj); - assertNotEquals(policyPN, - new AxPolicy(AxArtifactKey.getNullKey(), savedTemplate, savedStateMap, savedFirstState)); - assertNotEquals(policyPN, new AxPolicy(savedPolicyKey, "SomeTemplate", savedStateMap, savedFirstState)); - assertNotEquals(policyPN, new AxPolicy(savedPolicyKey, savedTemplate, stateMapEmpty, savedFirstState)); - assertNotEquals(policyPN, new AxPolicy(savedPolicyKey, savedTemplate, savedStateMap, "SomeFirstState")); - assertEquals(policyPN, new AxPolicy(savedPolicyKey, savedTemplate, savedStateMap, savedFirstState)); - - assertEquals(0, policyPN.compareTo(policyPN)); - assertEquals(0, policyPN.compareTo(clonedPolicy)); - assertNotEquals(0, policyPN.compareTo(new AxArtifactKey())); - assertNotEquals(0, policyPN.compareTo(null)); - assertNotEquals(0, policyPN.compareTo( - new AxPolicy(AxArtifactKey.getNullKey(), savedTemplate, savedStateMap, savedFirstState))); - assertNotEquals(0, policyPN.compareTo(new AxPolicy(savedPolicyKey, - "SomeTemplate", savedStateMap, savedFirstState))); - assertNotEquals(0, policyPN.compareTo(new AxPolicy(savedPolicyKey, savedTemplate, - stateMapEmpty, savedFirstState))); - assertNotEquals(0, policyPN.compareTo(new AxPolicy(savedPolicyKey, savedTemplate, - savedStateMap, "SomeFirstState"))); - assertEquals(0, policyPN.compareTo(new AxPolicy(savedPolicyKey, savedTemplate, - savedStateMap, savedFirstState))); - - assertNotNull(policyPN.getKeys()); - - final AxPolicies policies = new AxPolicies(); - result = new AxValidationResult(); - result = policies.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - // Invalid, no events in event map - policies.setKey(new AxArtifactKey("PoliciesKey", "0.0.1")); - assertEquals("PoliciesKey:0.0.1", policies.getKey().getId()); - - result = new AxValidationResult(); - result = policies.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - policies.getPolicyMap().put(savedPolicyKey, policyPN); - result = new AxValidationResult(); - result = policies.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - policies.getPolicyMap().put(AxArtifactKey.getNullKey(), null); - result = new AxValidationResult(); - result = policies.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - policies.getPolicyMap().remove(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = policies.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - policies.getPolicyMap().put(new AxArtifactKey("NullValueKey", "0.0.1"), null); - result = new AxValidationResult(); - result = policies.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - policies.getPolicyMap().remove(new AxArtifactKey("NullValueKey", "0.0.1")); - result = new AxValidationResult(); - result = policies.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - policies.getPolicyMap().put(new AxArtifactKey("BadEventKey", "0.0.1"), policyPN); - result = new AxValidationResult(); - result = policies.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - policies.getPolicyMap().remove(new AxArtifactKey("BadEventKey", "0.0.1")); - result = new AxValidationResult(); - result = policies.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - policies.clean(); - - final AxPolicies clonedPolicies = new AxPolicies(policies); - assertEquals("AxPolicies:(key=AxArtifactKey:(name=PoliciesKey,version=0.0.", - clonedPolicies.toString().substring(0, 60)); - - assertNotEquals(0, policies.hashCode()); - // disabling sonar because this code tests the equals() method - assertEquals(policies, policies); // NOSONAR - assertEquals(policies, clonedPolicies); - assertNotNull(policies); - assertNotEquals(policyPN, helloObj); - assertNotEquals(policies, new AxPolicies(new AxArtifactKey())); - - assertEquals(0, policies.compareTo(policies)); - assertEquals(0, policies.compareTo(clonedPolicies)); - assertNotEquals(0, policies.compareTo(null)); - assertNotEquals(0, policies.compareTo(new AxArtifactKey())); - assertNotEquals(0, policies.compareTo(new AxPolicies(new AxArtifactKey()))); - - clonedPolicies.get(savedPolicyKey).setTemplate("AnotherTemplate"); - assertNotEquals(0, policies.compareTo(clonedPolicies)); - - assertEquals(policies.getKey(), policies.getKeys().get(0)); - - assertEquals("policy", policies.get("policy").getKey().getName()); - assertEquals("policy", policies.get("policy", "0.0.1").getKey().getName()); - assertEquals(1, policies.getAll("policy", "0.0.1").size()); - assertEquals(0, policies.getAll("NonExistantPolicy").size()); - - AxStateTree stateTree = policy.getStateTree(); - assertNotNull(stateTree); - assertNotNull(stateTree.getReferencedStateList()); - assertNotNull(stateTree.getReferencedStateSet()); - - final AxState secondState = new AxState(policyPN.getStateMap().get("state")); - secondState.getKey().setLocalName("SecondState"); - policyPN.getStateMap().put("SecondState", secondState); - policyPN.getStateMap().get("state").getStateOutputs().get("stateOutput0").setNextState(secondState.getKey()); - - stateTree = policyPN.getStateTree(); - assertNotNull(stateTree); - assertNotNull(stateTree.getReferencedStateList()); - assertNotNull(stateTree.getReferencedStateSet()); - assertNotNull(stateTree.getNextStates()); - - policyPN.getStateMap().get("SecondState").getStateOutputs().get("stateOutput0") - .setNextState(policyPN.getStateMap().get("state").getKey()); - assertThatThrownBy(() -> policyPN.getStateTree()) - .hasMessageContaining("loop detected in state tree for policy policy:0.0.1 state SecondState, " - + "next state state referenced more than once"); - policyPN.getStateMap().get("SecondState").getStateOutputs().get("stateOutput0") - .setNextState(AxReferenceKey.getNullKey()); - - final AxState thirdState = new AxState(policyPN.getStateMap().get("state")); - thirdState.getKey().setLocalName("ThirdState"); - policyPN.getStateMap().put("ThirdState", thirdState); - policyPN.getStateMap().get("SecondState").getStateOutputs().get("stateOutput0") - .setNextState(thirdState.getKey()); - policyPN.getStateMap().get("ThirdState").getStateOutputs().get("stateOutput0") - .setNextState(AxReferenceKey.getNullKey()); - - stateTree = policyPN.getStateTree(); - - final AxStateOutput ssS0Clone = new AxStateOutput( - policyPN.getStateMap().get("SecondState").getStateOutputs().get("stateOutput0")); - ssS0Clone.getKey().setLocalName("ssS0Clone"); - policyPN.getStateMap().get("SecondState").getStateOutputs().put("ssS0Clone", ssS0Clone); - - assertThatThrownBy(() -> policyPN.getStateTree()) - .hasMessageContaining("loop detected in state tree for policy policy:0.0.1 state SecondState, " - + "next state ThirdState referenced more than once"); - policyPN.getStateMap().get("SecondState").getStateOutputs().remove("ssS0Clone"); - - policyPN.getStateMap().get("state").getStateOutputs().get("stateOutput0").setNextState(secondState.getKey()); - secondState.getStateOutputs().get("stateOutput0").setNextState(thirdState.getKey()); - thirdState.getStateOutputs().get("stateOutput0").setNextState(AxReferenceKey.getNullKey()); - - stateTree = policyPN.getStateTree(); - assertNotNull(stateTree.getState()); - - thirdState.getStateOutputs().get("stateOutput0").setNextState(secondState.getKey()); - - assertThatThrownBy(() -> policyPN.getStateTree()) - .hasMessageContaining("loop detected in state tree for policy policy:0.0.1 state ThirdState, " - + "next state SecondState referenced more than once"); - thirdState.getStateOutputs().get("stateOutput0").setNextState(AxReferenceKey.getNullKey()); - - stateTree = policyPN.getStateTree(); - - final AxStateTree otherStateTree = policyPN.getStateTree(); - assertEquals(0, stateTree.compareTo(otherStateTree)); - - for (final AxStateTree childStateTree : stateTree.getNextStates()) { - assertNotEquals(0, stateTree.compareTo(childStateTree)); - } - - otherStateTree.getNextStates().clear(); - assertNotEquals(0, stateTree.compareTo(otherStateTree)); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java deleted file mode 100644 index b699b5d48..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java +++ /dev/null @@ -1,312 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. - * Modifications Copyright (C) 2021 Bell Canada. 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.policymodel.concepts; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; -import org.onap.policy.apex.model.eventmodel.concepts.AxEvents; -import org.onap.policy.apex.model.eventmodel.concepts.AxField; -import org.onap.policy.apex.model.policymodel.handling.SupportApexPolicyModelCreator; - -/** - * Test policy models. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class PolicyModelTest { - - @Test - public void testPolicyModel() { - assertNotNull(new AxPolicyModel()); - assertNotNull(new AxPolicyModel(new AxArtifactKey())); - assertNotNull(new AxPolicyModel(new AxArtifactKey(), new AxContextSchemas(), new AxKeyInformation(), - new AxEvents(), new AxContextAlbums(), new AxTasks(), new AxPolicies())); - - final AxArtifactKey modelKey = new AxArtifactKey("ModelKey", "0.0.1"); - final AxArtifactKey schemasKey = new AxArtifactKey("SchemasKey", "0.0.1"); - final AxArtifactKey eventsKey = new AxArtifactKey("EventsKey", "0.0.1"); - final AxArtifactKey keyInfoKey = new AxArtifactKey("SchemasKey", "0.0.1"); - final AxArtifactKey albumsKey = new AxArtifactKey("AlbumsKey", "0.0.1"); - final AxArtifactKey tasksKey = new AxArtifactKey("TasksKey", "0.0.1"); - final AxArtifactKey policiesKey = new AxArtifactKey("PoliciesKey", "0.0.1"); - - AxPolicyModel model = new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey), - new AxTasks(tasksKey), new AxPolicies(policiesKey)); - - model.register(); - - assertNotNull(model.getContextModel()); - assertEquals("ModelKey:0.0.1", model.getKeys().get(0).getId()); - - model.clean(); - assertNotNull(model); - assertEquals("AxPolicyModel:(AxPolicyModel:(key=AxArtifactKey:(n", model.toString().substring(0, 50)); - - final AxPolicyModel clonedModel = new AxPolicyModel(model); - - assertNotEquals(0, model.hashCode()); - - // disabling sonar because this code tests the equals() method - assertEquals(model, model); // NOSONAR - assertEquals(model, clonedModel); - assertNotEquals(model, (Object) "Hello"); - assertNotEquals(model, new AxPolicyModel(new AxArtifactKey())); - assertNotEquals(model, new AxPolicyModel(AxArtifactKey.getNullKey(), new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey), - new AxTasks(tasksKey), new AxPolicies(policiesKey))); - assertNotEquals(model, new AxPolicyModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey), - new AxEvents(eventsKey), new AxContextAlbums(albumsKey), new AxTasks(tasksKey), - new AxPolicies(policiesKey))); - assertNotEquals(model, new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), new AxKeyInformation(), - new AxEvents(eventsKey), new AxContextAlbums(albumsKey), new AxTasks(tasksKey), - new AxPolicies(policiesKey))); - assertNotEquals(model, new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(), new AxContextAlbums(albumsKey), - new AxTasks(tasksKey), new AxPolicies(policiesKey))); - assertNotEquals(model, new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(), - new AxTasks(tasksKey), new AxPolicies(policiesKey))); - assertNotEquals(model, new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey), - new AxTasks(), new AxPolicies(policiesKey))); - assertNotEquals(model, new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey), - new AxTasks(tasksKey), new AxPolicies())); - assertEquals(model, new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey), - new AxTasks(tasksKey), new AxPolicies(policiesKey))); - - assertEquals(0, model.compareTo(model)); - assertEquals(0, model.compareTo(clonedModel)); - assertNotEquals(0, model.compareTo(new AxArtifactKey())); - assertNotEquals(0, model.compareTo(new AxPolicyModel(AxArtifactKey.getNullKey(), - new AxContextSchemas(schemasKey), new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), - new AxContextAlbums(albumsKey), new AxTasks(tasksKey), new AxPolicies(policiesKey)))); - assertNotEquals(0, model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(), - new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey), - new AxTasks(tasksKey), new AxPolicies(policiesKey)))); - assertNotEquals(0, - model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(), new AxEvents(eventsKey), new AxContextAlbums(albumsKey), - new AxTasks(tasksKey), new AxPolicies(policiesKey)))); - assertNotEquals(0, model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(), new AxContextAlbums(albumsKey), - new AxTasks(tasksKey), new AxPolicies(policiesKey)))); - assertNotEquals(0, - model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), - new AxContextAlbums(), new AxTasks(tasksKey), new AxPolicies(policiesKey)))); - assertNotEquals(0, - model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), - new AxContextAlbums(albumsKey), new AxTasks(), new AxPolicies(policiesKey)))); - assertNotEquals(0, - model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), - new AxContextAlbums(albumsKey), new AxTasks(tasksKey), new AxPolicies()))); - assertEquals(0, model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey), - new AxTasks(tasksKey), new AxPolicies(policiesKey)))); - - model = new SupportApexPolicyModelCreator().getModel(); - - AxValidationResult result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final AxArtifactKey savedPolicyKey = model.getKey(); - model.setKey(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - model.setKey(savedPolicyKey); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final AxField badField = new AxField(new AxReferenceKey(model.getEvents().get("inEvent").getKey(), "BadField"), - new AxArtifactKey("NonExistantSchema", "0.0.1")); - model.getEvents().get("inEvent").getParameterMap().put(badField.getKey().getLocalName(), badField); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - model.getEvents().get("inEvent").getParameterMap().remove(badField.getKey().getLocalName()); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final AxContextAlbum badAlbum = new AxContextAlbum(new AxArtifactKey("BadAlbum", "0.0.1"), "SomeScope", true, - new AxArtifactKey("NonExistantSchema", "0.0.1")); - model.getAlbums().getAlbumsMap().put(badAlbum.getKey(), badAlbum); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - model.getAlbums().getAlbumsMap().remove(badAlbum.getKey()); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - model.getTasks().get("task").getContextAlbumReferences() - .add(new AxArtifactKey("NonExistantContextAlbum", "0.0.1")); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - model.getTasks().get("task").getContextAlbumReferences() - .remove(new AxArtifactKey("NonExistantContextAlbum", "0.0.1")); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - model.getPolicies().get("policy").getStateMap().get("state").getContextAlbumReferences() - .add(new AxArtifactKey("NonExistantContextAlbum", "0.0.1")); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - model.getPolicies().get("policy").getStateMap().get("state").getContextAlbumReferences() - .remove(new AxArtifactKey("NonExistantContextAlbum", "0.0.1")); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final AxArtifactKey savedTrigger = model.getPolicies().get("policy").getStateMap().get("state").getTrigger(); - model.getPolicies().get("policy").getStateMap().get("state") - .setTrigger(new AxArtifactKey("NonExistantEvent", "0.0.1")); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - model.getPolicies().get("policy").getStateMap().get("state").setTrigger(savedTrigger); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final AxArtifactKey savedDefaultTask = model.getPolicies().get("policy").getStateMap().get("state") - .getDefaultTask(); - model.getPolicies().get("policy").getStateMap().get("state") - .setDefaultTask(new AxArtifactKey("NonExistantTask", "0.0.1")); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - model.getPolicies().get("policy").getStateMap().get("state").setDefaultTask(savedDefaultTask); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - // It is OK not to have TSL - final AxTaskSelectionLogic savedTaskSelectionLogic = model.getPolicies().get("policy").getStateMap() - .get("state").getTaskSelectionLogic(); - model.getPolicies().get("policy").getStateMap().get("state") - .setTaskSelectionLogic(new AxTaskSelectionLogic(AxReferenceKey.getNullKey())); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - model.getPolicies().get("policy").getStateMap().get("state").setTaskSelectionLogic(savedTaskSelectionLogic); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final AxStateOutput badStateOutput = new AxStateOutput( - new AxReferenceKey(model.getPolicies().get("policy").getStateMap().get("state").getKey(), - "BadSO"), - new AxArtifactKey("NonExistantEvent", "0.0.1"), AxReferenceKey.getNullKey()); - model.getPolicies().get("policy").getStateMap().get("state").getStateOutputs() - .put(badStateOutput.getKey().getLocalName(), badStateOutput); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - model.getPolicies().get("policy").getStateMap().get("state").getStateOutputs() - .remove(badStateOutput.getKey().getLocalName()); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final AxStateTaskReference badTaskReference = new AxStateTaskReference( - new AxReferenceKey(model.getPolicies().get("policy").getStateMap().get("state").getKey(), - "NonExistantTask"), - AxStateTaskOutputType.LOGIC, badStateOutput.getKey()); - model.getPolicies().get("policy").getStateMap().get("state").getTaskReferences() - .put(new AxArtifactKey("NonExistantTask", "0.0.1"), badTaskReference); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - badTaskReference.setStateTaskOutputType(AxStateTaskOutputType.DIRECT); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - model.getPolicies().get("policy").getStateMap().get("state").getTaskReferences() - .remove(new AxArtifactKey("NonExistantTask", "0.0.1")); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final AxStateTaskReference tr = model.getPolicies().get("policy").getStateMap().get("state").getTaskReferences() - .get(new AxArtifactKey("task", "0.0.1")); - - final String savedStateOutputName = tr.getOutput().getLocalName(); - tr.getOutput().setLocalName("NonExistantOutput"); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - tr.getOutput().setLocalName(savedStateOutputName); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - final AxStateOutput so = model.getPolicies().get("policy").getStateMap().get("state").getStateOutputs() - .get(savedStateOutputName); - - final AxArtifactKey savedOutEvent = so.getOutgoingEvent(); - so.setOutgoingEvent(new AxArtifactKey("NonExistantEvent", "0.0.1")); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - so.setOutgoingEvent(savedOutEvent); - result = new AxValidationResult(); - result = model.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java deleted file mode 100644 index 049783a7f..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. - * Modifications Copyright (C) 2021 Bell Canada. 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.policymodel.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; - -/** - * Test state outputs. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class StateOutputTest { - - @Test - public void testStateOutput() { - assertNotNull(new AxStateOutput()); - assertNotNull(new AxStateOutput(new AxReferenceKey())); - assertNotNull(new AxStateOutput(new AxReferenceKey(), new AxReferenceKey(), new AxArtifactKey())); - assertNotNull(new AxStateOutput(new AxReferenceKey(), new AxArtifactKey(), new AxReferenceKey())); - - final AxStateOutput so = new AxStateOutput(); - - final AxReferenceKey soKey = new AxReferenceKey("SOStateParent", "0.0.1", "SOState", "SOName"); - final AxReferenceKey nsKey = new AxReferenceKey("SOStateParent", "0.0.1", "NotUsed", "NextStateName"); - final AxArtifactKey eKey = new AxArtifactKey("EventName", "0.0.1"); - - assertThatThrownBy(() -> so.setKey(null)) - .hasMessage("key is marked non-null but is null"); - so.setKey(soKey); - assertEquals("SOStateParent:0.0.1:SOState:SOName", so.getKey().getId()); - assertEquals("SOStateParent:0.0.1:SOState:SOName", so.getKeys().get(0).getId()); - - assertThatThrownBy(() -> so.setNextState(null)) - .hasMessage("nextState is marked non-null but is null"); - so.setNextState(nsKey); - assertEquals(nsKey, so.getNextState()); - - assertThatThrownBy(() -> so.setOutgoingEvent(null)) - .hasMessage("outgoingEvent is marked non-null but is null"); - so.setOutgoingEvent(eKey); - assertEquals(eKey, so.getOutgoingEvent()); - - AxValidationResult result = new AxValidationResult(); - result = so.validate(result); - assertEquals(AxValidationResult.ValidationResult.VALID, result.getValidationResult()); - - so.setKey(AxReferenceKey.getNullKey()); - result = new AxValidationResult(); - result = so.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - so.setKey(soKey); - result = new AxValidationResult(); - result = so.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - so.setOutgoingEvent(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = so.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - so.setOutgoingEvent(eKey); - result = new AxValidationResult(); - result = so.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - so.clean(); - - final AxStateOutput clonedPar = new AxStateOutput(so); - assertEquals("AxStateOutput:(stateKey=AxReferenceKey:(parentKeyN", clonedPar.toString().substring(0, 50)); - - assertNotEquals(0, so.hashCode()); - - // disabling sonar because this code tests the equals() method - assertEquals(so, so); // NOSONAR - assertEquals(so, clonedPar); - assertNotNull(so); - assertNotEquals(so, (Object) "Hello"); - assertNotEquals(so, new AxStateOutput(AxReferenceKey.getNullKey(), eKey, nsKey)); - assertNotEquals(so, new AxStateOutput(soKey, new AxArtifactKey(), nsKey)); - assertNotEquals(so, new AxStateOutput(soKey, eKey, new AxReferenceKey())); - assertEquals(so, new AxStateOutput(soKey, eKey, nsKey)); - - assertEquals(0, so.compareTo(so)); - assertEquals(0, so.compareTo(clonedPar)); - assertNotEquals(0, so.compareTo(new AxArtifactKey())); - assertNotEquals(0, so.compareTo(null)); - assertNotEquals(0, so.compareTo(new AxStateOutput(AxReferenceKey.getNullKey(), eKey, nsKey))); - assertNotEquals(0, so.compareTo(new AxStateOutput(soKey, new AxArtifactKey(), nsKey))); - assertNotEquals(0, so.compareTo(new AxStateOutput(soKey, eKey, new AxReferenceKey()))); - assertEquals(0, so.compareTo(new AxStateOutput(soKey, eKey, nsKey))); - - assertNotNull(so.getKeys()); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java deleted file mode 100644 index 568c47f61..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.policymodel.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; - -/** - * Test state task references. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class StateTaskReferenceTest { - - @Test - public void testStateTaskReference() { - assertNotNull(new AxStateTaskReference()); - assertNotNull(new AxStateTaskReference(new AxReferenceKey())); - assertNotNull(new AxStateTaskReference(new AxReferenceKey(), AxStateTaskOutputType.UNDEFINED, - new AxReferenceKey())); - assertNotNull(new AxStateTaskReference(new AxReferenceKey(), new AxArtifactKey(), - AxStateTaskOutputType.UNDEFINED, new AxReferenceKey())); - - AxStateTaskReference stRef = new AxStateTaskReference(); - - AxReferenceKey stRefKey = new AxReferenceKey("StateParent", "0.0.1", "SOState", "SOName"); - - assertThatThrownBy(() -> stRef.setKey(null)) - .hasMessage("key may not be null"); - stRef.setKey(stRefKey); - assertEquals("StateParent:0.0.1:SOState:SOName", stRef.getKey().getId()); - assertEquals("StateParent:0.0.1:SOState:SOName", stRef.getKeys().get(0).getId()); - - assertThatThrownBy(() -> stRef.setStateTaskOutputType(null)) - .hasMessage("outputType may not be null"); - stRef.setStateTaskOutputType(AxStateTaskOutputType.UNDEFINED); - assertEquals(AxStateTaskOutputType.UNDEFINED, stRef.getStateTaskOutputType()); - stRef.setStateTaskOutputType(AxStateTaskOutputType.DIRECT); - assertEquals(AxStateTaskOutputType.DIRECT, stRef.getStateTaskOutputType()); - stRef.setStateTaskOutputType(AxStateTaskOutputType.LOGIC); - assertEquals(AxStateTaskOutputType.LOGIC, stRef.getStateTaskOutputType()); - - assertThatThrownBy(() -> stRef.setOutput(null)) - .hasMessage("output may not be null"); - AxReferenceKey soKey = new AxReferenceKey("StateParent", "0.0.1", "SOState", "STRef0"); - stRef.setOutput(soKey); - assertEquals(soKey, stRef.getOutput()); - - AxValidationResult result = new AxValidationResult(); - result = stRef.validate(result); - assertEquals(AxValidationResult.ValidationResult.VALID, result.getValidationResult()); - - stRef.setKey(AxReferenceKey.getNullKey()); - result = new AxValidationResult(); - result = stRef.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - stRef.setKey(stRefKey); - result = new AxValidationResult(); - result = stRef.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - stRef.setStateTaskOutputType(AxStateTaskOutputType.UNDEFINED); - result = new AxValidationResult(); - result = stRef.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - stRef.setStateTaskOutputType(AxStateTaskOutputType.LOGIC); - result = new AxValidationResult(); - result = stRef.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - stRef.setOutput(AxReferenceKey.getNullKey()); - result = new AxValidationResult(); - result = stRef.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - stRef.setOutput(soKey); - result = new AxValidationResult(); - result = stRef.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - stRef.clean(); - - AxStateTaskReference clonedStRef = new AxStateTaskReference(stRef); - assertEquals("AxStateTaskReference:(stateKey=AxReferenceKey:(par", clonedStRef.toString().substring(0, 50)); - - assertNotEquals(0, stRef.hashCode()); - - // disabling sonar because this code tests the equals() method - assertEquals(stRef, stRef); // NOSONAR - assertEquals(stRef, clonedStRef); - assertNotNull(stRef); - assertNotEquals(stRef, (Object) "Hello"); - assertNotEquals(stRef, new AxStateTaskReference(AxReferenceKey.getNullKey(), AxStateTaskOutputType.LOGIC, - soKey)); - assertNotEquals(stRef, new AxStateTaskReference(stRefKey, AxStateTaskOutputType.DIRECT, soKey)); - assertNotEquals(stRef, new AxStateTaskReference(stRefKey, AxStateTaskOutputType.LOGIC, new AxReferenceKey())); - assertEquals(stRef, new AxStateTaskReference(stRefKey, AxStateTaskOutputType.LOGIC, soKey)); - - assertNotNull(new AxStateTaskReference(new AxReferenceKey(), new AxArtifactKey(), - AxStateTaskOutputType.UNDEFINED, new AxReferenceKey())); - - assertEquals(0, stRef.compareTo(stRef)); - assertEquals(0, stRef.compareTo(clonedStRef)); - assertNotEquals(0, stRef.compareTo(new AxArtifactKey())); - assertNotEquals(0, stRef.compareTo(null)); - assertNotEquals(0, stRef.compareTo( - new AxStateTaskReference(AxReferenceKey.getNullKey(), AxStateTaskOutputType.LOGIC, soKey))); - assertNotEquals(0, stRef.compareTo(new AxStateTaskReference(stRefKey, AxStateTaskOutputType.DIRECT, soKey))); - assertNotEquals(0, stRef.compareTo( - new AxStateTaskReference(stRefKey, AxStateTaskOutputType.LOGIC, new AxReferenceKey()))); - assertEquals(0, stRef.compareTo(new AxStateTaskReference(stRefKey, AxStateTaskOutputType.LOGIC, soKey))); - - assertNotNull(stRef.getKeys()); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java deleted file mode 100644 index 7fbe78078..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java +++ /dev/null @@ -1,461 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020,2022 Nordix Foundation - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.policymodel.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; - -/** - * Test policy states. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class StateTest { - - @Test - public void testState() { - final TreeMap soEmptyMap = new TreeMap<>(); - final TreeSet ctxtEmptySet = new TreeSet<>(); - final TreeMap sflEmptyMap = new TreeMap<>(); - final TreeMap trEmptyMap = new TreeMap<>(); - - final TreeMap soMap = new TreeMap<>(); - final TreeSet ctxtSet = new TreeSet<>(); - final TreeMap sflMap = new TreeMap<>(); - final TreeMap trMap = new TreeMap<>(); - - assertNotNull(new AxState()); - assertNotNull(new AxState(new AxReferenceKey())); - assertNotNull(new AxState(new AxStateParamsBuilder().key(new AxReferenceKey()).trigger(new AxArtifactKey()) - .stateOutputs(soEmptyMap).contextAlbumReferenceSet(ctxtEmptySet) - .taskSelectionLogic(new AxTaskSelectionLogic()).stateFinalizerLogicMap(sflEmptyMap) - .defaultTask(new AxArtifactKey()).taskReferenceMap(trEmptyMap))); - - final AxState state = new AxState(); - - final AxReferenceKey stateKey = new AxReferenceKey("PolicyName", "0.0.1", "StateName"); - final AxReferenceKey stateKeyNext = new AxReferenceKey("PolicyName", "0.0.1", "StateNameNext"); - final AxReferenceKey stateKeyBad = new AxReferenceKey("PolicyName", "0.0.1", "BadStateName"); - final AxArtifactKey triggerKey = new AxArtifactKey("TriggerName", "0.0.1"); - final AxTaskSelectionLogic tsl = new AxTaskSelectionLogic(stateKey, "TSL", "LogicFlavour", "Some Logic"); - final AxArtifactKey defTaskKey = new AxArtifactKey("TaskName", "0.0.1"); - final AxArtifactKey taskKey1 = new AxArtifactKey("Task1", "0.0.1"); - final AxArtifactKey taskKey2 = new AxArtifactKey("Task2", "0.0.1"); - final AxArtifactKey taskKeyBad = new AxArtifactKey("TaskBad", "0.0.1"); - - assertThatThrownBy(() -> state.setKey(null)) - .hasMessage("key may not be null"); - state.setKey(stateKey); - assertEquals("PolicyName:0.0.1:NULL:StateName", state.getKey().getId()); - assertEquals("PolicyName:0.0.1:NULL:StateName", state.getKeys().get(0).getId()); - - final AxStateOutput so0 = new AxStateOutput(new AxReferenceKey(stateKey, "SO0"), triggerKey, - new AxReferenceKey()); - final AxStateOutput soU = new AxStateOutput(new AxReferenceKey(stateKey, "SOU"), triggerKey, stateKeyNext); - final AxStateOutput soSame = new AxStateOutput(new AxReferenceKey(stateKey, "SOU"), triggerKey, stateKey); - final AxArtifactKey cr0 = new AxArtifactKey("ContextReference", "0.0.1"); - final AxStateFinalizerLogic sfl = new AxStateFinalizerLogic(stateKey, "SFLogicName", "LogicFlavour", "Logic"); - final AxStateFinalizerLogic sflU = new AxStateFinalizerLogic(stateKey, "UnusedSFLogicName", "LogicFlavour", - "Logic"); - final AxStateTaskReference str0 = new AxStateTaskReference(new AxReferenceKey(stateKey, "STR0"), - AxStateTaskOutputType.DIRECT, so0.getKey()); - final AxStateTaskReference str1 = new AxStateTaskReference(new AxReferenceKey(stateKey, "STR1"), - AxStateTaskOutputType.DIRECT, so0.getKey()); - final AxStateTaskReference str2 = new AxStateTaskReference(new AxReferenceKey(stateKey, "STR2"), - AxStateTaskOutputType.LOGIC, sfl.getKey()); - - final AxStateTaskReference strBadState = new AxStateTaskReference(new AxReferenceKey(stateKeyBad, "STR2"), - AxStateTaskOutputType.LOGIC, sfl.getKey()); - final AxStateTaskReference strBadStateOutput = new AxStateTaskReference(new AxReferenceKey(stateKey, "STR2"), - AxStateTaskOutputType.UNDEFINED, sfl.getKey()); - final AxStateTaskReference strBadStateFinalizerLogic = new AxStateTaskReference( - new AxReferenceKey(stateKeyBad, "STR2"), AxStateTaskOutputType.LOGIC, - new AxReferenceKey(stateKey, "SomeSFL")); - - soMap.put(so0.getKey().getLocalName(), so0); - ctxtSet.add(cr0); - sflMap.put(sfl.getKey().getLocalName(), sfl); - trMap.put(defTaskKey.getKey(), str0); - trMap.put(taskKey1.getKey(), str1); - trMap.put(taskKey2.getKey(), str2); - - assertThatThrownBy(() -> state.setTrigger(null)) - .hasMessage("trigger may not be null"); - state.setTrigger(triggerKey); - assertEquals(triggerKey, state.getTrigger()); - - assertThatThrownBy(() -> state.setStateOutputs(null)) - .hasMessage("stateOutputs may not be null"); - state.setStateOutputs(soMap); - assertEquals(soMap, state.getStateOutputs()); - - assertThatThrownBy(() -> state.setContextAlbumReferences(null)) - .hasMessage("contextAlbumReferenceSet may not be null"); - state.setContextAlbumReferences(ctxtSet); - assertEquals(ctxtSet, state.getContextAlbumReferences()); - - assertThatThrownBy(() -> state.setTaskSelectionLogic(null)) - .hasMessage("taskSelectionLogic may not be null"); - assertEquals(false, state.checkSetTaskSelectionLogic()); - state.setTaskSelectionLogic(tsl); - assertEquals(tsl, state.getTaskSelectionLogic()); - assertEquals(true, state.checkSetTaskSelectionLogic()); - - assertThatThrownBy(() -> state.setStateFinalizerLogicMap(null)) - .hasMessage("stateFinalizerLogic may not be null"); - state.setStateFinalizerLogicMap(sflMap); - assertEquals(sflMap, state.getStateFinalizerLogicMap()); - - assertThatThrownBy(() -> state.setDefaultTask(null)) - .hasMessage("defaultTask may not be null"); - state.setDefaultTask(defTaskKey); - assertEquals(defTaskKey, state.getDefaultTask()); - - assertThatThrownBy(() -> state.setTaskReferences(null)) - .hasMessage("taskReferenceMap may not be null"); - state.setTaskReferences(trMap); - assertEquals(trMap, state.getTaskReferences()); - - state.buildReferences(); - assertEquals(state.getKey(), state.getKeys().get(0)); - state.getTaskSelectionLogic().getKey().setLocalName(AxKey.NULL_KEY_NAME); - state.buildReferences(); - assertEquals(state.getKey(), state.getKeys().get(0)); - - final Set stateSet = state.getNextStateSet(); - assertEquals(1, stateSet.size()); - - AxValidationResult result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - state.setKey(AxReferenceKey.getNullKey()); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - state.setKey(stateKey); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - state.setTrigger(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - state.setTrigger(triggerKey); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - state.setStateOutputs(soEmptyMap); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - state.setStateOutputs(soMap); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - so0.getKey().setParentLocalName("Zooby"); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - so0.getKey().setParentLocalName("StateName"); - state.setStateOutputs(soMap); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - soMap.put("NullOutput", null); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - soMap.remove("NullOutput"); - state.setStateOutputs(soMap); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - soMap.put("DupOutput", so0); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - soMap.remove("DupOutput"); - state.setStateOutputs(soMap); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - soMap.put("UnusedOutput", soU); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.OBSERVATION, result.getValidationResult()); - - soMap.remove("UnusedOutput"); - state.setStateOutputs(soMap); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - soMap.put("OutputToSameState", soSame); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - soMap.remove("OutputToSameState"); - state.setStateOutputs(soMap); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - // Empty context reference set is OK - state.setContextAlbumReferences(ctxtEmptySet); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - state.setContextAlbumReferences(ctxtSet); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - ctxtSet.add(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - ctxtSet.remove(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - // Null TSL is OK - state.getTaskSelectionLogic().setKey(AxReferenceKey.getNullKey()); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - state.getTaskSelectionLogic().setKey(new AxReferenceKey(stateKey, "TSL")); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - state.setDefaultTask(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - state.setDefaultTask(defTaskKey); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - state.setTaskReferences(trEmptyMap); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - state.setTaskReferences(trMap); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - trMap.put(AxArtifactKey.getNullKey(), null); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - trMap.remove(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - trMap.put(AxArtifactKey.getNullKey(), str0); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - trMap.remove(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - trMap.put(taskKeyBad, strBadStateOutput); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - trMap.remove(taskKeyBad); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - trMap.put(taskKeyBad, strBadState); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - trMap.remove(taskKeyBad); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - trMap.put(taskKeyBad, strBadStateFinalizerLogic); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - trMap.remove(taskKeyBad); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - state.setDefaultTask(new AxArtifactKey("NonExistantTask", "0.0.1")); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - state.setDefaultTask(defTaskKey); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - sflMap.put("NullSFL", null); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - sflMap.remove("NullSFL"); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - sflMap.put(sflU.getKey().getLocalName(), sflU); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.OBSERVATION, result.getValidationResult()); - - sflMap.remove(sflU.getKey().getLocalName()); - result = new AxValidationResult(); - result = state.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - state.clean(); - - final AxState clonedState = new AxState(state); - assertEquals("AxState:(stateKey=AxReferenceKey:(parent", clonedState.toString().substring(0, 40)); - - assertNotEquals(0, state.hashCode()); - // disabling sonar because this code tests the equals() method - assertEquals(state, state); // NOSONAR - assertEquals(state, clonedState); - assertNotNull(state); - - Object helloObj = "Hello"; - assertNotEquals(state, helloObj); - assertNotEquals(state, new AxState(new AxStateParamsBuilder().key(new AxReferenceKey()).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trMap))); - assertNotEquals(state, new AxState(new AxStateParamsBuilder().key(stateKey).trigger(new AxArtifactKey()) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trMap))); - assertNotEquals(state, new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soEmptyMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trMap))); - assertNotEquals(state, new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtEmptySet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trMap))); - assertNotEquals(state, new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet) - .taskSelectionLogic(new AxTaskSelectionLogic()).stateFinalizerLogicMap(sflMap) - .defaultTask(defTaskKey).taskReferenceMap(trMap))); - assertNotEquals(state, new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflEmptyMap).defaultTask(defTaskKey).taskReferenceMap(trMap))); - assertNotEquals(state, new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflMap).defaultTask(new AxArtifactKey()).taskReferenceMap(trMap))); - assertNotEquals(state, new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trEmptyMap))); - assertEquals(state, new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trMap))); - - assertEquals(0, state.compareTo(state)); - assertEquals(0, state.compareTo(clonedState)); - assertNotEquals(0, state.compareTo(new AxArtifactKey())); - assertNotEquals(0, state.compareTo(null)); - assertNotEquals(0, - state.compareTo(new AxState(new AxStateParamsBuilder().key(new AxReferenceKey()) - .trigger(triggerKey).stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet) - .taskSelectionLogic(tsl).stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey) - .taskReferenceMap(trMap)))); - assertNotEquals(0, state.compareTo(new AxState(new AxStateParamsBuilder().key(stateKey) - .trigger(new AxArtifactKey()).stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet) - .taskSelectionLogic(tsl).stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey) - .taskReferenceMap(trMap)))); - assertNotEquals(0, state.compareTo(new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soEmptyMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trMap)))); - assertNotEquals(0, state.compareTo(new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtEmptySet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trMap)))); - assertNotEquals(0, - state.compareTo(new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet) - .taskSelectionLogic(new AxTaskSelectionLogic()).stateFinalizerLogicMap(sflMap) - .defaultTask(defTaskKey).taskReferenceMap(trMap)))); - assertNotEquals(0, state.compareTo(new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflEmptyMap).defaultTask(defTaskKey).taskReferenceMap(trMap)))); - assertNotEquals(0, state.compareTo(new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflMap).defaultTask(new AxArtifactKey()).taskReferenceMap(trMap)))); - assertNotEquals(0, state.compareTo(new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trEmptyMap)))); - assertEquals(0, state.compareTo(new AxState(new AxStateParamsBuilder().key(stateKey).trigger(triggerKey) - .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) - .stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trMap)))); - - assertNotNull(state.getKeys()); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java deleted file mode 100644 index 4255b495d..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.policymodel.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; - -/** - * Test task parameters. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class TaskParameterTest { - - @Test - public void testTaskParameter() { - assertNotNull(new AxTaskParameter()); - assertNotNull(new AxTaskParameter(new AxReferenceKey())); - assertNotNull(new AxTaskParameter(new AxReferenceKey(), "DefaultValue")); - - final AxTaskParameter par = new AxTaskParameter(); - - final AxReferenceKey parKey = new AxReferenceKey("ParParentName", "0.0.1", "PLN", "LN"); - par.setKey(parKey); - assertEquals("ParParentName:0.0.1:PLN:LN", par.getKey().getId()); - assertEquals("ParParentName:0.0.1:PLN:LN", par.getKeys().get(0).getId()); - - par.setDefaultValue("DefaultValue"); - assertEquals("DefaultValue", par.getTaskParameterValue()); - - AxValidationResult result = new AxValidationResult(); - result = par.validate(result); - assertEquals(AxValidationResult.ValidationResult.VALID, result.getValidationResult()); - - par.setKey(AxReferenceKey.getNullKey()); - result = new AxValidationResult(); - result = par.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - par.setKey(parKey); - result = new AxValidationResult(); - result = par.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - assertThatThrownBy(() -> par.setDefaultValue(null)) - .hasMessage("defaultValue may not be null"); - par.setDefaultValue(""); - result = new AxValidationResult(); - result = par.validate(result); - assertEquals(ValidationResult.WARNING, result.getValidationResult()); - - par.setDefaultValue("DefaultValue"); - result = new AxValidationResult(); - result = par.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - par.clean(); - - final AxTaskParameter clonedPar = new AxTaskParameter(par); - assertEquals("AxTaskParameter:(key=AxReferenceKey:(parentKeyName=ParParentName,parentKeyVersion=0.0.1," - + "parentLocalName=PLN,localName=LN),defaultValue=DefaultValue)", clonedPar.toString()); - - assertNotEquals(0, par.hashCode()); - // disabling sonar because this code tests the equals() method - assertEquals(par, par); // NOSONAR - assertEquals(par, clonedPar); - assertNotNull(par); - assertNotEquals(par, (Object) "Hello"); - assertNotEquals(par, new AxTaskParameter(AxReferenceKey.getNullKey(), "DefaultValue")); - assertNotEquals(par, new AxTaskParameter(parKey, "OtherDefaultValue")); - assertEquals(par, new AxTaskParameter(parKey, "DefaultValue")); - - assertEquals(0, par.compareTo(par)); - assertEquals(0, par.compareTo(clonedPar)); - assertNotEquals(0, par.compareTo(new AxArtifactKey())); - assertNotEquals(0, par.compareTo(null)); - assertNotEquals(0, par.compareTo(new AxTaskParameter(AxReferenceKey.getNullKey(), "DefaultValue"))); - assertNotEquals(0, par.compareTo(new AxTaskParameter(parKey, "OtherDefaultValue"))); - assertEquals(0, par.compareTo(new AxTaskParameter(parKey, "DefaultValue"))); - - assertNotNull(par.getKeys()); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java deleted file mode 100644 index 9c7866c85..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java +++ /dev/null @@ -1,259 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation. - * Modifications Copyright (C) 2021 Bell Canada. 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.policymodel.concepts; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.Map; -import java.util.TreeMap; -import java.util.TreeSet; -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.eventmodel.concepts.AxEvent; - -/** - * Test policy tasks. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class TasksTest { - - @Test - public void testTasks() { - final TreeMap tpEmptyMap = new TreeMap<>(); - final TreeSet ctxtEmptySet = new TreeSet<>(); - - final TreeMap tpMap = new TreeMap<>(); - final TreeSet ctxtSet = new TreeSet<>(); - - assertNotNull(new AxTask()); - assertNotNull(new AxTask(new AxArtifactKey())); - assertNotNull(new AxTask(new AxArtifactKey(), tpMap, ctxtSet, new AxTaskLogic())); - - final AxTask task = new AxTask(); - - final AxArtifactKey taskKey = new AxArtifactKey("TaskName", "0.0.1"); - task.setKey(taskKey); - assertEquals("TaskName:0.0.1", task.getKey().getId()); - assertEquals("TaskName:0.0.1", task.getKeys().get(0).getId()); - - final AxTaskParameter tp0 = new AxTaskParameter(new AxReferenceKey(taskKey, "TP0"), "DefaultValue"); - final AxArtifactKey cr0 = new AxArtifactKey("ContextReference", "0.0.1"); - final AxTaskLogic tl = new AxTaskLogic(taskKey, "LogicName", "LogicFlavour", "Logic"); - - tpMap.put(tp0.getKey().getLocalName(), tp0); - ctxtSet.add(cr0); - - task.setInputEvent(new AxEvent()); - task.setOutputEvents(Map.of("Event", new AxEvent())); - - task.setTaskParameters(tpMap); - assertEquals(tpMap, task.getTaskParameters()); - - task.setContextAlbumReferences(ctxtSet); - assertEquals(ctxtSet, task.getContextAlbumReferences()); - - task.setTaskLogic(tl); - assertEquals(tl, task.getTaskLogic()); - - task.setKey(taskKey); - assertEquals("TaskName:0.0.1", task.getKey().getId()); - assertEquals("TaskName:0.0.1", task.getKeys().get(0).getId()); - - task.buildReferences(); - assertEquals(1, task.getTaskParameters().size()); - - AxValidationResult result = new AxValidationResult(); - result = task.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - task.setKey(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = task.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - task.setKey(taskKey); - result = new AxValidationResult(); - result = task.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - // Empty task parameter map is OK - task.setTaskParameters(tpEmptyMap); - result = new AxValidationResult(); - result = task.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - task.setTaskParameters(tpMap); - result = new AxValidationResult(); - result = task.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - tpMap.put("NullField", null); - result = new AxValidationResult(); - result = task.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - tpMap.remove("NullField"); - result = new AxValidationResult(); - result = task.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - // Empty context reference set is OK - task.setContextAlbumReferences(ctxtEmptySet); - result = new AxValidationResult(); - result = task.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - task.setContextAlbumReferences(ctxtSet); - result = new AxValidationResult(); - result = task.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - ctxtSet.add(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = task.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - ctxtSet.remove(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = task.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - task.clean(); - - final AxTask clonedTask = new AxTask(task); - assertEquals("AxTask:(key=AxArtifactKey:(name=TaskName", clonedTask.toString().substring(0, 40)); - - assertNotEquals(0, task.hashCode()); - // disabling sonar because this code tests the equals() method - assertEquals(task, task); // NOSONAR - assertEquals(task, clonedTask); - assertNotNull(task); - - Object helloObj = "Hello"; - assertNotEquals(task, helloObj); - assertNotEquals(task, new AxTask(new AxArtifactKey(), tpMap, ctxtSet, tl)); - assertEquals(task, new AxTask(taskKey, tpMap, ctxtSet, tl)); - assertNotEquals(task, new AxTask(taskKey, tpEmptyMap, ctxtSet, tl)); - assertNotEquals(task, new AxTask(taskKey, tpMap, ctxtEmptySet, tl)); - assertNotEquals(task, new AxTask(taskKey, tpMap, ctxtSet, new AxTaskLogic())); - assertEquals(task, new AxTask(taskKey, tpMap, ctxtSet, tl)); - - assertEquals(0, task.compareTo(task)); - assertEquals(0, task.compareTo(clonedTask)); - assertNotEquals(0, task.compareTo(new AxArtifactKey())); - assertNotEquals(0, task.compareTo(null)); - assertNotEquals(0, task.compareTo(new AxTask(new AxArtifactKey(), tpMap, ctxtSet, tl))); - assertEquals(0, task.compareTo(new AxTask(taskKey, tpMap, ctxtSet, tl))); - assertNotEquals(0, task.compareTo(new AxTask(taskKey, tpEmptyMap, ctxtSet, tl))); - assertNotEquals(0, task.compareTo(new AxTask(taskKey, tpMap, ctxtEmptySet, tl))); - assertNotEquals(0, task.compareTo(new AxTask(taskKey, tpMap, ctxtSet, new AxTaskLogic()))); - assertEquals(0, task.compareTo(new AxTask(taskKey, tpMap, ctxtSet, tl))); - - assertNotNull(task.getKeys()); - - final AxTasks tasks = new AxTasks(); - result = new AxValidationResult(); - result = tasks.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - // Invalid, no tasks in task map - tasks.setKey(new AxArtifactKey("TasksKey", "0.0.1")); - assertEquals("TasksKey:0.0.1", tasks.getKey().getId()); - - result = new AxValidationResult(); - result = tasks.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - tasks.getTaskMap().put(taskKey, task); - result = new AxValidationResult(); - result = tasks.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - tasks.getTaskMap().put(AxArtifactKey.getNullKey(), null); - result = new AxValidationResult(); - result = tasks.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - tasks.getTaskMap().remove(AxArtifactKey.getNullKey()); - result = new AxValidationResult(); - result = tasks.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - tasks.getTaskMap().put(new AxArtifactKey("NullValueKey", "0.0.1"), null); - result = new AxValidationResult(); - result = tasks.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - tasks.getTaskMap().remove(new AxArtifactKey("NullValueKey", "0.0.1")); - result = new AxValidationResult(); - result = tasks.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - tasks.getTaskMap().put(new AxArtifactKey("BadTaskKey", "0.0.1"), task); - result = new AxValidationResult(); - result = tasks.validate(result); - assertEquals(ValidationResult.INVALID, result.getValidationResult()); - - tasks.getTaskMap().remove(new AxArtifactKey("BadTaskKey", "0.0.1")); - result = new AxValidationResult(); - result = tasks.validate(result); - assertEquals(ValidationResult.VALID, result.getValidationResult()); - - tasks.clean(); - - final AxTasks clonedTasks = new AxTasks(tasks); - assertEquals("AxTasks:(key=AxArtifactKey:(name=TasksKey,version=0.0.1),tas", - clonedTasks.toString().substring(0, 60)); - - assertNotEquals(0, tasks.hashCode()); - - // disabling sonar because this code tests the equals() method - assertEquals(tasks, tasks); // NOSONAR - assertEquals(tasks, clonedTasks); - assertNotNull(tasks); - assertNotEquals(tasks, helloObj); - assertNotEquals(tasks, new AxTasks(new AxArtifactKey())); - - assertEquals(0, tasks.compareTo(tasks)); - assertEquals(0, tasks.compareTo(clonedTasks)); - assertNotEquals(0, tasks.compareTo(null)); - assertNotEquals(0, tasks.compareTo(new AxArtifactKey())); - assertNotEquals(0, tasks.compareTo(new AxTasks(new AxArtifactKey()))); - - clonedTasks.get(taskKey).getTaskLogic().setLogic("SomeChangedLogic"); - assertNotEquals(0, tasks.compareTo(clonedTasks)); - - assertEquals(tasks.getKey(), tasks.getKeys().get(0)); - - assertEquals("TaskName", tasks.get("TaskName").getKey().getName()); - assertEquals("TaskName", tasks.get("TaskName", "0.0.1").getKey().getName()); - assertEquals(1, tasks.getAll("TaskName", "0.0.1").size()); - assertEquals(0, tasks.getAll("NonExistantTaskName").size()); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java deleted file mode 100644 index 48e4f87f9..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020,2022 Nordix Foundation. - * Modifications Copyright (C) 2021 Bell Canada. 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.policymodel.handling; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.basicmodel.test.TestApexModel; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; - -public class ApexPolicyModelTest { - private static final String VALID_MODEL_STRING = "***validation of model successful***"; - - private static final String OBSERVATION_MODEL_STRING = "\n" - + "***observations noted during validation of model***\n" - + "AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL," - + "localName=state):org.onap.policy.apex.model.policymodel.concepts.AxState:OBSERVATION:" - + "state output stateOutput0 is not used directly by any task\n" - + "********************************"; - - private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n" - + "AxArtifactKey:(name=policy,version=0.0.1)" - + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicy:WARNING:state AxReferenceKey:" - + "(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=anotherState) " - + "is not referenced in the policy execution tree\n" + "********************************"; - - private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n" - + "AxArtifactKey:(name=contextAlbum0,version=0.0.1):" - + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined\n" - + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):" - + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined\n" - + "********************************"; - - private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n" - + "AxArtifactKey:(name=policyModel_KeyInfo,version=0.0.1):" - + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:" - + "keyInfoMap may not be empty\n" + "AxArtifactKey:(name=policyModel,version=0.0.1)" - + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:" - + "key information not found for key AxArtifactKey:(name=policyModel,version=0.0.1)\n" - + "AxArtifactKey:(name=policyModel,version=0.0.1)" - + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:" - + "key information not found for key AxArtifactKey:(name=policyModel_KeyInfo,version=0.0.1)\n" - + "AxArtifactKey:(name=policyModel,version=0.0.1)" - + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:" - + "key information not found for key AxArtifactKey:(name=policyModel_Schemas,version=0.0.1)\n" - + "AxArtifactKey:(name=policyModel,version=0.0.1)" - + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:" - + "key information not found for key AxArtifactKey:(name=policyModel_Events,version=0.0.1)\n" - + "AxArtifactKey:(name=policyModel,version=0.0.1)" - + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:" - + "key information not found for key AxArtifactKey:(name=policyModel_Albums,version=0.0.1)\n" - + "AxArtifactKey:(name=policyModel,version=0.0.1)" - + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:" - + "key information not found for key AxArtifactKey:(name=policyModel_Tasks,version=0.0.1)\n" - + "AxArtifactKey:(name=policyModel,version=0.0.1)" - + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:" - + "key information not found for key AxArtifactKey:(name=policyModel_Policies,version=0.0.1)\n" - + "AxArtifactKey:(name=policyModel_Schemas,version=0.0.1):" - + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas:INVALID:" - + "contextSchemas may not be empty\n" + "AxArtifactKey:(name=policyModel_Events,version=0.0.1):" - + "org.onap.policy.apex.model.eventmodel.concepts.AxEvents:INVALID:eventMap may not be empty\n" - + "AxArtifactKey:(name=policyModel_Albums,version=0.0.1):" - + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:OBSERVATION:albums are empty\n" - + "AxArtifactKey:(name=policyModel_Tasks,version=0.0.1)" - + ":org.onap.policy.apex.model.policymodel.concepts.AxTasks:INVALID:taskMap may not be empty\n" - + "AxArtifactKey:(name=policyModel_Policies,version=0.0.1)" - + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicies:INVALID:policyMap may not be empty\n" - + "********************************"; - - TestApexModel testApexModel; - - /** - * Set up the policy model tests. - * - * @throws Exception on setup errors - */ - @Before - public void setup() throws Exception { - testApexModel = new TestApexModel(AxPolicyModel.class, new SupportApexPolicyModelCreator()); - } - - @Test - public void testModelValid() throws Exception { - final AxValidationResult result = testApexModel.testApexModelValid(); - assertEquals(VALID_MODEL_STRING, result.toString()); - } - - @Test - public void testApexModelVaidateObservation() throws Exception { - final AxValidationResult result = testApexModel.testApexModelVaidateObservation(); - assertEquals(OBSERVATION_MODEL_STRING, result.toString()); - } - - @Test - public void testApexModelVaidateWarning() throws Exception { - final AxValidationResult result = testApexModel.testApexModelVaidateWarning(); - assertEquals(WARNING_MODEL_STRING, result.toString()); - } - - @Test - public void testModelVaidateInvalidModel() throws Exception { - final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel(); - assertEquals(INVALID_MODEL_STRING, result.toString()); - } - - @Test - public void testModelVaidateMalstructured() throws Exception { - final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured(); - assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString()); - } - - @Test - public void testModelWriteReadJson() throws Exception { - testApexModel.testApexModelWriteReadJson(); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java deleted file mode 100644 index b1e2d5cbd..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. - * Modifications Copyright (C) 2021 Bell Canada. 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.policymodel.handling; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; - -public class PolicyAnalyserTest { - @Test - public void test() { - final AxPolicyModel apexModel = new SupportApexPolicyModelCreator().getModel(); - - final PolicyAnalyser policyAnalyser = new PolicyAnalyser(); - final PolicyAnalysisResult analysisResult = policyAnalyser.analyse(apexModel); - - assertEquals(EXPECTED_ANALYSIS_RESULT, analysisResult.toString()); - - assertNotNull(analysisResult.getUsedContextAlbums()); - assertNotNull(analysisResult.getUsedContextSchemas()); - assertNotNull(analysisResult.getUsedEvents()); - assertNotNull(analysisResult.getUsedTasks()); - assertNotNull(analysisResult.getUnusedContextAlbums()); - assertNotNull(analysisResult.getUnusedContextSchemas()); - assertNotNull(analysisResult.getUnusedEvents()); - assertNotNull(analysisResult.getUnusedTasks()); - } - - private static final String EXPECTED_ANALYSIS_RESULT = "" + "Context Schema usage\n" + " MapType:0.0.1\n" - + " contextAlbum0:0.0.1\n" + " StringType:0.0.1\n" + " contextAlbum1:0.0.1\n" - + " eventContextItem0:0.0.1\n" + " inEvent:0.0.1\n" + " outEvent0:0.0.1\n" + " outEvent1:0.0.1\n" - + " eventContextItem1:0.0.1\n" + " inEvent:0.0.1\n" + " outEvent0:0.0.1\n" - + " outEvent1:0.0.1\n" + "Context Album usage\n" + " contextAlbum0:0.0.1\n" - + " task:0.0.1\n" + " policy:0.0.1:NULL:state\n" + " contextAlbum1:0.0.1\n" + " task:0.0.1\n" - + " policy:0.0.1:NULL:state\n" + "Event usage\n" + " inEvent:0.0.1\n" + " policy:0.0.1:NULL:state\n" - + " outEvent0:0.0.1\n" + " policy:0.0.1:NULL:state\n" + " outEvent1:0.0.1 (unused)\n" + "Task usage\n" - + " task:0.0.1\n" + " policy:0.0.1:NULL:state\n"; -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReaderTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReaderTest.java deleted file mode 100644 index a2cbe7415..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReaderTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.policymodel.handling; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.policymodel.concepts.AxLogic; - -/** - * Logic reader for policy tests. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class PolicyLogicReaderTest { - - @Test - public void test() { - final AxReferenceKey logicKey = new AxReferenceKey("LogicParent", "0.0.1", "LogicInstanceName"); - - final PolicyLogicReader plReader = new PolicyLogicReader(); - - plReader.setLogicPackage("somewhere.over.the.rainbow"); - assertEquals("somewhere.over.the.rainbow", plReader.getLogicPackage()); - - plReader.setDefaultLogic("FunkyDefaultLogic"); - assertEquals("FunkyDefaultLogic", plReader.getDefaultLogic()); - - assertThatThrownBy(() -> new AxLogic(logicKey, "FunkyLogic", plReader)) - .hasMessage("logic not found for logic " - + "\"somewhere/over/the/rainbow/funkylogic/FunkyDefaultLogic.funkylogic\""); - plReader.setDefaultLogic(null); - assertThatThrownBy(() -> new AxLogic(logicKey, "FunkyLogic", plReader)) - .hasMessage("logic not found for logic " - + "\"somewhere/over/the/rainbow/funkylogic/LogicParentLogicInstanceName.funkylogic\""); - logicKey.setParentLocalName("LogicParentLocalName"); - assertThatThrownBy(() -> new AxLogic(logicKey, "FunkyLogic", plReader)) - .hasMessage("logic not found for logic " + "\"somewhere/over/the/rainbow/funkylogic/" - + "LogicParentLogicParentLocalNameLogicInstanceName.funkylogic\""); - plReader.setLogicPackage("path.to.apex.logic"); - - AxLogic logic = new AxLogic(logicKey, "FunkyLogic", plReader); - assertThat(logic.getLogic()).endsWith("Way out man, this is funky logic!"); - - plReader.setLogicPackage("somewhere.over.the.rainbow"); - plReader.setDefaultLogic("JavaLogic"); - - logic = new AxLogic(logicKey, "JAVA", plReader); - assertEquals("somewhere.over.the.rainbow.java.JavaLogic", logic.getLogic()); - - plReader.setDefaultLogic(null); - - logic = new AxLogic(logicKey, "JAVA", plReader); - assertEquals("somewhere.over.the.rainbow.java.LogicParentLogicParentLocalNameLogicInstanceName", - logic.getLogic()); - - logicKey.setParentLocalName(AxKey.NULL_KEY_NAME); - logic = new AxLogic(logicKey, "JAVA", plReader); - assertEquals("somewhere.over.the.rainbow.java.LogicParentLogicInstanceName", logic.getLogic()); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java deleted file mode 100644 index 691880d6b..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020,2022 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.policymodel.handling; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; -import java.util.UUID; -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.common.utils.resources.TextFileUtils; - -public class PolicyModelComparerTest { - - @Test - public void testPolicyComparer() throws IOException { - final AxPolicyModel leftApexModel = new SupportApexPolicyModelCreator().getModel(); - final AxPolicyModel rightApexModel = new AxPolicyModel(leftApexModel); - - PolicyModelComparer policyModelComparer = new PolicyModelComparer(leftApexModel, rightApexModel); - - String resultString = policyModelComparer.asString(false, false); - String checkString = TextFileUtils - .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt"); - assertEquals(resultString.trim().replaceAll("\\s+", ""), checkString.trim().replaceAll("\\s+", "")); - - resultString = policyModelComparer.asString(false, true); - checkString = TextFileUtils - .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseKeys.txt"); - assertEquals(checkString.trim().replaceAll("\\s+", ""), resultString.trim().replaceAll("\\s+", "")); - - resultString = policyModelComparer.asString(true, false); - checkString = - TextFileUtils.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt"); - assertEquals(checkString.trim().replaceAll("\\s+", ""), resultString.trim().replaceAll("\\s+", "")); - - resultString = policyModelComparer.asString(true, true); - checkString = - TextFileUtils.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt"); - assertEquals(checkString.trim().replaceAll("\\s+", ""), resultString.trim().replaceAll("\\s+", "")); - - final AxKeyInfo leftOnlyKeyInfo = new AxKeyInfo(new AxArtifactKey("LeftOnlyKeyInfo", "0.0.1"), - UUID.fromString("ce9168c-e6df-414f-9646-6da464b6f000"), "Left only key info"); - final AxKeyInfo rightOnlyKeyInfo = new AxKeyInfo(new AxArtifactKey("RightOnlyKeyInfo", "0.0.1"), - UUID.fromString("ce9168c-e6df-414f-9646-6da464b6f001"), "Right only key info"); - - leftApexModel.getKeyInformation().getKeyInfoMap().put(leftOnlyKeyInfo.getKey(), leftOnlyKeyInfo); - rightApexModel.getKeyInformation().getKeyInfoMap().put(rightOnlyKeyInfo.getKey(), rightOnlyKeyInfo); - - leftApexModel.getKeyInformation().getKeyInfoMap().get(new AxArtifactKey("inEvent", "0.0.1")) - .setDescription("Left InEvent Description"); - rightApexModel.getKeyInformation().getKeyInfoMap().get(new AxArtifactKey("inEvent", "0.0.1")) - .setDescription("Right InEvent Description"); - - policyModelComparer = new PolicyModelComparer(leftApexModel, rightApexModel); - - resultString = policyModelComparer.asString(false, false); - checkString = TextFileUtils - .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt"); - assertEquals(resultString.trim().replaceAll("\\s+", ""), checkString.trim().replaceAll("\\s+", "")); - - resultString = policyModelComparer.asString(false, true); - checkString = TextFileUtils - .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt"); - assertEquals(checkString.trim().replaceAll("\\s+", ""), resultString.trim().replaceAll("\\s+", "")); - - resultString = policyModelComparer.asString(true, false); - checkString = TextFileUtils - .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt"); - assertEquals(checkString.trim().replaceAll("\\s+", ""), resultString.trim().replaceAll("\\s+", "")); - - resultString = policyModelComparer.asString(true, true); - checkString = TextFileUtils - .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt"); - assertEquals(checkString.trim().replaceAll("\\s+", ""), resultString.trim().replaceAll("\\s+", "")); - - assertNotNull(policyModelComparer.getContextAlbumComparisonResult()); - assertNotNull(policyModelComparer.getContextAlbumKeyDifference()); - assertNotNull(policyModelComparer.getContextSchemaComparisonResult()); - assertNotNull(policyModelComparer.getContextSchemaKeyDifference()); - assertNotNull(policyModelComparer.getEventComparisonResult()); - assertNotNull(policyModelComparer.getEventKeyDifference()); - assertNotNull(policyModelComparer.getKeyInfoComparisonResult()); - assertNotNull(policyModelComparer.getKeyInformationKeyDifference()); - assertNotNull(policyModelComparer.getPolicyComparisonResult()); - assertNotNull(policyModelComparer.getPolicykeyDifference()); - assertNotNull(policyModelComparer.getPolicyModelsKeyDifference()); - assertNotNull(policyModelComparer.getTaskComparisonResult()); - assertNotNull(policyModelComparer.getTaskKeyDifference()); - - assertNotNull(new PolicyComparer().compare(leftApexModel.getPolicies(), rightApexModel.getPolicies())); - - assertEquals("****** policy map differences ******\n*** context s", - policyModelComparer.toString().substring(0, 50)); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelMergerTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelMergerTest.java deleted file mode 100644 index 2bdf7499f..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelMergerTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2020 Bell Canada. 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.policymodel.handling; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic; - -/** - * Test model merging. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class PolicyModelMergerTest { - - @Test - public void testPolicyModelMerger() throws ApexModelException { - final AxPolicyModel leftPolicyModel = new SupportApexPolicyModelCreator().getModel(); - final AxPolicyModel rightPolicyModel = new SupportApexPolicyModelCreator().getModel(); - - AxPolicyModel mergedPolicyModel = - PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel, false, false); - assertEquals(leftPolicyModel, mergedPolicyModel); - assertEquals(rightPolicyModel, mergedPolicyModel); - - leftPolicyModel.setKey(new AxArtifactKey("LeftPolicyModel", "0.0.1")); - assertThatThrownBy( - () -> PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel, false, false)) - .hasMessageContaining("left model is invalid: \n***validation of model failed"); - - leftPolicyModel.setKey(new AxArtifactKey("LeftPolicyModel", "0.0.1")); - assertNotNull(PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel, false, true, false)); - - leftPolicyModel.getKeyInformation().generateKeyInfo(leftPolicyModel); - mergedPolicyModel = PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel, true, false); - assertNotNull(mergedPolicyModel); - - rightPolicyModel.setKey(new AxArtifactKey("RightPolicyModel", "0.0.1")); - assertThatThrownBy( - () -> PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel, false, false)) - .hasMessageContaining("right model is invalid: \n***validation of model failed"); - - rightPolicyModel.setKey(new AxArtifactKey("RightPolicyModel", "0.0.1")); - assertNotNull(PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel, false, true, false)); - - rightPolicyModel.getKeyInformation().generateKeyInfo(rightPolicyModel); - mergedPolicyModel = PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel, false, false); - assertNotNull(mergedPolicyModel); - - final AxPolicyModel rightPolicyModel2 = new SupportApexPolicyModelCreator().getAnotherModel(); - mergedPolicyModel = PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel2, true, false); - assertNotNull(mergedPolicyModel); - - mergedPolicyModel = PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel2, true, true); - assertNotNull(mergedPolicyModel); - - final AxPolicyModel rightPolicyModel3 = new SupportApexPolicyModelCreator().getModel(); - AxArtifactKey taskArtifactKey = new AxArtifactKey("task", "0.0.1"); - // fail when concepts in two policies have same name but different definition - // here make up some change so as to update the definition of the task in second policy - rightPolicyModel3.getTasks().getTaskMap().get(taskArtifactKey) - .setTaskLogic(new AxTaskLogic(taskArtifactKey, "logicName", "logicFlavour", "logicImpl")); - assertThatThrownBy(() -> PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel3, true, true)) - .hasMessage("\n Same task - task:0.0.1 with different definitions used in different policies"); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java deleted file mode 100644 index 902206d51..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.policymodel.handling; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.Set; -import java.util.TreeSet; -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; - -public class PolicyModelSplitterTest { - @Test - public void test() throws ApexModelException { - final AxPolicyModel apexModel = new SupportApexPolicyModelCreator().getModel(); - - final Set requiredPolicySet = new TreeSet(); - requiredPolicySet.add(new AxArtifactKey("policy", "0.0.1")); - - // There's only one policy so a split of this model on that policy should return the same - // model - AxPolicyModel splitApexModel = null; - splitApexModel = PolicyModelSplitter.getSubPolicyModel(apexModel, requiredPolicySet); - - // The only difference between the models should be that the unused event outEvent1 should - // not be in the split model - apexModel.getEvents().getEventMap().remove(new AxArtifactKey("outEvent1", "0.0.1")); - apexModel.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("outEvent1", "0.0.1")); - assertEquals(apexModel, splitApexModel); - - final Set requiredMissingPolicySet = new TreeSet(); - requiredPolicySet.add(new AxArtifactKey("MissingPolicy", "0.0.1")); - - AxPolicyModel missingSplitApexModel = null; - missingSplitApexModel = PolicyModelSplitter.getSubPolicyModel(apexModel, requiredMissingPolicySet); - assertNotNull(missingSplitApexModel); - - splitApexModel = null; - splitApexModel = PolicyModelSplitter.getSubPolicyModel(apexModel, requiredPolicySet, true); - - // The only difference between the models should be that the unused event outEvent1 should - // not be in the split model - apexModel.getEvents().getEventMap().remove(new AxArtifactKey("outEvent1", "0.0.1")); - apexModel.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("outEvent1", "0.0.1")); - assertEquals(apexModel, splitApexModel); - - // There's only one policy so a split of this model on that policy should return the same - // model - apexModel.getKey().setName("InvalidPolicyModelName"); - assertThatThrownBy(() -> PolicyModelSplitter.getSubPolicyModel(apexModel, requiredPolicySet)) - .hasMessageContaining("source model is invalid: \n***validation of model f"); - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java deleted file mode 100644 index 85040221a..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java +++ /dev/null @@ -1,406 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2021 Bell Canada. 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.policymodel.handling; - -import java.util.Map; -import java.util.UUID; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo; -import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; -import org.onap.policy.apex.model.eventmodel.concepts.AxEvent; -import org.onap.policy.apex.model.eventmodel.concepts.AxEvents; -import org.onap.policy.apex.model.eventmodel.concepts.AxField; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicies; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicy; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.apex.model.policymodel.concepts.AxState; -import org.onap.policy.apex.model.policymodel.concepts.AxStateFinalizerLogic; -import org.onap.policy.apex.model.policymodel.concepts.AxStateOutput; -import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskOutputType; -import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference; -import org.onap.policy.apex.model.policymodel.concepts.AxTask; -import org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic; -import org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter; -import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic; -import org.onap.policy.apex.model.policymodel.concepts.AxTasks; - -/** - * Model creator for model tests. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class SupportApexPolicyModelCreator implements TestApexModelCreator { - - @Override - public AxPolicyModel getModel() { - final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("eventContextItem0", "0.0.1"), "Java", - "java.lang.String"); - final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("eventContextItem1", "0.0.1"), "Java", - "java.lang.Long"); - final AxContextSchema schema2 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java", - "org.onap.policy.apex.model.policymodel.concepts.TestContextItem000"); - final AxContextSchema schema3 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java", - "org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A"); - - final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("ContextSchemas", "0.0.1")); - schemas.getSchemasMap().put(schema0.getKey(), schema0); - schemas.getSchemasMap().put(schema1.getKey(), schema1); - schemas.getSchemasMap().put(schema2.getKey(), schema2); - schemas.getSchemasMap().put(schema3.getKey(), schema3); - - final AxContextAlbum album0 = new AxContextAlbum(new AxArtifactKey("contextAlbum0", "0.0.1"), "APPLICATION", - true, schema3.getKey()); - final AxContextAlbum album1 = new AxContextAlbum(new AxArtifactKey("contextAlbum1", "0.0.1"), "GLOBAL", false, - schema2.getKey()); - - final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1")); - albums.getAlbumsMap().put(album0.getKey(), album0); - albums.getAlbumsMap().put(album1.getKey(), album1); - - final AxEvent inEvent = new AxEvent(new AxArtifactKey("inEvent", "0.0.1"), - "org.onap.policy.apex.model.policymodel.events", "Source", "Target"); - inEvent.getParameterMap().put("IEPAR0", - new AxField(new AxReferenceKey(inEvent.getKey(), "IEPAR0"), schema0.getKey())); - inEvent.getParameterMap().put("IEPAR1", - new AxField(new AxReferenceKey(inEvent.getKey(), "IEPAR1"), schema1.getKey())); - - final AxEvent outEvent0 = new AxEvent(new AxArtifactKey("outEvent0", "0.0.1"), - "org.onap.policy.apex.model.policymodel.events", "Source", "Target"); - outEvent0.getParameterMap().put("OE0PAR0", - new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PAR0"), schema0.getKey())); - outEvent0.getParameterMap().put("OE0PAR1", - new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PAR1"), schema1.getKey())); - outEvent0.getParameterMap().put("OE1PAR0", - new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PAR0"), schema0.getKey())); - outEvent0.getParameterMap().put("OE1PAR1", - new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PAR1"), schema1.getKey())); - - final AxEvent outEvent1 = new AxEvent(new AxArtifactKey("outEvent1", "0.0.1"), - "org.onap.policy.apex.model.policymodel.events", "Source", "Target"); - outEvent1.getParameterMap().put("OE1PAR0", - new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PAR0"), schema0.getKey())); - outEvent1.getParameterMap().put("OE1PAR1", - new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PAR1"), schema1.getKey())); - - final AxEvents events = new AxEvents(new AxArtifactKey("events", "0.0.1")); - events.getEventMap().put(inEvent.getKey(), inEvent); - events.getEventMap().put(outEvent0.getKey(), outEvent0); - events.getEventMap().put(outEvent1.getKey(), outEvent1); - - final AxTask task = new AxTask(new AxArtifactKey("task", "0.0.1")); - - task.setInputEvent(inEvent); - task.setOutputEvents(Map.of(outEvent0.getId(), outEvent0, outEvent1.getId(), outEvent1)); - - final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameter0"), - "Task parameter 0 value"); - final AxTaskParameter taskPar1 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameter1"), - "Task parameter 1 value"); - - task.getTaskParameters().put(taskPar0.getKey().getLocalName(), taskPar0); - task.getTaskParameters().put(taskPar1.getKey().getLocalName(), taskPar1); - task.getContextAlbumReferences().add(album0.getKey()); - task.getContextAlbumReferences().add(album1.getKey()); - - final AxTaskLogic taskLogic = new AxTaskLogic(new AxReferenceKey(task.getKey(), "taskLogic"), "MVEL", - "Some task logic"); - task.setTaskLogic(taskLogic); - - final AxTasks tasks = new AxTasks(new AxArtifactKey("tasks", "0.0.1")); - tasks.getTaskMap().put(task.getKey(), task); - - final AxPolicy policy = new AxPolicy(new AxArtifactKey("policy", "0.0.1")); - policy.setTemplate("FREEFORM"); - - final AxState state = new AxState(new AxReferenceKey(policy.getKey(), "state")); - final AxTaskSelectionLogic taskSelectionLogic = new AxTaskSelectionLogic( - new AxReferenceKey(state.getKey(), "taskSelectionLogic"), "MVEL", "Some TS logic "); - - state.setTrigger(inEvent.getKey()); - state.getContextAlbumReferences().add(album0.getKey()); - state.getContextAlbumReferences().add(album1.getKey()); - state.setTaskSelectionLogic(taskSelectionLogic); - state.setDefaultTask(task.getKey()); - - final AxStateOutput stateOutput0 = new AxStateOutput(new AxReferenceKey(state.getKey(), "stateOutput0"), - outEvent0.getKey(), AxReferenceKey.getNullKey()); - state.getStateOutputs().put(stateOutput0.getKey().getLocalName(), stateOutput0); - - final AxStateTaskReference stateTaskReference = new AxStateTaskReference( - new AxReferenceKey(state.getKey(), task.getKey().getName()), AxStateTaskOutputType.DIRECT, - stateOutput0.getKey()); - - state.getTaskReferences().put(task.getKey(), stateTaskReference); - - policy.getStateMap().put(state.getKey().getLocalName(), state); - policy.setFirstState(state.getKey().getLocalName()); - - final AxPolicies policies = new AxPolicies(new AxArtifactKey("policies", "0.0.1")); - policies.getPolicyMap().put(policy.getKey(), policy); - - final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1")); - final AxPolicyModel policyModel = new AxPolicyModel(new AxArtifactKey("PolicyModel", "0.0.1")); - policyModel.setKeyInformation(keyInformation); - policyModel.setSchemas(schemas); - policyModel.setAlbums(albums); - policyModel.setEvents(events); - policyModel.setTasks(tasks); - policyModel.setPolicies(policies); - policyModel.getKeyInformation().generateKeyInfo(policyModel); - - int uuidIncrementer = 0; - for (final AxKeyInfo keyInfo : policyModel.getKeyInformation().getKeyInfoMap().values()) { - final String uuidString = String.format("ce9168c-e6df-414f-9646-6da464b6e%03d", uuidIncrementer++); - keyInfo.setUuid(UUID.fromString(uuidString)); - } - - final AxValidationResult result = new AxValidationResult(); - policyModel.validate(result); - - return policyModel; - } - - /** - * Gets another policy model. - * - * @return the model - */ - public AxPolicyModel getAnotherModel() { - final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("eventContextItemA0", "0.0.1"), "Java", - "java.lang.String"); - final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("eventContextItemA1", "0.0.1"), "Java", - "java.lang.Long"); - final AxContextSchema schema2 = new AxContextSchema(new AxArtifactKey("StringTypeA", "0.0.1"), "Java", - "org.onap.policy.apex.model.policymodel.concepts.TestContextItem000"); - final AxContextSchema schema3 = new AxContextSchema(new AxArtifactKey("MapTypeA", "0.0.1"), "Java", - "org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A"); - - final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("ContextSchemasA", "0.0.1")); - schemas.getSchemasMap().put(schema0.getKey(), schema0); - schemas.getSchemasMap().put(schema1.getKey(), schema1); - schemas.getSchemasMap().put(schema2.getKey(), schema2); - schemas.getSchemasMap().put(schema3.getKey(), schema3); - - final AxContextAlbum album0 = new AxContextAlbum(new AxArtifactKey("contextAlbumA0", "0.0.1"), "APPLICATION", - true, schema3.getKey()); - final AxContextAlbum album1 = new AxContextAlbum(new AxArtifactKey("contextAlbumA1", "0.0.1"), "GLOBAL", false, - schema2.getKey()); - - final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("contextA", "0.0.1")); - albums.getAlbumsMap().put(album0.getKey(), album0); - albums.getAlbumsMap().put(album1.getKey(), album1); - - final AxEvent inEvent = new AxEvent(new AxArtifactKey("inEventA", "0.0.1"), - "org.onap.policy.apex.model.policymodel.events", "Source", "Target"); - inEvent.getParameterMap().put("IEPARA0", - new AxField(new AxReferenceKey(inEvent.getKey(), "IEPARA0"), schema0.getKey())); - inEvent.getParameterMap().put("IEPARA1", - new AxField(new AxReferenceKey(inEvent.getKey(), "IEPARA1"), schema1.getKey())); - - final AxEvent outEvent0 = new AxEvent(new AxArtifactKey("outEventA0", "0.0.1"), - "org.onap.policy.apex.model.policymodel.events", "Source", "Target"); - outEvent0.getParameterMap().put("OE0PARA0", - new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PARA0"), schema0.getKey())); - outEvent0.getParameterMap().put("OE0PARA1", - new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PARA1"), schema1.getKey())); - outEvent0.getParameterMap().put("OE1PARA0", - new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PARA0"), schema0.getKey())); - outEvent0.getParameterMap().put("OE1PARA1", - new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PARA1"), schema1.getKey())); - - final AxEvent outEvent1 = new AxEvent(new AxArtifactKey("outEventA1", "0.0.1"), - "org.onap.policy.apex.model.policymodel.events", "Source", "Target"); - outEvent1.getParameterMap().put("OE1PARA0", - new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PARA0"), schema0.getKey())); - outEvent1.getParameterMap().put("OE1PARA1", - new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PARA1"), schema1.getKey())); - - final AxEvents events = new AxEvents(new AxArtifactKey("eventsA", "0.0.1")); - events.getEventMap().put(inEvent.getKey(), inEvent); - events.getEventMap().put(outEvent0.getKey(), outEvent0); - events.getEventMap().put(outEvent1.getKey(), outEvent1); - - final AxTask task = new AxTask(new AxArtifactKey("taskA", "0.0.1")); - - task.setInputEvent(inEvent); - task.setOutputEvents(Map.of(outEvent0.getId(), outEvent0, outEvent1.getId(), outEvent1)); - - final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameterA0"), - "Task parameter 0 value"); - final AxTaskParameter taskPar1 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameterA1"), - "Task parameter 1 value"); - - task.getTaskParameters().put(taskPar0.getKey().getLocalName(), taskPar0); - task.getTaskParameters().put(taskPar1.getKey().getLocalName(), taskPar1); - task.getContextAlbumReferences().add(album0.getKey()); - task.getContextAlbumReferences().add(album1.getKey()); - - final AxTaskLogic taskLogic = new AxTaskLogic(new AxReferenceKey(task.getKey(), "taskLogicA"), "MVEL", - "Some task logic"); - task.setTaskLogic(taskLogic); - - final AxTasks tasks = new AxTasks(new AxArtifactKey("tasksA", "0.0.1")); - tasks.getTaskMap().put(task.getKey(), task); - - final AxPolicy policy = new AxPolicy(new AxArtifactKey("policyA", "0.0.1")); - policy.setTemplate("FREEFORM"); - - final AxState state = new AxState(new AxReferenceKey(policy.getKey(), "stateA")); - final AxTaskSelectionLogic taskSelectionLogic = new AxTaskSelectionLogic( - new AxReferenceKey(state.getKey(), "taskSelectionLogicA"), "MVEL", "Some TS logic "); - - state.setTrigger(inEvent.getKey()); - state.getContextAlbumReferences().add(album0.getKey()); - state.getContextAlbumReferences().add(album1.getKey()); - state.setTaskSelectionLogic(taskSelectionLogic); - state.setDefaultTask(task.getKey()); - - final AxStateOutput stateOutput0 = new AxStateOutput(new AxReferenceKey(state.getKey(), "stateOutputA0"), - outEvent0.getKey(), AxReferenceKey.getNullKey()); - state.getStateOutputs().put(stateOutput0.getKey().getLocalName(), stateOutput0); - - final AxStateTaskReference stateTaskReference = new AxStateTaskReference( - new AxReferenceKey(state.getKey(), task.getKey().getName()), AxStateTaskOutputType.DIRECT, - stateOutput0.getKey()); - - state.getTaskReferences().put(task.getKey(), stateTaskReference); - - policy.getStateMap().put(state.getKey().getLocalName(), state); - policy.setFirstState(state.getKey().getLocalName()); - - final AxPolicies policies = new AxPolicies(new AxArtifactKey("policiesA", "0.0.1")); - policies.getPolicyMap().put(policy.getKey(), policy); - - final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKeyA", "0.0.1")); - final AxPolicyModel policyModel = new AxPolicyModel(new AxArtifactKey("PolicyModelA", "0.0.1")); - policyModel.setKeyInformation(keyInformation); - policyModel.setSchemas(schemas); - policyModel.setAlbums(albums); - policyModel.setEvents(events); - policyModel.setTasks(tasks); - policyModel.setPolicies(policies); - policyModel.getKeyInformation().generateKeyInfo(policyModel); - - int uuidIncrementer = 0; - for (final AxKeyInfo keyInfo : policyModel.getKeyInformation().getKeyInfoMap().values()) { - final String uuidString = String.format("ce9168c-e6df-414f-9646-6da464b6e%03d", uuidIncrementer++); - keyInfo.setUuid(UUID.fromString(uuidString)); - } - - final AxValidationResult result = new AxValidationResult(); - policyModel.validate(result); - - return policyModel; - } - - @Override - public AxPolicyModel getMalstructuredModel() { - final AxPolicyModel policyModel = new AxPolicyModel(new AxArtifactKey("policyModel", "0.0.1")); - return policyModel; - } - - @Override - public AxPolicyModel getObservationModel() { - final AxPolicyModel policyModel = getModel(); - - final AxState state = policyModel.getPolicies().get("policy").getStateMap().get("state"); - final AxTask task = policyModel.getTasks().get("task"); - - final AxStateFinalizerLogic stateFinalizerLogic = new AxStateFinalizerLogic( - new AxReferenceKey(state.getKey(), "SFL"), "MVEL", "Some SF logic "); - state.getStateFinalizerLogicMap().put(stateFinalizerLogic.getKey().getLocalName(), stateFinalizerLogic); - final AxStateTaskReference stateTaskReference = new AxStateTaskReference( - new AxReferenceKey(state.getKey(), task.getKey().getName()), AxStateTaskOutputType.LOGIC, - stateFinalizerLogic.getKey()); - - state.getTaskReferences().put(task.getKey(), stateTaskReference); - - return policyModel; - } - - @Override - public AxPolicyModel getWarningModel() { - final AxPolicyModel policyModel = getModel(); - - final AxState anotherState = new AxState( - new AxReferenceKey(new AxArtifactKey("policy", "0.0.1"), "anotherState")); - - final AxEvent inEvent = policyModel.getEvents().getEventMap().get(new AxArtifactKey("inEvent", "0.0.1")); - final AxEvent outEvent0 = policyModel.getEvents().getEventMap().get(new AxArtifactKey("outEvent0", "0.0.1")); - - final AxTask anotherTask = new AxTask(new AxArtifactKey("anotherTask", "0.0.1")); - - anotherTask.setInputEvent(inEvent); - anotherTask.setOutputEvents(Map.of(outEvent0.getId(), outEvent0)); - final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(anotherTask.getKey(), "taskParameter0"), - "Task parameter 0 value"); - final AxTaskParameter taskPar1 = new AxTaskParameter(new AxReferenceKey(anotherTask.getKey(), "taskParameter1"), - "Task parameter 1 value"); - - anotherTask.getTaskParameters().put(taskPar0.getKey().getLocalName(), taskPar0); - anotherTask.getTaskParameters().put(taskPar1.getKey().getLocalName(), taskPar1); - - final AxTaskLogic taskLogic = new AxTaskLogic(new AxReferenceKey(anotherTask.getKey(), "taskLogic"), "MVEL", - "Some task logic"); - anotherTask.setTaskLogic(taskLogic); - policyModel.getTasks().getTaskMap().put(anotherTask.getKey(), anotherTask); - - final AxStateOutput anotherStateOutput0 = new AxStateOutput( - new AxReferenceKey(anotherState.getKey(), "stateOutput0"), outEvent0.getKey(), - AxReferenceKey.getNullKey()); - anotherState.setTrigger(inEvent.getKey()); - anotherState.getStateOutputs().put(anotherStateOutput0.getKey().getLocalName(), anotherStateOutput0); - anotherState.setDefaultTask(anotherTask.getKey()); - final AxStateTaskReference anotherStateTaskReference = new AxStateTaskReference( - new AxReferenceKey(anotherState.getKey(), anotherTask.getKey().getName()), - AxStateTaskOutputType.DIRECT, anotherStateOutput0.getKey()); - anotherState.getTaskReferences().put(anotherTask.getKey(), anotherStateTaskReference); - - policyModel.getPolicies().getPolicyMap().get(new AxArtifactKey("policy", "0.0.1")).getStateMap() - .put(anotherState.getKey().getLocalName(), anotherState); - - policyModel.getKeyInformation().generateKeyInfo(policyModel); - - return policyModel; - } - - @Override - public AxPolicyModel getInvalidModel() { - final AxPolicyModel policyModel = getModel(); - - policyModel.getAlbums().get(new AxArtifactKey("contextAlbum0", "0.0.1")).setScope("UNDEFINED"); - policyModel.getAlbums().get(new AxArtifactKey("contextAlbum1", "0.0.1")).setScope("UNDEFINED"); - - final AxEvent outEvent0 = policyModel.getEvents().get("outEvent0"); - outEvent0.getParameterMap().remove("OE1PAR0"); - outEvent0.getParameterMap().remove("OE1PAR1"); - - return policyModel; - } -} diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/utils/SupportPolicyModelValidator.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/utils/SupportPolicyModelValidator.java deleted file mode 100644 index daff1efa7..000000000 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/utils/SupportPolicyModelValidator.java +++ /dev/null @@ -1,48 +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.policymodel.utils; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; -import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; - -/** - * Main class to run the policy model validator. - */ -public class SupportPolicyModelValidator { - /** - * Main method. - * @param args the command line arguments - * @throws ApexModelException on errors on the apex model - * @throws FileNotFoundException on file find failures - */ - public static void main(final String[] args) throws ApexModelException, FileNotFoundException { - final ApexModelReader policyModelReader = new ApexModelReader( - AxPolicyModel.class); - - final AxPolicyModel policyModel = policyModelReader.read(new FileInputStream(args[0])); - final AxValidationResult result = policyModel.validate(new AxValidationResult()); - System.out.println(result); - } -} diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt deleted file mode 100644 index 4d00394b7..000000000 --- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt +++ /dev/null @@ -1,12 +0,0 @@ -****** policy map differences ****** -*** context schema differences *** -*** event differences *** -*** context album differences *** -*** task differences *** -*** policy differences *** -*** key information differences *** -*** list of keys on left only -key=AxArtifactKey:(name=LeftOnlyKeyInfo,version=0.0.1) -*** list of keys on right only -key=AxArtifactKey:(name=RightOnlyKeyInfo,version=0.0.1) -*********************************** diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt deleted file mode 100644 index 82fecd990..000000000 --- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt +++ /dev/null @@ -1,12 +0,0 @@ -****** policy map differences ****** -*** context schema differences *** -*** event differences *** -*** context album differences *** -*** task differences *** -*** policy differences *** -*** key information differences *** -*** list of keys on left only -key=AxArtifactKey:(name=LeftOnlyKeyInfo,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=LeftOnlyKeyInfo,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6f000,description=Left only key info) -*** list of keys on right only -key=AxArtifactKey:(name=RightOnlyKeyInfo,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=RightOnlyKeyInfo,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6f001,description=Right only key info) -*********************************** diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt deleted file mode 100644 index 38623c32a..000000000 --- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt +++ /dev/null @@ -1,70 +0,0 @@ -****** policy map differences ****** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** context schema differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=MapType,version=0.0.1) -key=AxArtifactKey:(name=StringType,version=0.0.1) -key=AxArtifactKey:(name=eventContextItem0,version=0.0.1) -key=AxArtifactKey:(name=eventContextItem1,version=0.0.1) -*** event differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=inEvent,version=0.0.1) -key=AxArtifactKey:(name=outEvent0,version=0.0.1) -key=AxArtifactKey:(name=outEvent1,version=0.0.1) -*** context album differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=contextAlbum0,version=0.0.1) -key=AxArtifactKey:(name=contextAlbum1,version=0.0.1) -*** task differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=task,version=0.0.1) -*** policy differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=policy,version=0.0.1) -*** key information differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** list of keys on left only -key=AxArtifactKey:(name=LeftOnlyKeyInfo,version=0.0.1) -*** list of keys on right only -key=AxArtifactKey:(name=RightOnlyKeyInfo,version=0.0.1) -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=ContextSchemas,version=0.0.1) -key=AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1) -key=AxArtifactKey:(name=MapType,version=0.0.1) -key=AxArtifactKey:(name=PolicyModel,version=0.0.1) -key=AxArtifactKey:(name=StringType,version=0.0.1) -key=AxArtifactKey:(name=context,version=0.0.1) -key=AxArtifactKey:(name=contextAlbum0,version=0.0.1) -key=AxArtifactKey:(name=contextAlbum1,version=0.0.1) -key=AxArtifactKey:(name=eventContextItem0,version=0.0.1) -key=AxArtifactKey:(name=eventContextItem1,version=0.0.1) -key=AxArtifactKey:(name=events,version=0.0.1) -key=AxArtifactKey:(name=inEvent,version=0.0.1) -key=AxArtifactKey:(name=outEvent0,version=0.0.1) -key=AxArtifactKey:(name=outEvent1,version=0.0.1) -key=AxArtifactKey:(name=policies,version=0.0.1) -key=AxArtifactKey:(name=policy,version=0.0.1) -key=AxArtifactKey:(name=task,version=0.0.1) -key=AxArtifactKey:(name=tasks,version=0.0.1) -*********************************** \ No newline at end of file diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt deleted file mode 100644 index 53cadd979..000000000 --- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt +++ /dev/null @@ -1,70 +0,0 @@ -****** policy map differences ****** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** context schema differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=MapType,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=MapType,version=0.0.1), schemaFlavour=Java, schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A) -key=AxArtifactKey:(name=StringType,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=StringType,version=0.0.1), schemaFlavour=Java, schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem000) -key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=eventContextItem0,version=0.0.1), schemaFlavour=Java, schemaDefinition=java.lang.String) -key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=eventContextItem1,version=0.0.1), schemaFlavour=Java, schemaDefinition=java.lang.Long) -*** event differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=inEvent,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=inEvent,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={IEPAR0=AxField:(key=AxReferenceKey:(parentKeyName=inEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=IEPAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), IEPAR1=AxField:(key=AxReferenceKey:(parentKeyName=inEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=IEPAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},toscaPolicyState=) -key=AxArtifactKey:(name=outEvent0,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=outEvent0,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={OE0PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE0PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE0PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE0PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false), OE1PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},toscaPolicyState=) -key=AxArtifactKey:(name=outEvent1,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=outEvent1,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={OE1PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},toscaPolicyState=) -*** context album differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),value=AxContextAlbum(key=AxArtifactKey:(name=contextAlbum0,version=0.0.1), scope=APPLICATION, isWritable=true, itemSchema=AxArtifactKey:(name=MapType,version=0.0.1)) -key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),value=AxContextAlbum(key=AxArtifactKey:(name=contextAlbum1,version=0.0.1), scope=GLOBAL, isWritable=false, itemSchema=AxArtifactKey:(name=StringType,version=0.0.1)) -*** task differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=task,version=0.0.1),value=AxTask:(key=AxArtifactKey:(name=task,version=0.0.1),taskParameters={taskParameter0=AxTaskParameter:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskParameter0),defaultValue=Task parameter 0 value), taskParameter1=AxTaskParameter:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskParameter1),defaultValue=Task parameter 1 value)},contextAlbumReferenceSet=[AxArtifactKey:(name=contextAlbum0,version=0.0.1), AxArtifactKey:(name=contextAlbum1,version=0.0.1)],taskLogic=AxTaskLogic:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskLogic),logicFlavour=MVEL,logic=Some task logic)) -*** policy differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=policy,version=0.0.1),value=AxPolicy:(key=AxArtifactKey:(name=policy,version=0.0.1),template=FREEFORM,stateMap={state=AxState:(stateKey=AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=state),trigger=AxArtifactKey:(name=inEvent,version=0.0.1),stateOutputs={stateOutput0=AxStateOutput:(stateKey=AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=state,localName=stateOutput0),outgoingEvent=AxArtifactKey:(name=outEvent0,version=0.0.1),nextState=AxReferenceKey:(parentKeyName=NULL,parentKeyVersion=0.0.0,parentLocalName=NULL,localName=NULL))},contextAlbumReferenceSet=[AxArtifactKey:(name=contextAlbum0,version=0.0.1), AxArtifactKey:(name=contextAlbum1,version=0.0.1)],taskSelectionLogic=AxTaskSelectionLogic:(key=AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=state,localName=taskSelectionLogic),logicFlavour=MVEL,logic=Some TS logic),stateFinalizerLogicSet={},defaultTask=AxArtifactKey:(name=task,version=0.0.1),taskReferenceMap={AxArtifactKey:(name=task,version=0.0.1)=AxStateTaskReference:(stateKey=AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=state,localName=task),outputType=DIRECT,output=AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=state,localName=stateOutput0))})},firstState=state) -*** key information differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** list of keys on left only -key=AxArtifactKey:(name=LeftOnlyKeyInfo,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=LeftOnlyKeyInfo,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6f000,description=Left only key info) -*** list of keys on right only -key=AxArtifactKey:(name=RightOnlyKeyInfo,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=RightOnlyKeyInfo,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6f001,description=Right only key info) -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=ContextSchemas,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=ContextSchemas,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e000,description=Generated description for concept referred to by key "ContextSchemas:0.0.1") -key=AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e001,description=Generated description for concept referred to by key "KeyInfoMapKey:0.0.1") -key=AxArtifactKey:(name=MapType,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=MapType,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e002,description=Generated description for concept referred to by key "MapType:0.0.1") -key=AxArtifactKey:(name=PolicyModel,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=PolicyModel,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e003,description=Generated description for concept referred to by key "PolicyModel:0.0.1") -key=AxArtifactKey:(name=StringType,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=StringType,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e004,description=Generated description for concept referred to by key "StringType:0.0.1") -key=AxArtifactKey:(name=context,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=context,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e005,description=Generated description for concept referred to by key "context:0.0.1") -key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=contextAlbum0,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e006,description=Generated description for concept referred to by key "contextAlbum0:0.0.1") -key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=contextAlbum1,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e007,description=Generated description for concept referred to by key "contextAlbum1:0.0.1") -key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=eventContextItem0,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e008,description=Generated description for concept referred to by key "eventContextItem0:0.0.1") -key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=eventContextItem1,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e009,description=Generated description for concept referred to by key "eventContextItem1:0.0.1") -key=AxArtifactKey:(name=events,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=events,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e010,description=Generated description for concept referred to by key "events:0.0.1") -key=AxArtifactKey:(name=inEvent,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=inEvent,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e011,description=Left InEvent Description) -key=AxArtifactKey:(name=outEvent0,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=outEvent0,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e012,description=Generated description for concept referred to by key "outEvent0:0.0.1") -key=AxArtifactKey:(name=outEvent1,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=outEvent1,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e013,description=Generated description for concept referred to by key "outEvent1:0.0.1") -key=AxArtifactKey:(name=policies,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=policies,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e014,description=Generated description for concept referred to by key "policies:0.0.1") -key=AxArtifactKey:(name=policy,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=policy,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e015,description=Generated description for concept referred to by key "policy:0.0.1") -key=AxArtifactKey:(name=task,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=task,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e016,description=Generated description for concept referred to by key "task:0.0.1") -key=AxArtifactKey:(name=tasks,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=tasks,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e017,description=Generated description for concept referred to by key "tasks:0.0.1") -*********************************** \ No newline at end of file diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt deleted file mode 100644 index b9c0decdd..000000000 --- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt +++ /dev/null @@ -1,8 +0,0 @@ -****** policy map differences ****** -*** context schema differences *** -*** event differences *** -*** context album differences *** -*** task differences *** -*** policy differences *** -*** key information differences *** -*********************************** \ No newline at end of file diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseKeys.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseKeys.txt deleted file mode 100644 index 17862e1b1..000000000 --- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseKeys.txt +++ /dev/null @@ -1,69 +0,0 @@ -****** policy map differences ****** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** context schema differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=MapType,version=0.0.1) -key=AxArtifactKey:(name=StringType,version=0.0.1) -key=AxArtifactKey:(name=eventContextItem0,version=0.0.1) -key=AxArtifactKey:(name=eventContextItem1,version=0.0.1) -*** event differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=inEvent,version=0.0.1) -key=AxArtifactKey:(name=outEvent0,version=0.0.1) -key=AxArtifactKey:(name=outEvent1,version=0.0.1) -*** context album differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=contextAlbum0,version=0.0.1) -key=AxArtifactKey:(name=contextAlbum1,version=0.0.1) -*** task differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=task,version=0.0.1) -*** policy differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=policy,version=0.0.1) -*** key information differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=ContextSchemas,version=0.0.1) -key=AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1) -key=AxArtifactKey:(name=MapType,version=0.0.1) -key=AxArtifactKey:(name=PolicyModel,version=0.0.1) -key=AxArtifactKey:(name=StringType,version=0.0.1) -key=AxArtifactKey:(name=context,version=0.0.1) -key=AxArtifactKey:(name=contextAlbum0,version=0.0.1) -key=AxArtifactKey:(name=contextAlbum1,version=0.0.1) -key=AxArtifactKey:(name=eventContextItem0,version=0.0.1) -key=AxArtifactKey:(name=eventContextItem1,version=0.0.1) -key=AxArtifactKey:(name=events,version=0.0.1) -key=AxArtifactKey:(name=inEvent,version=0.0.1) -key=AxArtifactKey:(name=outEvent0,version=0.0.1) -key=AxArtifactKey:(name=outEvent1,version=0.0.1) -key=AxArtifactKey:(name=policies,version=0.0.1) -key=AxArtifactKey:(name=policy,version=0.0.1) -key=AxArtifactKey:(name=task,version=0.0.1) -key=AxArtifactKey:(name=tasks,version=0.0.1) -*********************************** - diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt deleted file mode 100644 index 4e07c5360..000000000 --- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt +++ /dev/null @@ -1,68 +0,0 @@ -****** policy map differences ****** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** context schema differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=MapType,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=MapType,version=0.0.1),schemaFlavour=Java,schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A) -key=AxArtifactKey:(name=StringType,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=StringType,version=0.0.1),schemaFlavour=Java,schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem000) -key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),schemaFlavour=Java,schemaDefinition=java.lang.String) -key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),schemaFlavour=Java,schemaDefinition=java.lang.Long) -*** event differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=inEvent,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=inEvent,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={IEPAR0=AxField:(key=AxReferenceKey:(parentKeyName=inEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=IEPAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), IEPAR1=AxField:(key=AxReferenceKey:(parentKeyName=inEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=IEPAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},toscaPolicyState=) -key=AxArtifactKey:(name=outEvent0,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=outEvent0,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={OE0PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE0PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE0PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE0PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false), OE1PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},toscaPolicyState=) -key=AxArtifactKey:(name=outEvent1,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=outEvent1,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={OE1PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},toscaPolicyState=) -*** context album differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),value=AxContextAlbum(key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),scope=APPLICATION,isWritable=true,itemSchema=AxArtifactKey:(name=MapType,version=0.0.1)) -key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),value=AxContextAlbum(key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),scope=GLOBAL,isWritable=false,itemSchema=AxArtifactKey:(name=StringType,version=0.0.1)) -*** task differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=task,version=0.0.1),value=AxTask:(key=AxArtifactKey:(name=task,version=0.0.1),taskParameters={taskParameter0=AxTaskParameter:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskParameter0),defaultValue=Task parameter 0 value), taskParameter1=AxTaskParameter:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskParameter1),defaultValue=Task parameter 1 value)},contextAlbumReferenceSet=[AxArtifactKey:(name=contextAlbum0,version=0.0.1), AxArtifactKey:(name=contextAlbum1,version=0.0.1)],taskLogic=AxTaskLogic:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskLogic),logicFlavour=MVEL,logic=Some task logic)) -*** policy differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=policy,version=0.0.1),value=AxPolicy:(key=AxArtifactKey:(name=policy,version=0.0.1),template=FREEFORM,stateMap={state=AxState:(stateKey=AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=state),trigger=AxArtifactKey:(name=inEvent,version=0.0.1),stateOutputs={stateOutput0=AxStateOutput:(stateKey=AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=state,localName=stateOutput0),outgoingEvent=AxArtifactKey:(name=outEvent0,version=0.0.1),nextState=AxReferenceKey:(parentKeyName=NULL,parentKeyVersion=0.0.0,parentLocalName=NULL,localName=NULL))},contextAlbumReferenceSet=[AxArtifactKey:(name=contextAlbum0,version=0.0.1), AxArtifactKey:(name=contextAlbum1,version=0.0.1)],taskSelectionLogic=AxTaskSelectionLogic:(key=AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=state,localName=taskSelectionLogic),logicFlavour=MVEL,logic=Some TS logic),stateFinalizerLogicSet={},defaultTask=AxArtifactKey:(name=task,version=0.0.1),taskReferenceMap={AxArtifactKey:(name=task,version=0.0.1)=AxStateTaskReference:(stateKey=AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=state,localName=task),outputType=DIRECT,output=AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=state,localName=stateOutput0))})},firstState=state) -*** key information differences *** -left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1) -*** all left keys in right -*** all right keys in left -*** all values in left and right are identical -*** list of identical entries in left and right -key=AxArtifactKey:(name=ContextSchemas,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=ContextSchemas,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e000,description=Generated description for concept referred to by key "ContextSchemas:0.0.1") -key=AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e001,description=Generated description for concept referred to by key "KeyInfoMapKey:0.0.1") -key=AxArtifactKey:(name=MapType,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=MapType,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e002,description=Generated description for concept referred to by key "MapType:0.0.1") -key=AxArtifactKey:(name=PolicyModel,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=PolicyModel,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e003,description=Generated description for concept referred to by key "PolicyModel:0.0.1") -key=AxArtifactKey:(name=StringType,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=StringType,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e004,description=Generated description for concept referred to by key "StringType:0.0.1") -key=AxArtifactKey:(name=context,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=context,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e005,description=Generated description for concept referred to by key "context:0.0.1") -key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=contextAlbum0,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e006,description=Generated description for concept referred to by key "contextAlbum0:0.0.1") -key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=contextAlbum1,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e007,description=Generated description for concept referred to by key "contextAlbum1:0.0.1") -key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=eventContextItem0,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e008,description=Generated description for concept referred to by key "eventContextItem0:0.0.1") -key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=eventContextItem1,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e009,description=Generated description for concept referred to by key "eventContextItem1:0.0.1") -key=AxArtifactKey:(name=events,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=events,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e010,description=Generated description for concept referred to by key "events:0.0.1") -key=AxArtifactKey:(name=inEvent,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=inEvent,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e011,description=Generated description for concept referred to by key "inEvent:0.0.1") -key=AxArtifactKey:(name=outEvent0,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=outEvent0,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e012,description=Generated description for concept referred to by key "outEvent0:0.0.1") -key=AxArtifactKey:(name=outEvent1,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=outEvent1,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e013,description=Generated description for concept referred to by key "outEvent1:0.0.1") -key=AxArtifactKey:(name=policies,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=policies,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e014,description=Generated description for concept referred to by key "policies:0.0.1") -key=AxArtifactKey:(name=policy,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=policy,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e015,description=Generated description for concept referred to by key "policy:0.0.1") -key=AxArtifactKey:(name=task,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=task,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e016,description=Generated description for concept referred to by key "task:0.0.1") -key=AxArtifactKey:(name=tasks,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=tasks,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e017,description=Generated description for concept referred to by key "tasks:0.0.1") -*********************************** \ No newline at end of file diff --git a/model/policy-model/src/test/resources/logback-test.xml b/model/policy-model/src/test/resources/logback-test.xml deleted file mode 100644 index 2aff4c2e9..000000000 --- a/model/policy-model/src/test/resources/logback-test.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - Apex - - - - - - - %d %contextName [%t] %level %logger{36} - %msg%n - - - - - - - - - - - - - - - - - - - - - ${LOG_DIR}/apex.log - - %d %-5relative [procId=${processId}] [%thread] %-5level - %logger{26} - %msg %n %ex{full} - - - - - ${LOG_DIR}/apex_ctxt.log - - %d %-5relative [procId=${processId}] [%thread] %-5level - %logger{26} - %msg %n %ex{full} - - - - - - - - - - - diff --git a/model/policy-model/src/test/resources/path/to/apex/logic/funkylogic/LogicParentLogicParentLocalNameLogicInstanceName.funkylogic b/model/policy-model/src/test/resources/path/to/apex/logic/funkylogic/LogicParentLogicParentLocalNameLogicInstanceName.funkylogic deleted file mode 100644 index 7ccf3da88..000000000 --- a/model/policy-model/src/test/resources/path/to/apex/logic/funkylogic/LogicParentLogicParentLocalNameLogicInstanceName.funkylogic +++ /dev/null @@ -1,21 +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========================================================= -#------------------------------------------------------------------------------- - -Way out man, this is funky logic! \ No newline at end of file -- cgit 1.2.3-korg