Remove exception test helpers from policy-common 47/142947/3
authordanielhanrahan <daniel.hanrahan@est.tech>
Fri, 16 Jan 2026 19:19:18 +0000 (19:19 +0000)
committerdanielhanrahan <daniel.hanrahan@est.tech>
Mon, 19 Jan 2026 15:32:39 +0000 (15:32 +0000)
Issue-ID: POLICY-5532
Change-Id: I4ecad091a0de354ae2d321a4c2a9727e0192994d
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
policy-common/src/main/java/org/onap/policy/common/message/bus/event/client/TopicSinkClientException.java
policy-common/src/main/java/org/onap/policy/common/utils/test/ConstructionError.java [deleted file]
policy-common/src/main/java/org/onap/policy/common/utils/test/ErrorsTester.java [deleted file]
policy-common/src/main/java/org/onap/policy/common/utils/test/ExceptionsTester.java [deleted file]
policy-common/src/main/java/org/onap/policy/common/utils/test/ThrowablesTester.java [deleted file]
policy-common/src/test/java/org/onap/policy/common/message/bus/event/client/TopicClientExceptionTest.java
policy-common/src/test/java/org/onap/policy/common/utils/test/ConstructionErrorTest.java [deleted file]
policy-common/src/test/java/org/onap/policy/common/utils/test/ErrorsTesterTest.java [deleted file]
policy-common/src/test/java/org/onap/policy/common/utils/test/ExceptionsTesterTest.java [deleted file]
policy-common/src/test/java/org/onap/policy/common/utils/test/ThrowablesTesterTest.java [deleted file]

index fad5e11..1f618a7 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019, 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2026 OpenInfra Foundation Europe. 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.
@@ -30,25 +30,8 @@ public class TopicSinkClientException extends Exception {
     @Serial
     private static final long serialVersionUID = 1L;
 
-    public TopicSinkClientException() {
-        super();
-    }
-
     public TopicSinkClientException(final String message) {
         super(message);
     }
 
-    public TopicSinkClientException(final Throwable cause) {
-        super(cause);
-    }
-
-    public TopicSinkClientException(final String message, final Throwable cause) {
-        super(message, cause);
-    }
-
-    public TopicSinkClientException(final String message, final Throwable cause, final boolean enableSuppression,
-            final boolean writableStackTrace) {
-        super(message, cause, enableSuppression, writableStackTrace);
-    }
-
 }
