Reformat PolicyEngineAPI test cases
[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  * 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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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=========================================================
21  */
22 package org.onap.policy.test;
23
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;
28
29 public class PolicyExceptionTest {
30
31     @Test
32     public void test1() {
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());
40     }
41
42     @Test
43     public void test2() {
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());
51
52     }
53
54     @Test
55     public void test3() {
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());
62     }
63
64     @Test
65     public void test4() {
66         String message = "";
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());
73     }
74
75     @Test
76     public void test5() throws Exception {
77         String message = "";
78         Throwable cause = new Throwable();
79         boolean enableSuppression = true;
80         boolean writableStackTrace = true;
81
82         PolicyException result =
83                 new PolicyException(message, cause, enableSuppression, writableStackTrace);
84
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());
90     }
91 }