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