From 7fc651bc66b013bd54aad31b43abf07f2d3d3bf5 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Thu, 8 Apr 2021 09:39:36 -0400 Subject: Minor clean-up of drools-apps Made the following minor changes: - removed SupportUtil, as it is no longer needed. - modified junit for exception class to use ExceptionsTester - added junit for another exception class Issue-ID: POLICY-3175 Change-Id: I7375e5bdb47a12f48a53e7df50f0924781c1c4b6 Signed-off-by: Jim Hahn --- .../controlloop/ControlLoopExceptionTest.java | 14 +---- .../org/onap/policy/controlloop/SupportUtil.java | 68 ---------------------- .../common/rules/test/SimulatorExceptionTest.java | 32 ++++++++++ 3 files changed, 35 insertions(+), 79 deletions(-) delete mode 100644 controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/SupportUtil.java create mode 100644 controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/SimulatorExceptionTest.java (limited to 'controlloop/common') diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ControlLoopExceptionTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ControlLoopExceptionTest.java index aca8d9655..198af71b2 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ControlLoopExceptionTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ControlLoopExceptionTest.java @@ -3,7 +3,7 @@ * eventmanager * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019-20201 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. @@ -21,21 +21,13 @@ package org.onap.policy.controlloop; -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; import org.junit.Test; +import org.onap.policy.common.utils.test.ExceptionsTester; public class ControlLoopExceptionTest { - private static final String IN_OZ = "In Oz"; - @Test public void testControlLoopException() { - assertNotNull(new ControlLoopException()); - assertNotNull(new ControlLoopException(IN_OZ)); - assertNotNull(new ControlLoopException(new IOException())); - assertNotNull(new ControlLoopException(IN_OZ, new IOException())); - assertNotNull(new ControlLoopException(IN_OZ, new IOException(), false, false)); + new ExceptionsTester().test(ControlLoopException.class); } } 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 deleted file mode 100644 index 05eba6450..000000000 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/SupportUtil.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * util - * ================================================================================ - * Copyright (C) 2017-2019 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 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.models.tosca.authorative.concepts.ToscaPolicy; -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; - } - } - - private SupportUtil() { - // do nothing - } - - /** - * Load yaml into a Pair object. - * - * @param testFile the yaml file - * @return a Pair - * @throws IOException if the file cannot be read - */ - public static Pair loadYaml(String testFile) throws IOException { - 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(ToscaPolicy.class)); - ToscaPolicy obj = yaml.load(contents); - return new Pair<>(obj, contents); - } - } - -} diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/SimulatorExceptionTest.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/SimulatorExceptionTest.java new file mode 100644 index 000000000..0dee6d4be --- /dev/null +++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/SimulatorExceptionTest.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * Copyright (C) 2021 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.common.rules.test; + +import org.junit.Test; +import org.onap.policy.common.utils.test.ExceptionsTester; + +public class SimulatorExceptionTest { + + @Test + public void test() { + new ExceptionsTester().test(SimulatorException.class); + } +} -- cgit 1.2.3-korg