diff --git a/policy-common/src/main/java/org/onap/policy/common/utils/test/ConstructionError.java b/policy-common/src/main/java/org/onap/policy/common/utils/test/ConstructionError.java
deleted file mode 100644 (file)
index d343857..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * ============LICENSE_START====================================================
- * Common Utils-Test
- * =============================================================================
- * Copyright (C) 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.common.utils.test;
-
-/**
- * An error that occurred while trying to construct an object for a junit test.
- */
-public class ConstructionError extends AssertionError {
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * Constructor.
-     */
-    public ConstructionError() {
-        super();
-    }
-
-    /**
-     * Constructor.
-     * 
-     * @param message denotes the error message
-     */
-    public ConstructionError(final String message) {
-        super(message);
-    }
-
-    /**
-     * Constructor.
-     * 
-     * @param cause denotes the cause of the error
-     */
-    public ConstructionError(final Throwable cause) {
-        super(cause);
-    }
-
-    /**
-     * Constructor.
-     * 
-     * @param message denotes the error message
-     * @param cause denotes the cause of the error
-     */
-    public ConstructionError(final String message, final Throwable cause) {
-        super(message, cause);
-    }
-
-}
diff --git a/policy-common/src/main/java/org/onap/policy/common/utils/test/ErrorsTester.java b/policy-common/src/main/java/org/onap/policy/common/utils/test/ErrorsTester.java
deleted file mode 100644 (file)
index ab876b6..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * ============LICENSE_START====================================================
- * Common Utils-Test
- * =============================================================================
- * Copyright (C) 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.common.utils.test;
-
-/**
- * Used to test various Error subclasses. Uses reflection to identify the
- * constructors that the subclass supports.
- */
-public class ErrorsTester extends ThrowablesTester {
-
-    /**
-     * Runs tests, on an Error subclass, for all of the standard
-     * constructors.If the Error subclass does not support a given
-     * type of constructor, then it skips that test.
-     * Does <i>not</i> throw an exception if no standard constructors
-     * are found.
-     *
-     * @param claz subclass to be tested
-     * @param <T> this needs to be declared
-     *
-     * @return the number of constructors that were found/tested
-     * @throws ConstructionError
-     *             if the Error subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public <T extends Error> int testAllError(final Class<T> claz) {
-        return testAllThrowable(claz);
-    }
-}
diff --git a/policy-common/src/main/java/org/onap/policy/common/utils/test/ExceptionsTester.java b/policy-common/src/main/java/org/onap/policy/common/utils/test/ExceptionsTester.java
deleted file mode 100644 (file)
index 34dc568..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * ============LICENSE_START====================================================
- * Common Utils-Test
- * =============================================================================
- * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 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.
- * ============LICENSE_END======================================================
- */
-
-package org.onap.policy.common.utils.test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.lang.reflect.Constructor;
-
-/**
- * Used to test various Exception subclasses. Uses reflection to identify the
- * constructors that the subclass supports.
- */
-public class ExceptionsTester extends ThrowablesTester {
-
-    /**
-     * Runs tests, on an Exception subclass, for all of the standard
-     * constructors. If the Exception subclass does not support a given
-     * type of constructor, then it skips that test.
-     *
-     * @param claz subclass to be tested
-     * @param <T> Type of the class
-     *
-     * @return the number of constructors that were found/tested
-     * @throws ConstructionError
-     *             if the Exception subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public <T extends Exception> int test(final Class<T> claz) {
-        int ncons = testAllException(claz);
-
-        assertTrue(ncons > 0);
-
-        return ncons;
-    }
-
-    /**
-     * Runs tests, on an Exception subclass, for all of the standard
-     * constructors. If the Exception subclass does not support a given
-     * type of constructor, then it skips that test. Does <i>not</i> throw
-     * an exception if no standard constructors are found.
-     *
-     * @param claz subclass to be tested
-     * @param <T> type of the class
-     *
-     * @return the number of constructors that were found/tested
-     * @throws ConstructionError
-     *             if the Exception subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public <T extends Exception> int testAllException(final Class<T> claz) {
-        var ncons = 0;
-
-        ncons += testAllThrowable(claz);
-        ncons += testException(claz);
-        ncons += testStringException(claz);
-        ncons += testStringExceptionBooleanBoolean(claz);
-
-        return ncons;
-    }
-
-    /**
-     * Tests exceptions created via the constructor that takes just an
-     * Exception. Verifies that:
-     * <ul>
-     * <li><i>toString()</i> returns a non-null value</li>
-     * <li><i>getMessage()</i> returns the cause's message</li>
-     * <li><i>getCause()</i> returns the original cause passed to the
-     * constructor</li>
-     * </ul>
-     *
-     * <p>If the Exception subclass does not support this type of constructor,
-     * then this method simply returns.
-     *
-     * @param claz subclass to be tested
-     * @param <T> Type of the class
-     *
-     * @return {@code 1}, if the subclass supports this type of constructor,
-     *         {@code 0} otherwise
-     * @throws ConstructionError
-     *             if the Exception subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public <T extends Exception> int testException(final Class<T> claz) {
-        Constructor<T> cons = getConstructor(claz, "exception",
-                        Exception.class);
-
-        if (cons == null) {
-            return 0;
-        }
-
-        var cause = new Exception(EXPECTED_EXCEPTION_MSG);
-        var ex = newInstance(cons, cause);
-
-        assertNotNull(ex.toString());
-        assertEquals(ex.getMessage(), ex.getMessage());
-        assertEquals(cause, ex.getCause());
-
-        return 1;
-    }
-
-    /**
-     * Tests exceptions created via the constructor that takes a String
-     * and an Exception. Verifies that:
-     * <ul>
-     * <li><i>toString()</i> returns a non-null value</li>
-     * <li><i>getMessage()</i> returns the original message passed to
-     * the constructor</li>
-     * <li><i>getCause()</i> returns the original cause passed to the
-     * constructor</li>
-     * </ul>
-     *
-     * <p>If the Exception subclass does not support this type of
-     * constructor, then this method simply returns.
-     *
-     * @param claz subclass to be tested
-     * @param <T> Type of the class
-     *
-     * @return {@code 1}, if the subclass supports this type of constructor,
-     *         {@code 0} otherwise
-     * @throws ConstructionError
-     *             if the Exception subclass cannot be constructed
-     */
-    public <T extends Exception> int testStringException(
-                    final Class<T> claz) {
-        Constructor<T> cons = getConstructor(claz, "string-exception",
-                        String.class, Exception.class);
-        if (cons == null) {
-            return 0;
-        }
-
-        var cause = new Exception(EXPECTED_EXCEPTION_MSG);
-        var ex = newInstance(cons, "world", cause);
-
-        assertNotNull(ex.toString());
-        assertEquals("world", ex.getMessage());
-        assertEquals(cause, ex.getCause());
-
-        return 1;
-    }
-
-    /**
-     * Tests exceptions created via the constructor that takes a String, an
-     * Exception, and two booleans. Verifies that:
-     * <ul>
-     * <li><i>toString()</i> returns a non-null value</li>
-     * <li><i>getMessage()</i> returns the original message passed to the
-     * constructor</li>
-     * <li><i>getCause()</i> returns the original cause passed to the
-     * constructor</li>
-     * <li>suppressed exceptions can be added, if enabled</li>
-     * <li>the stack trace can be added, if enabled</li>
-     * </ul>
-     *
-     * <p>If the Exception subclass does not support this type of constructor,
-     * then this method simply returns.
-     *
-     * @param claz subclass to be tested
-     * @param <T> Type of the class
-     *
-     * @return {@code 1}, if the subclass supports this type of constructor,
-     *         {@code 0} otherwise
-     * @throws ConstructionError
-     *             if the Exception subclass cannot be constructed
-     */
-    public <T extends Exception> int testStringExceptionBooleanBoolean(
-                    final Class<T> claz) {
-
-        Constructor<T> cons = getConstructor(claz,
-                        "string-exception-flags", String.class, Exception.class,
-                        Boolean.TYPE, Boolean.TYPE);
-
-        if (cons == null) {
-            return 0;
-        }
-
-        // test each combination of "message" and "cause"
-        testMessageCauseCombos(cons);
-
-        // test each combination of the boolean flags
-        testFlagCombos(cons);
-
-        return 1;
-    }
-}
diff --git a/policy-common/src/main/java/org/onap/policy/common/utils/test/ThrowablesTester.java b/policy-common/src/main/java/org/onap/policy/common/utils/test/ThrowablesTester.java
deleted file mode 100644 (file)
index 62584c7..0000000
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- * ============LICENSE_START====================================================
- * Common Utils-Test
- * =============================================================================
- * Copyright (C) 2018, 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 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.
- * ============LICENSE_END======================================================
- */
-
-package org.onap.policy.common.utils.test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Used to test various Throwable subclasses. Uses reflection to identify the
- * constructors that the subclass supports.
- */
-public class ThrowablesTester {
-
-    private static Logger logger =
-                    LoggerFactory.getLogger(ThrowablesTester.class);
-
-    public static final String EXPECTED_EXCEPTION_MSG =
-                    "expected exception";
-    private static final String EXPECTED_SUPPRESSED_EXCEPTION_MSG =
-                    "expected suppressed exception";
-
-    /**
-     * Passed as a "cause" to constructors.
-     */
-    public static final Exception CAUSE =
-                    new Exception(EXPECTED_EXCEPTION_MSG);
-
-    /**
-     * Passed to new objects via the <i>addSuppressed()</i> method..
-     */
-    public static final Throwable SUPPRESSED =
-                    new Throwable(EXPECTED_SUPPRESSED_EXCEPTION_MSG);
-
-    /**
-     * Runs tests, on an Throwable subclass, for all of the
-     * standard constructors. If the Throwable subclass does
-     * not support a given type of constructor, then it skips
-     * that test. Does <i>not</i> throw an exception if no
-     * standard constructors are found.
-     *
-     * @param claz subclass to be tested
-     * @param <T> To be defined
-     * @return the number of constructors that were found/tested
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public final <T extends Throwable> int testAllThrowable(
-                    final Class<T> claz) {
-        var ncons = 0;
-
-        ncons += testDefault(claz);
-        ncons += testString(claz);
-        ncons += testThrowable(claz);
-        ncons += testStringThrowable(claz);
-        ncons += testStringThrowableBooleanBoolean(claz);
-
-        return ncons;
-    }
-
-    /**
-     * Tests Throwable objects created via the default constructor. Verifies
-     * that:
-     * <ul>
-     * <li><i>toString()</i> returns a non-null value</li>
-     * <li><i>getMessage()</i> returns null</li>
-     * <li><i>getCause()</i> returns null</li>
-     * </ul>
-     *
-     * <p>If the Throwable subclass does not support this type of
-     * constructor, then this method simply returns.
-     *
-     * @param claz subclass to be tested
-     * @param <T> to be defined
-     * @return {@code 1}, if the subclass supports this type of constructor,
-     *         {@code 0} otherwise
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public final <T extends Throwable> int testDefault(
-                    final Class<T> claz) {
-        Constructor<T> cons = getConstructor(claz, "default");
-        if (cons == null) {
-            return 0;
-        }
-
-        var ex = newInstance(cons);
-
-        assertNotNull(ex.toString());
-        assertNull(ex.getMessage());
-        assertNull(ex.getCause());
-
-        return 1;
-    }
-
-    /**
-     * Tests Throwable objects created via the constructor that takes just a
-     * String. Verifies that:
-     * <ul>
-     * <li><i>toString()</i> returns a non-null value</li>
-     * <li><i>getMessage()</i> returns the original message passed to the
-     * constructor</li>
-     * <li><i>getCause()</i> returns null</li>
-     * </ul>
-     *
-     * <p>If the Throwable subclass does not support this type of constructor,
-     * then this method simply returns.
-     *
-     * @param claz
-     *            subclass to be tested
-     * @param <T> to be defined
-     * @return {@code 1}, if the subclass supports this type of constructor,
-     *         {@code 0} otherwise
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public final <T extends Throwable> int testString(final Class<T> claz) {
-        Constructor<T> cons = getConstructor(claz, "string",
-                        String.class);
-        if (cons == null) {
-            return 0;
-        }
-
-        var ex = newInstance(cons, "hello");
-
-        assertNotNull(ex.toString());
-        assertEquals("hello", ex.getMessage());
-        assertNull(ex.getCause());
-
-        return 1;
-    }
-
-    /**
-     * Tests Throwable objects created via the constructor that takes just a
-     * Throwable. Verifies that:
-     * <ul>
-     * <li><i>toString()</i> returns a non-null value</li>
-     * <li><i>getMessage()</i> returns the cause's message</li>
-     * <li><i>getCause()</i> returns the original cause passed to the
-     * constructor</li>
-     * </ul>
-     *
-     * <p>If the Throwable subclass does not support this type of constructor,
-     * then this method simply returns.
-     *
-     * @param claz
-     *            subclass to be tested
-     * @param <T> to be defined
-     * @return {@code 1}, if the subclass supports this type of constructor,
-     *         {@code 0} otherwise
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public final <T extends Throwable> int testThrowable(
-                    final Class<T> claz) {
-        Constructor<T> cons = getConstructor(claz, "throwable",
-                        Throwable.class);
-        if (cons == null) {
-            return 0;
-        }
-
-        var ex = newInstance(cons, CAUSE);
-
-        assertEquals(ex.getMessage(), ex.getMessage());
-        assertNotNull(ex.toString());
-        assertEquals(CAUSE, ex.getCause());
-
-        return 1;
-    }
-
-    /**
-     * Tests Throwable objects created via the constructor that takes
-     * a String and a Throwable. Verifies that:
-     * <ul>
-     * <li><i>toString()</i> returns a non-null value</li>
-     * <li><i>getMessage()</i> returns the original message passed to the
-     * constructor</li>
-     * <li><i>getCause()</i> returns the original cause passed to the
-     * constructor</li>
-     * </ul>
-     *
-     * <p>If the Throwable subclass does not support this type of constructor,
-     * then this method simply returns.
-     *
-     * @param claz subclass to be tested
-     * @param <T> to be defined
-     * @return {@code 1}, if the subclass supports this type of constructor,
-     *         {@code 0} otherwise
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public final <T extends Throwable> int testStringThrowable(
-                    final Class<T> claz) {
-        Constructor<T> cons = getConstructor(claz, "string-throwable",
-                        String.class, Throwable.class);
-        if (cons == null) {
-            return 0;
-        }
-
-        var ex = newInstance(cons, "world", CAUSE);
-
-        assertNotNull(ex.toString());
-        assertEquals("world", ex.getMessage());
-        assertEquals(CAUSE, ex.getCause());
-
-        return 1;
-    }
-
-    /**
-     * Tests Throwable objects created via the constructor that takes
-     * a String, a Throwable, and two booleans. Verifies that:
-     * <ul>
-     * <li><i>toString()</i> returns a non-null value</li>
-     * <li><i>getMessage()</i> returns the original message passed to the
-     * constructor</li>
-     * <li><i>getCause()</i> returns the original cause passed to the
-     * constructor</li>
-     * <li>suppressed exceptions can be added, if enabled</li>
-     * <li>the stack trace can be added, if enabled</li>
-     * </ul>
-     *
-     * <p>If the Throwable subclass does not support this type of constructor,
-     * then this method simply returns.
-     *
-     * @param claz
-     *            subclass to be tested
-     * @param <T> to be defined
-     * @return {@code 1}, if the subclass supports this type of constructor,
-     *         {@code 0} otherwise
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public final <T extends Throwable> int
-        testStringThrowableBooleanBoolean(
-                    final Class<T> claz) {
-        Constructor<T> cons = getConstructor(claz,
-                        "string-throwable-flags",
-                        String.class, Throwable.class,
-                        Boolean.TYPE, Boolean.TYPE);
-        if (cons == null) {
-            return 0;
-        }
-
-        // test each combination of "message" and "cause"
-        testMessageCauseCombos(cons);
-
-        // test each combination of the boolean flags
-        testSuppressStack(cons);
-        testSuppressNoStack(cons);
-        testNoSuppressStack(cons);
-        testNoSuppressNoStack(cons);
-
-        return 1;
-    }
-
-    /**
-     * Tests each combination of values for the "message" and the "cause"
-     * when using the constructor that takes a String,
-     * a Throwable/Exception, and two booleans. Verifies that expected
-     * values are returned
-     * <ul>
-     * <i>toString()</i>,
-     * <i>getMessage()</i>, and <i>getCause()</i>.
-     * </ul>
-     *
-     * @param cons
-     *            constructor to be invoked
-     * @param <T> to be defined
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public final <T extends Throwable> void testMessageCauseCombos(
-                    final Constructor<T> cons) {
-        T ex;
-
-        ex = newInstance(cons, null, null, true, true);
-        assertNotNull(ex.toString());
-        assertNull(ex.getMessage());
-        assertNull(ex.getCause());
-
-        ex = newInstance(cons, "abc", null, true, true);
-        assertNotNull(ex.toString());
-        assertEquals("abc", ex.getMessage());
-        assertNull(ex.getCause());
-
-        ex = newInstance(cons, null, CAUSE, true, true);
-        assertNotNull(ex.toString());
-        assertNull(ex.getMessage());
-        assertEquals(CAUSE, ex.getCause());
-
-        ex = newInstance(cons, "xyz", CAUSE, true, true);
-        assertNotNull(ex.toString());
-        assertEquals("xyz", ex.getMessage());
-        assertEquals(CAUSE, ex.getCause());
-    }
-
-    /**
-     * Tests each combination of values for the "message" and the
-     * "cause" when using the constructor that takes a String,
-     * a Throwable/Exception, and two booleans. Verifies that
-     * expected values are returned by
-     * <ul>
-     * <i>toString()</i>,
-     * <i>getMessage()</i>, and <i>getCause()</i>.
-     * </ul>
-     *
-     * @param cons
-     *            constructor to be invoked
-     * @param <T> to be defined
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public final <T extends Throwable> void testFlagCombos(
-                    final Constructor<T> cons) {
-        testSuppressStack(cons);
-        testSuppressNoStack(cons);
-        testNoSuppressStack(cons);
-        testNoSuppressNoStack(cons);
-    }
-
-    /**
-     * Tests Throwable objects constructed with
-     * {@code enableSuppression=true} and
-     * {@code writableStackTrace=true}. Verifies that:
-     * <ul>
-     * <li><i>toString()</i> returns a non-null value</li>
-     * <li><i>getMessage()</i> returns the original message passed to the
-     * constructor</li>
-     * <li><i>getCause()</i> returns the original cause passed to the
-     * constructor</li>
-     * <li>suppressed exceptions are added</li>
-     * <li>the stack trace is added</li>
-     * </ul>
-     *
-     * @param cons
-     *            the throwable's class constructor
-     * @param <T> to be defined
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public final <T extends Throwable> void testSuppressStack(
-                    final Constructor<T> cons) {
-        var ex = newInstance(cons, "yes,yes", CAUSE, true, true);
-
-        ex.addSuppressed(SUPPRESSED);
-
-        assertNotNull(ex.toString());
-        assertEquals("yes,yes", ex.getMessage());
-        assertEquals(CAUSE, ex.getCause());
-
-        assertEquals(1, ex.getSuppressed().length);
-        assertEquals(SUPPRESSED, ex.getSuppressed()[0]);
-
-        assertTrue(ex.getStackTrace().length > 0);
-    }
-
-    /**
-     * Tests Throwable objects constructed with
-     * {@code enableSuppression=true} and
-     * {@code writableStackTrace=false}. Verifies that:
-     * <ul>
-     * <li><i>toString()</i> returns a non-null value</li>
-     * <li><i>getMessage()</i> returns the original message passed to the
-     * constructor</li>
-     * <li><i>getCause()</i> returns the original cause passed to the
-     * constructor</li>
-     * <li>suppressed exceptions are added</li>
-     * <li>the stack trace is <i>not</i> added</li>
-     * </ul>
-     *
-     * @param cons
-     *            the throwable's class constructor
-     * @param <T> to be defined
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public final <T extends Throwable> void testSuppressNoStack(
-                    final Constructor<T> cons) {
-        var ex = newInstance(cons, "yes,no", CAUSE, true, false);
-
-        ex.addSuppressed(SUPPRESSED);
-
-        assertNotNull(ex.toString());
-        assertEquals("yes,no", ex.getMessage());
-        assertEquals(CAUSE, ex.getCause());
-
-        assertEquals(1, ex.getSuppressed().length);
-        assertEquals(SUPPRESSED, ex.getSuppressed()[0]);
-
-        assertEquals(0, ex.getStackTrace().length);
-    }
-
-    /**
-     * Tests Throwable objects constructed with
-     * {@code enableSuppression=false} and
-     * {@code writableStackTrace=true}. Verifies that:
-     * <ul>
-     * <li><i>toString()</i> returns a non-null value</li>
-     * <li><i>getMessage()</i> returns the original message passed to the
-     * constructor</li>
-     * <li><i>getCause()</i> returns the original cause passed to the
-     * constructor</li>
-     * <li>suppressed exceptions are <i>not</i> added</li>
-     * <li>the stack trace is added</li>
-     * </ul>
-     *
-     * @param cons
-     *            the throwable's class constructor
-     * @param <T> to be defined
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public final <T extends Throwable> void testNoSuppressStack(
-                    final Constructor<T> cons) {
-        var ex = newInstance(cons, "no,yes", CAUSE, false, true);
-
-        ex.addSuppressed(SUPPRESSED);
-
-        assertNotNull(ex.toString());
-        assertEquals("no,yes", ex.getMessage());
-        assertEquals(CAUSE, ex.getCause());
-
-        assertEquals(0, ex.getSuppressed().length);
-
-        assertTrue(ex.getStackTrace().length > 0);
-    }
-
-    /**
-     * Tests Throwable objects constructed with
-     * {@code enableSuppression=false} and
-     * {@code writableStackTrace=false}. Verifies that:
-     * <ul>
-     * <li><i>toString()</i> returns a non-null value</li>
-     * <li><i>getMessage()</i> returns the original message passed to the
-     * constructor</li>
-     * <li><i>getCause()</i> returns the original cause passed to the
-     * constructor</li>
-     * <li>suppressed exceptions are <i>not</i> added</li>
-     * <li>the stack trace is <i>not</i> added</li>
-     * </ul>
-     * @param cons
-     *            the throwable's class constructor
-     * @param <T> to be defined
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     * @throws AssertionError
-     *             if the constructed objects fail to pass various tests
-     */
-    public final <T extends Throwable> void testNoSuppressNoStack(
-                    final Constructor<T> cons) {
-        var ex = newInstance(cons, "no,no", CAUSE, false, false);
-
-        ex.addSuppressed(SUPPRESSED);
-
-        assertNotNull(ex.toString());
-        assertEquals("no,no", ex.getMessage());
-        assertEquals(CAUSE, ex.getCause());
-
-        assertEquals(0, ex.getSuppressed().length);
-        assertEquals(0, ex.getStackTrace().length);
-    }
-
-    /**
-     * Attempts to get a constructor for objects of a given type.
-     *
-     * @param claz
-     *            class of objects whose constructor is to be gotten
-     * @param <T> to be defined
-     * @param testType
-     *            type of test being run
-     * @param argTypes
-     *            argument types to be passed to the constructor
-     * @return the desired constructor, or {@code null} if the desired
-     *         constructor is not available
-     */
-    protected <T extends Throwable> Constructor<T> getConstructor(
-                    final Class<T> claz,
-                    final String testType,
-                    final Class<?>... argTypes) {
-
-        try {
-            return claz.getConstructor(argTypes);
-
-        } catch (NoSuchMethodException | SecurityException e) {
-            // this constructor is not defined so nothing to test
-            logger.debug("skipped test, no constructor for: {}", claz, e);
-            return null;
-        }
-    }
-
-    /**
-     * Creates a new instance of an Throwable subclass.
-     *
-     * @param cons
-     *            subclass constructor
-     * @param <T> to be defined
-     * @param args
-     *            arguments to be passed to the constructor
-     * @return a new instance of the Throwable subclass
-     * @throws ConstructionError
-     *             if the Throwable subclass cannot be constructed
-     */
-    protected <T extends Throwable> T newInstance(
-                    final Constructor<T> cons,
-                    final Object... args) {
-        try {
-            return cons.newInstance(args);
-
-        } catch (InstantiationException | IllegalAccessException
-                        | IllegalArgumentException
-                        | InvocationTargetException e) {
-
-            throw new ConstructionError(e);
-        }
-
-    }
-}
index 93341a9..9b8c91f 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP PAP
  * ================================================================================
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019, 2024 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2026 OpenInfra Foundation Europe. 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.
@@ -24,12 +24,12 @@ package org.onap.policy.common.message.bus.event.client;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.junit.jupiter.api.Test;
-import org.onap.policy.common.utils.test.ExceptionsTester;
 
 class TopicClientExceptionTest {
 
     @Test
     void test() {
-        assertEquals(5, new ExceptionsTester().test(TopicSinkClientException.class));
+        var exception = new TopicSinkClientException("test");
+        assertEquals("test", exception.getMessage());
     }
 }
diff --git a/policy-common/src/test/java/org/onap/policy/common/utils/test/ConstructionErrorTest.java b/policy-common/src/test/java/org/onap/policy/common/utils/test/ConstructionErrorTest.java
deleted file mode 100644 (file)
index 95bba10..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Common Utils-Test
- * ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.utils.test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.junit.jupiter.api.Test;
-
-class ConstructionErrorTest extends ErrorsTester {
-
-    @Test
-    void test() {
-        assertEquals(4, testAllError(ConstructionError.class));
-    }
-
-}
diff --git a/policy-common/src/test/java/org/onap/policy/common/utils/test/ErrorsTesterTest.java b/policy-common/src/test/java/org/onap/policy/common/utils/test/ErrorsTesterTest.java
deleted file mode 100644 (file)
index b6d91f0..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Common Utils-Test
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.utils.test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.junit.jupiter.api.Test;
-
-class ErrorsTesterTest {
-
-    @Test
-    void test() {
-        assertEquals(2, new ErrorsTester().testAllError(SimpleError.class));
-        assertEquals(5, new ErrorsTester().testAllError(StaticError.class));
-    }
-
-    /**
-     * Used to test a simple success case.
-     */
-    public static class SimpleError extends Error {
-        private static final long serialVersionUID = 1L;
-
-        public SimpleError() {
-            super();
-        }
-
-        public SimpleError(String message) {
-            super(message);
-        }
-    }
-
-    /**
-     * Used to test the exhaustive success case.
-     */
-    public static class StaticError extends Error {
-        private static final long serialVersionUID = 1L;
-
-        public StaticError() {
-            super();
-        }
-
-        public StaticError(String message) {
-            super(message);
-        }
-
-        public StaticError(Throwable cause) {
-            super(cause);
-        }
-
-        public StaticError(String message, Throwable cause) {
-            super(message, cause);
-        }
-
-        public StaticError(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
-            super(message, cause, enableSuppression, writableStackTrace);
-        }
-    }
-
-}
diff --git a/policy-common/src/test/java/org/onap/policy/common/utils/test/ExceptionsTesterTest.java b/policy-common/src/test/java/org/onap/policy/common/utils/test/ExceptionsTesterTest.java
deleted file mode 100644 (file)
index 2004009..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Common Utils-Test
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.utils.test;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.junit.jupiter.api.Test;
-
-class ExceptionsTesterTest {
-
-    @Test
-    void test() {
-        assertEquals(2, new ExceptionsTester().test(SimpleException.class));
-        assertEquals(8, new ExceptionsTester().test(StaticException.class));
-    }
-
-    @Test
-    void testNoConstructorsException() {
-        ExceptionsTester tester = new ExceptionsTester();
-        assertThatThrownBy(() -> tester.test(NoConstructorsException.class))
-            .isInstanceOf(AssertionError.class);
-    }
-
-    /**
-     * Used to test a failure case - this has no standard constructors. The only constructor it has
-     * takes an "int", thus it is not one of the standard constructors.
-     */
-    public static class NoConstructorsException extends Exception {
-        private static final long serialVersionUID = 1L;
-
-        @SuppressWarnings("unused")
-        public NoConstructorsException(int value) {
-            super();
-        }
-    }
-
-    /**
-     * Used to test a simple success case.
-     */
-    public static class SimpleException extends Exception {
-        private static final long serialVersionUID = 1L;
-
-        public SimpleException() {
-            super();
-        }
-
-        public SimpleException(String message) {
-            super(message);
-        }
-    }
-
-    /**
-     * Used to test the exhaustive success case.
-     */
-    public static class StaticException extends Exception {
-        private static final long serialVersionUID = 1L;
-
-        public StaticException() {
-            super();
-        }
-
-        public StaticException(String message) {
-            super(message);
-        }
-
-        public StaticException(Throwable cause) {
-            super(cause);
-        }
-
-        public StaticException(String message, Throwable cause) {
-            super(message, cause);
-        }
-
-        public StaticException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
-            super(message, cause, enableSuppression, writableStackTrace);
-        }
-
-        // same as above, but with Exceptions substituted for Throwables
-
-        public StaticException(Exception cause) {
-            super(cause);
-        }
-
-        public StaticException(String message, Exception cause) {
-            super(message, cause);
-        }
-
-        public StaticException(String message, Exception cause, boolean enableSuppression, boolean writableStackTrace) {
-            super(message, cause, enableSuppression, writableStackTrace);
-        }
-    }
-
-}
diff --git a/policy-common/src/test/java/org/onap/policy/common/utils/test/ThrowablesTesterTest.java b/policy-common/src/test/java/org/onap/policy/common/utils/test/ThrowablesTesterTest.java
deleted file mode 100644 (file)
index 0a437b5..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Common Utils-Test
- * ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.utils.test;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.junit.jupiter.api.Test;
-
-class ThrowablesTesterTest {
-
-    @Test
-    void test() {
-        assertEquals(2, new ThrowablesTester().testAllThrowable(SimpleThrowable.class));
-        assertEquals(5, new ThrowablesTester().testAllThrowable(StaticThrowable.class));
-    }
-
-    @Test
-    void testNoConstructorsThrowable() {
-        // this will not throw an error, but it should return 0, as there are
-        // no matching constructors
-        assertEquals(0, new ThrowablesTester().testAllThrowable(NoConstructorsThrowable.class));
-    }
-
-    @Test
-    void testIgnoreMessageThrowable() {
-        ThrowablesTester tester = new ThrowablesTester();
-        assertThatThrownBy(() -> tester.testAllThrowable(IgnoreMessageThrowable.class))
-            .isInstanceOf(AssertionError.class);
-    }
-
-    @Test
-    void testIgnoreCauseThrowable() {
-        ThrowablesTester tester = new ThrowablesTester();
-        assertThatThrownBy(() -> tester.testAllThrowable(IgnoreCauseThrowable.class))
-            .isInstanceOf(AssertionError.class);
-    }
-
-    @Test
-    void testAlwaysSuppressThrowable() {
-        ThrowablesTester tester = new ThrowablesTester();
-        assertThatThrownBy(() -> tester.testAllThrowable(AlwaysSuppressThrowable.class))
-            .isInstanceOf(AssertionError.class);
-    }
-
-    @Test
-    void testNeverSuppressThrowable() {
-        ThrowablesTester tester = new ThrowablesTester();
-        assertThatThrownBy(() -> tester.testAllThrowable(NeverSuppressThrowable.class))
-            .isInstanceOf(AssertionError.class);
-    }
-
-    @Test
-    void testAlwaysWritableThrowable() {
-        ThrowablesTester tester = new ThrowablesTester();
-        assertThatThrownBy(() -> tester.testAllThrowable(AlwaysWritableThrowable.class))
-            .isInstanceOf(AssertionError.class);
-    }
-
-    @Test
-    void testNeverWritableThrowable() {
-        ThrowablesTester tester = new ThrowablesTester();
-        assertThatThrownBy(() -> tester.testAllThrowable(NeverWritableThrowable.class))
-            .isInstanceOf(AssertionError.class);
-    }
-
-    @Test
-    void testThrowInstantiationException() {
-        ThrowablesTester tester = new ThrowablesTester();
-        assertThatThrownBy(() -> tester.testAllThrowable(ThrowInstantiationThrowable.class))
-            .isInstanceOf(AssertionError.class);
-    }
-
-    /**
-     * Used to test a failure case - message text is ignored.
-     */
-    public static class IgnoreMessageThrowable extends Throwable {
-        private static final long serialVersionUID = 1L;
-
-        public IgnoreMessageThrowable(String message) {
-            super("bogus");
-        }
-    }
-
-    /**
-     * Used to test a failure case - cause is ignored.
-     */
-    public static class IgnoreCauseThrowable extends Throwable {
-        private static final long serialVersionUID = 1L;
-
-        public IgnoreCauseThrowable(Throwable cause) {
-            super(new Throwable("another cause"));
-        }
-    }
-
-    /**
-     * Used to test a failure case - this has no standard constructors. The only constructor it has
-     * takes an "int", thus it is not one of the standard constructors.
-     */
-    public static class NoConstructorsThrowable extends Throwable {
-        private static final long serialVersionUID = 1L;
-
-        @SuppressWarnings("unused")
-        public NoConstructorsThrowable(int value) {
-            super();
-        }
-    }
-
-    /**
-     * Used to test a failure case - always suppresses.
-     */
-    public static class AlwaysSuppressThrowable extends Throwable {
-        private static final long serialVersionUID = 1L;
-
-        public AlwaysSuppressThrowable(String message, Throwable cause, boolean enableSuppression,
-                boolean writableStackTrace) {
-            super(message, cause, true, writableStackTrace);
-        }
-    }
-
-    /**
-     * Used to test a failure case - never suppresses.
-     */
-    public static class NeverSuppressThrowable extends Throwable {
-        private static final long serialVersionUID = 1L;
-
-        public NeverSuppressThrowable(String message, Throwable cause, boolean enableSuppression,
-                boolean writableStackTrace) {
-            super(message, cause, false, writableStackTrace);
-        }
-    }
-
-    /**
-     * Used to test a failure case - always allows stack writes.
-     */
-    public static class AlwaysWritableThrowable extends Throwable {
-        private static final long serialVersionUID = 1L;
-
-        public AlwaysWritableThrowable(String message, Throwable cause, boolean enableSuppression,
-                boolean writableStackTrace) {
-            super(message, cause, enableSuppression, true);
-        }
-    }
-
-    /**
-     * Used to test a failure case - never allows stack writes.
-     */
-    public static class NeverWritableThrowable extends Throwable {
-        private static final long serialVersionUID = 1L;
-
-        public NeverWritableThrowable(String message, Throwable cause, boolean enableSuppression,
-                boolean writableStackTrace) {
-            super(message, cause, enableSuppression, false);
-        }
-    }
-
-    /**
-     * Used to test a failure case - throws InstantiationException when constructed.
-     */
-    public static class ThrowInstantiationThrowable extends Throwable {
-        private static final long serialVersionUID = 1L;
-
-        public ThrowInstantiationThrowable(String message, Throwable cause, boolean enableSuppression,
-                boolean writableStackTrace) throws InstantiationException {
-
-            throw new InstantiationException(ThrowablesTester.EXPECTED_EXCEPTION_MSG);
-        }
-    }
-
-    /**
-     * Used to test a simple success case.
-     */
-    public static class SimpleThrowable extends Throwable {
-        private static final long serialVersionUID = 1L;
-
-        public SimpleThrowable() {
-            super();
-        }
-
-        public SimpleThrowable(String message) {
-            super(message);
-        }
-    }
-
-    /**
-     * Used to test the exhaustive success case.
-     */
-    public static class StaticThrowable extends Throwable {
-        private static final long serialVersionUID = 1L;
-
-        public StaticThrowable() {
-            super();
-        }
-
-        public StaticThrowable(String message) {
-            super(message);
-        }
-
-        public StaticThrowable(Throwable cause) {
-            super(cause);
-        }
-
-        public StaticThrowable(String message, Throwable cause) {
-            super(message, cause);
-        }
-
-        public StaticThrowable(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
-            super(message, cause, enableSuppression, writableStackTrace);
-        }
-    }
-
-}