From 1f0322329c388e9bf40f4703d3aff1ce18c229cb Mon Sep 17 00:00:00 2001 From: jhh Date: Thu, 9 Jan 2020 18:29:35 -0600 Subject: Add ControlLoopParams from models repo. This class is only useful under drools applications and eventually will be deprecated to accommodate the new Operational Policy Types. Issue-ID: POLICY-2146 Signed-off-by: jhh Change-Id: I68927cb144a33fac6fe330be15fe60aee32b15a1 --- .../drl/legacy/ControlLoopParamsTest.java | 117 +++++++++++++++++++++ .../controlloop/utils/ControlLoopUtilsTest.java | 4 +- 2 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/drl/legacy/ControlLoopParamsTest.java (limited to 'controlloop/common/eventmanager/src/test/java') diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/drl/legacy/ControlLoopParamsTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/drl/legacy/ControlLoopParamsTest.java new file mode 100644 index 000000000..7bb2c5c96 --- /dev/null +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/drl/legacy/ControlLoopParamsTest.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * Copyright (C) 2020 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.controlloop.drl.legacy; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class ControlLoopParamsTest { + private static final String CONTROL_LOOP_NAME = "c"; + private static final String POLICY_NAME = "m"; + private static final String POLICY_SCOPE = "s"; + private static final String POLICY_VERSION = "v"; + private static final String CONTROL_LOOP_YAML = "y"; + + private ControlLoopParams clp = new ControlLoopParams(); + + /** + * Prepare tests. + */ + @Before + public void setUp() { + clp.setClosedLoopControlName(CONTROL_LOOP_NAME); + clp.setPolicyName(POLICY_NAME); + clp.setPolicyScope(POLICY_SCOPE); + clp.setPolicyVersion(POLICY_VERSION); + clp.setControlLoopYaml(CONTROL_LOOP_YAML); + } + + @Test + public void getClosedLoopControlName() { + assertEquals(CONTROL_LOOP_NAME, clp.getClosedLoopControlName()); + } + + @Test + public void getControlLoopYaml() { + assertEquals(CONTROL_LOOP_YAML, clp.getControlLoopYaml()); + } + + @Test + public void getPolicyName() { + assertEquals(POLICY_NAME, clp.getPolicyName()); + } + + @Test + public void getPolicyScope() { + assertEquals(POLICY_SCOPE, clp.getPolicyScope()); + } + + @Test + public void getPolicyVersion() { + assertEquals(POLICY_VERSION, clp.getPolicyVersion()); + } + + @Test + public void setClosedLoopControlName() { + clp.setClosedLoopControlName(CONTROL_LOOP_NAME.toUpperCase()); + assertEquals(CONTROL_LOOP_NAME.toUpperCase(), clp.getClosedLoopControlName()); + } + + @Test + public void setControlLoopYaml() { + clp.setControlLoopYaml(CONTROL_LOOP_YAML.toUpperCase()); + assertEquals(CONTROL_LOOP_YAML.toUpperCase(), clp.getControlLoopYaml()); + } + + @Test + public void setPolicyName() { + clp.setPolicyName(POLICY_NAME.toUpperCase()); + assertEquals(POLICY_NAME.toUpperCase(), clp.getPolicyName()); + } + + @Test + public void setPolicyScope() { + clp.setPolicyScope(POLICY_SCOPE.toUpperCase()); + assertEquals(POLICY_SCOPE.toUpperCase(), clp.getPolicyScope()); + } + + @Test + public void setPolicyVersion() { + clp.setPolicyVersion(POLICY_VERSION.toUpperCase()); + assertEquals(POLICY_VERSION.toUpperCase(), clp.getPolicyVersion()); + } + + @Test + public void testTwo() { + ControlLoopParams other = new ControlLoopParams(); + other.setClosedLoopControlName(CONTROL_LOOP_NAME); + other.setPolicyName(POLICY_NAME); + other.setPolicyScope(POLICY_SCOPE); + other.setPolicyVersion(POLICY_VERSION); + other.setControlLoopYaml(CONTROL_LOOP_YAML); + + assertEquals(clp, other); + assertEquals(clp.hashCode(), other.hashCode()); + assertEquals(clp.toString(), other.toString()); + } +} \ No newline at end of file diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/utils/ControlLoopUtilsTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/utils/ControlLoopUtilsTest.java index 47907d9c3..ad83b7730 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/utils/ControlLoopUtilsTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/utils/ControlLoopUtilsTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2020 AT&T Intellectual Property. 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. @@ -27,7 +27,7 @@ import java.nio.file.Paths; import java.util.Map; import org.junit.Test; import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.controlloop.params.ControlLoopParams; +import org.onap.policy.controlloop.drl.legacy.ControlLoopParams; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; public class ControlLoopUtilsTest { -- cgit 1.2.3-korg