diff options
author | vamshi.nemalikonda <vn00480215@techmahindra.com> | 2018-07-10 19:44:02 +0530 |
---|---|---|
committer | vamshi.nemalikonda <vn00480215@techmahindra.com> | 2018-07-10 19:44:02 +0530 |
commit | 39305c31cee623b44e56ca7b944aada2747d8f31 (patch) | |
tree | 7dce8270be614be21c7eca98bb7b473173faea5b /utils-test/src/main/java/org/onap/policy/common/utils/test/ExceptionsTester.java | |
parent | c1c13a8fce06a1508da2eb6e356dddeb456095bc (diff) |
fixed Checkstyle warnings
Issue-ID: POLICY-881
Signed-off-by: vamshi.nemalikonda <vn00480215@techmahindra.com>
Change-Id: I4057306bec83a48921c90a081fb9752f663ee3b6
Diffstat (limited to 'utils-test/src/main/java/org/onap/policy/common/utils/test/ExceptionsTester.java')
-rw-r--r-- | utils-test/src/main/java/org/onap/policy/common/utils/test/ExceptionsTester.java | 109 |
1 files changed, 61 insertions, 48 deletions
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 3a43b943..7208748a 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 @@ -1,21 +1,21 @@ /* - * ============LICENSE_START======================================================= + * ============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========================================================= + * ============LICENSE_END====================================================== */ package org.onap.policy.common.utils.test; @@ -34,18 +34,19 @@ 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 + * 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(Class<T> claz) { + public <T extends Exception> int test(final Class<T> claz) { int ncons = testAllException(claz); assertTrue(ncons > 0); @@ -55,19 +56,20 @@ 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. Does <i>not</i> throw an exception - * if no standard constructors are found. - * - * @param claz - * subclass to be tested + * 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(Class<T> claz) { + public <T extends Exception> int testAllException(final Class<T> claz) { int ncons = 0; ncons += testAllThrowable(claz); @@ -87,12 +89,13 @@ public class ExceptionsTester extends ThrowablesTester { * <li><i>getCause()</i> returns the original cause passed to the * constructor</li> * </ul> - * - * If the Exception subclass does not support this type of constructor, then - * this method simply returns. - * - * @param claz - * subclass to be tested + * + * 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 @@ -100,8 +103,10 @@ public class ExceptionsTester extends ThrowablesTester { * @throws AssertionError * if the constructed objects fail to pass various tests */ - public <T extends Exception> int testException(Class<T> claz) { - Constructor<T> cons = getConstructor(claz, "exception", Exception.class); + public <T extends Exception> int testException(final Class<T> claz) { + Constructor<T> cons = getConstructor(claz, "exception", + Exception.class); + if (cons == null) { return 0; } @@ -117,28 +122,31 @@ public class ExceptionsTester extends ThrowablesTester { } /** - * Tests exceptions created via the constructor that takes a String and an - * Exception. Verifies that: + * 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>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> - * - * If the Exception subclass does not support this type of constructor, then - * this method simply returns. - * - * @param claz - * subclass to be tested + * + * 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(Class<T> claz) { - Constructor<T> cons = getConstructor(claz, "string-exception", String.class, Exception.class); + 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; } @@ -165,20 +173,25 @@ public class ExceptionsTester extends ThrowablesTester { * <li>suppressed exceptions can be added, if enabled</li> * <li>the stack trace can be added, if enabled</li> * </ul> - * - * If the Exception subclass does not support this type of constructor, then - * this method simply returns. - * - * @param claz - * subclass to be tested + * + * 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(Class<T> claz) { - Constructor<T> cons = getConstructor(claz, "string-exception-flags", String.class, Exception.class, - Boolean.TYPE, Boolean.TYPE); + 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; } |