f925edbfad489bf21565cd764418d8d3d28c31e4
[policy/engine.git] / PolicyEngineAPI / src / test / java / org / onap / policy / test / PolicyExceptionTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * PolicyEngineAPI
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20 package org.onap.policy.test;
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertNotNull;
24
25 import org.junit.Test;
26 import org.onap.policy.api.PolicyException;
27
28 public class PolicyExceptionTest {
29
30         @Test
31         public void test1() {
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());
39         }
40
41         @Test
42         public void test2() {
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());
50                 
51         }
52
53         @Test
54         public void test3() {
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());
61         }
62
63         @Test
64         public void test4() {
65                 String message = "";
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());
72         }
73         
74         @Test
75         public void test5()
76                 throws Exception {
77                 String message = "";
78                 Throwable cause = new Throwable();
79                 boolean enableSuppression = true;
80                 boolean writableStackTrace = true;
81
82                 PolicyException result = new PolicyException(message, cause, enableSuppression, writableStackTrace);
83
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());
89         }
90
91         
92 }