From d697d828df129afa52555e9381d69c45d526c7d6 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Mon, 26 Nov 2018 18:22:40 +0900 Subject: Rename test classes in drools-applications Make test classes name consitence by adding 'Support' or 'Dummy' at start of util or dummy type of test classes Issue-ID: POLICY-1258 Change-Id: Idea946375ee46f14512d4c4bc29e65adaa4d2b37 Signed-off-by: Parshad Patel --- .../org/onap/policy/controlloop/SupportUtil.java | 69 ++++++++++++++++++++++ .../java/org/onap/policy/controlloop/Util.java | 69 ---------------------- .../eventmanager/ControlLoopEventManagerTest.java | 8 +-- .../ControlLoopOperationManagerTest.java | 6 +- 4 files changed, 76 insertions(+), 76 deletions(-) create mode 100644 controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/SupportUtil.java delete mode 100644 controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/Util.java (limited to 'controlloop/common/eventmanager') diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/SupportUtil.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/SupportUtil.java new file mode 100644 index 000000000..39077e3b3 --- /dev/null +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/SupportUtil.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * util + * ================================================================================ + * Copyright (C) 2017-2018 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; + +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +import org.apache.commons.io.IOUtils; +import org.onap.policy.controlloop.policy.ControlLoopPolicy; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.constructor.Constructor; + +public final class SupportUtil { + + public static class Pair { + public final A key; + public final B value; + + public Pair(A key, B value) { + this.key = key; + this.value = value; + } + } + + /** + * Load yaml into a Pair object. + * + * @param testFile the yaml file + * @return a Pair + */ + public static Pair loadYaml(String testFile) { + try (InputStream is = new FileInputStream(new File(testFile))) { + String contents = IOUtils.toString(is, StandardCharsets.UTF_8); + // + // Read the yaml into our Java Object + // + Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class)); + Object obj = yaml.load(contents); + return new Pair((ControlLoopPolicy) obj, contents); + } catch (IOException e) { + fail(e.getLocalizedMessage()); + } + return null; + } + +} diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/Util.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/Util.java deleted file mode 100644 index ced419a04..000000000 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/Util.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * util - * ================================================================================ - * Copyright (C) 2017-2018 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; - -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; - -import org.apache.commons.io.IOUtils; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; - -public final class Util { - - public static class Pair { - public final A key; - public final B value; - - public Pair(A key, B value) { - this.key = key; - this.value = value; - } - } - - /** - * Load yaml into a Pair object. - * - * @param testFile the yaml file - * @return a Pair - */ - public static Pair loadYaml(String testFile) { - try (InputStream is = new FileInputStream(new File(testFile))) { - String contents = IOUtils.toString(is, StandardCharsets.UTF_8); - // - // Read the yaml into our Java Object - // - Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class)); - Object obj = yaml.load(contents); - return new Pair((ControlLoopPolicy) obj, contents); - } catch (IOException e) { - fail(e.getLocalizedMessage()); - } - return null; - } - -} diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java index 1673df3be..49a6258c1 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java @@ -58,7 +58,7 @@ import org.onap.policy.common.utils.io.Serializer; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopException; import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.Util; +import org.onap.policy.controlloop.SupportUtil; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.VirtualControlLoopNotification; import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager.NEW_EVENT_STATUS; @@ -124,7 +124,7 @@ public class ControlLoopEventManagerTest { @Test public void testAaiVnfInfo() { - final Util.Pair pair = Util.loadYaml("src/test/resources/test.yaml"); + final SupportUtil.Pair pair = SupportUtil.loadYaml("src/test/resources/test.yaml"); onset.setClosedLoopControlName(pair.key.getControlLoop().getControlLoopName()); try { AaiGetVnfResponse response = getQueryByVnfId2( @@ -143,7 +143,7 @@ public class ControlLoopEventManagerTest { @Test public void testAaiVnfInfo2() { - final Util.Pair pair = Util.loadYaml("src/test/resources/test.yaml"); + final SupportUtil.Pair pair = SupportUtil.loadYaml("src/test/resources/test.yaml"); onset.setClosedLoopControlName(pair.key.getControlLoop().getControlLoopName()); try { AaiGetVnfResponse response = getQueryByVnfName2( @@ -161,7 +161,7 @@ public class ControlLoopEventManagerTest { @Test public void testAaiVserver() { - final Util.Pair pair = Util.loadYaml("src/test/resources/test.yaml"); + final SupportUtil.Pair pair = SupportUtil.loadYaml("src/test/resources/test.yaml"); onset.setClosedLoopControlName(pair.key.getControlLoop().getControlLoopName()); try { AaiGetVserverResponse response = getQueryByVserverName2( diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java index dae03aa6e..0afe9d2d3 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java @@ -61,7 +61,7 @@ import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopException; import org.onap.policy.controlloop.ControlLoopNotificationType; import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.Util; +import org.onap.policy.controlloop.SupportUtil; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.VirtualControlLoopNotification; import org.onap.policy.controlloop.policy.ControlLoopPolicy; @@ -161,7 +161,7 @@ public class ControlLoopOperationManagerTest { // // Load up the policy // - final Util.Pair pair = Util.loadYaml("src/test/resources/test.yaml"); + final SupportUtil.Pair pair = SupportUtil.loadYaml("src/test/resources/test.yaml"); onset.setClosedLoopControlName(pair.key.getControlLoop().getControlLoopName()); try { // @@ -292,7 +292,7 @@ public class ControlLoopOperationManagerTest { // // Load up the policy // - final Util.Pair pair = Util.loadYaml("src/test/resources/test.yaml"); + final SupportUtil.Pair pair = SupportUtil.loadYaml("src/test/resources/test.yaml"); onset.setClosedLoopControlName(pair.key.getControlLoop().getControlLoopName()); try { // -- cgit 1.2.3-korg