From d51dde65937908d97ad057d1ebb2de9993ee6ed3 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 15 Mar 2019 13:28:08 -0400 Subject: Add additional constructors to Exception classes Modified test class to use auto-tester. Updated comments. Updated licenses. Change-Id: I993d0b78f31d15e6e6c35b701ed801616708628a Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn --- .../org/onap/policy/pap/main/PolicyPapException.java | 12 +++++++++++- .../onap/policy/pap/main/PolicyPapRuntimeException.java | 12 +++++++++++- .../java/org/onap/policy/pap/main/TestExceptions.java | 17 +++++++---------- 3 files changed, 29 insertions(+), 12 deletions(-) (limited to 'main') diff --git a/main/src/main/java/org/onap/policy/pap/main/PolicyPapException.java b/main/src/main/java/org/onap/policy/pap/main/PolicyPapException.java index 6459d6bb..8e8b9b61 100644 --- a/main/src/main/java/org/onap/policy/pap/main/PolicyPapException.java +++ b/main/src/main/java/org/onap/policy/pap/main/PolicyPapException.java @@ -1,6 +1,7 @@ -/*- +/* * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +38,15 @@ public class PolicyPapException extends Exception { super(message); } + /** + * Instantiates a new policy pap exception with a caused by exception. + * + * @param exp the exception that caused this exception to be thrown + */ + public PolicyPapException(final Exception exp) { + super(exp); + } + /** * Instantiates a new policy pap exception with a message and a caused by exception. * diff --git a/main/src/main/java/org/onap/policy/pap/main/PolicyPapRuntimeException.java b/main/src/main/java/org/onap/policy/pap/main/PolicyPapRuntimeException.java index e1df1b16..95b941f6 100644 --- a/main/src/main/java/org/onap/policy/pap/main/PolicyPapRuntimeException.java +++ b/main/src/main/java/org/onap/policy/pap/main/PolicyPapRuntimeException.java @@ -1,6 +1,7 @@ -/*- +/* * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +38,15 @@ public class PolicyPapRuntimeException extends RuntimeException { super(message); } + /** + * Instantiates a new policy pap runtime exception with a caused by exception. + * + * @param exp the exception that caused this exception to be thrown + */ + public PolicyPapRuntimeException(final Exception exp) { + super(exp); + } + /** * Instantiates a new policy pap runtime exception with a message and a caused by exception. * diff --git a/main/src/test/java/org/onap/policy/pap/main/TestExceptions.java b/main/src/test/java/org/onap/policy/pap/main/TestExceptions.java index b45cdab7..9e3cda9c 100644 --- a/main/src/test/java/org/onap/policy/pap/main/TestExceptions.java +++ b/main/src/test/java/org/onap/policy/pap/main/TestExceptions.java @@ -1,6 +1,7 @@ -/*- +/* * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +21,10 @@ package org.onap.policy.pap.main; -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; - import org.junit.Test; +import org.onap.policy.common.utils.test.ExceptionsTester; +import org.onap.policy.pap.main.PolicyPapException; +import org.onap.policy.pap.main.PolicyPapRuntimeException; /** * Class to perform unit test of {@link PolicyPapException PolicyPapRuntimeException}}. @@ -35,10 +35,7 @@ public class TestExceptions { @Test public void test() { - assertNotNull(new PolicyPapException("Message")); - assertNotNull(new PolicyPapException("Message", new IOException())); - - assertNotNull(new PolicyPapRuntimeException("Message")); - assertNotNull(new PolicyPapRuntimeException("Message", new IOException())); + new ExceptionsTester().test(PolicyPapException.class); + new ExceptionsTester().test(PolicyPapRuntimeException.class); } } -- cgit 1.2.3-korg