2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (C) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 package org.onap.policy.test;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import org.junit.Test;
27 import org.onap.policy.api.PolicyException;
29 public class PolicyExceptionTest {
33 PolicyException result = new PolicyException();
34 // add additional test code here
35 assertNotNull(result);
36 assertEquals(null, result.getCause());
37 assertEquals("org.onap.policy.api.PolicyException", result.toString());
38 assertEquals(null, result.getLocalizedMessage());
39 assertEquals(null, result.getMessage());
44 String message = "message";
45 PolicyException result = new PolicyException(message);
46 assertNotNull(result);
47 assertEquals(null, result.getCause());
48 assertEquals("org.onap.policy.api.PolicyException: " + message, result.toString());
49 assertEquals(message, result.getLocalizedMessage());
50 assertEquals(message, result.getMessage());
56 Throwable cause = new Throwable();
57 PolicyException result = new PolicyException(cause);
58 assertNotNull(result);
59 assertEquals("org.onap.policy.api.PolicyException: java.lang.Throwable", result.toString());
60 assertEquals("java.lang.Throwable", result.getLocalizedMessage());
61 assertEquals("java.lang.Throwable", result.getMessage());
67 Throwable cause = new Throwable();
68 PolicyException result = new PolicyException(message, cause);
69 assertNotNull(result);
70 assertEquals("org.onap.policy.api.PolicyException: ", result.toString());
71 assertEquals("", result.getLocalizedMessage());
72 assertEquals("", result.getMessage());
76 public void test5() throws Exception {
78 Throwable cause = new Throwable();
79 boolean enableSuppression = true;
80 boolean writableStackTrace = true;
82 PolicyException result =
83 new PolicyException(message, cause, enableSuppression, writableStackTrace);
85 // add additional test code here
86 assertNotNull(result);
87 assertEquals("org.onap.policy.api.PolicyException: ", result.toString());
88 assertEquals("", result.getLocalizedMessage());
89 assertEquals("", result.getMessage());