From 2d381afcd78b61d8791ace22b676e88271b3bdce Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Mon, 13 Aug 2018 14:39:43 -0400 Subject: Fix checkstyle in utils Cleared all the checkstyle in these 2 submodules. Issue-ID: POLICY-881 Change-Id: I248e1894aebf549d5a4f8669a6466ec227d40b55 Signed-off-by: Pamela Dragosh --- .../policy/common/utils/test/ExceptionsTester.java | 344 ++++++++++----------- 1 file changed, 172 insertions(+), 172 deletions(-) (limited to 'utils-test/src/main/java/org/onap/policy/common/utils/test/ExceptionsTester.java') diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/test/ExceptionsTester.java b/utils-test/src/main/java/org/onap/policy/common/utils/test/ExceptionsTester.java index 7208748a..f457dd21 100644 --- a/utils-test/src/main/java/org/onap/policy/common/utils/test/ExceptionsTester.java +++ b/utils-test/src/main/java/org/onap/policy/common/utils/test/ExceptionsTester.java @@ -32,176 +32,176 @@ import java.lang.reflect.Constructor; */ 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 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 int test(final Class 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 not throw - * an exception if no standard constructors are found. - * - * @param claz subclass to be tested - * @param 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 int testAllException(final Class claz) { - int 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: - *
    - *
  • toString() returns a non-null value
  • - *
  • getMessage() returns the cause's message
  • - *
  • getCause() returns the original cause passed to the - * constructor
  • - *
- * - * If the Exception subclass does not support this type of constructor, - * then this method simply returns. - * - * @param claz subclass to be tested - * @param 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 int testException(final Class claz) { - Constructor cons = getConstructor(claz, "exception", - Exception.class); - - if (cons == null) { - return 0; - } - - Exception cause = new Exception(EXPECTED_EXCEPTION_MSG); - T 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: - *
    - *
  • toString() returns a non-null value
  • - *
  • getMessage() returns the original message passed to - * the constructor
  • - *
  • getCause() returns the original cause passed to the - * constructor
  • - *
- * - * If the Exception subclass does not support this type of - * constructor, then this method simply returns. - * - * @param claz subclass to be tested - * @param 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 int testStringException( - final Class claz) { - Constructor cons = getConstructor(claz, "string-exception", - String.class, Exception.class); - if (cons == null) { - return 0; - } - - Exception cause = new Exception(EXPECTED_EXCEPTION_MSG); - T 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: - *
    - *
  • toString() returns a non-null value
  • - *
  • getMessage() returns the original message passed to the - * constructor
  • - *
  • getCause() returns the original cause passed to the - * constructor
  • - *
  • suppressed exceptions can be added, if enabled
  • - *
  • the stack trace can be added, if enabled
  • - *
- * - * If the Exception subclass does not support this type of constructor, - * then this method simply returns. - * - * @param claz subclass to be tested - * @param 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 int testStringExceptionBooleanBoolean( - final Class claz) { - - Constructor 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; - } + /** + * 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 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 int test(final Class 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 not throw + * an exception if no standard constructors are found. + * + * @param claz subclass to be tested + * @param 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 int testAllException(final Class claz) { + int 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: + *
    + *
  • toString() returns a non-null value
  • + *
  • getMessage() returns the cause's message
  • + *
  • getCause() returns the original cause passed to the + * constructor
  • + *
+ * + *

If the Exception subclass does not support this type of constructor, + * then this method simply returns. + * + * @param claz subclass to be tested + * @param 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 int testException(final Class claz) { + Constructor cons = getConstructor(claz, "exception", + Exception.class); + + if (cons == null) { + return 0; + } + + Exception cause = new Exception(EXPECTED_EXCEPTION_MSG); + T 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: + *

    + *
  • toString() returns a non-null value
  • + *
  • getMessage() returns the original message passed to + * the constructor
  • + *
  • getCause() returns the original cause passed to the + * constructor
  • + *
+ * + *

If the Exception subclass does not support this type of + * constructor, then this method simply returns. + * + * @param claz subclass to be tested + * @param 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 int testStringException( + final Class claz) { + Constructor cons = getConstructor(claz, "string-exception", + String.class, Exception.class); + if (cons == null) { + return 0; + } + + Exception cause = new Exception(EXPECTED_EXCEPTION_MSG); + T 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: + *

    + *
  • toString() returns a non-null value
  • + *
  • getMessage() returns the original message passed to the + * constructor
  • + *
  • getCause() returns the original cause passed to the + * constructor
  • + *
  • suppressed exceptions can be added, if enabled
  • + *
  • the stack trace can be added, if enabled
  • + *
+ * + *

If the Exception subclass does not support this type of constructor, + * then this method simply returns. + * + * @param claz subclass to be tested + * @param 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 int testStringExceptionBooleanBoolean( + final Class claz) { + + Constructor 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; + } } -- cgit 1.2.3-korg