Merge "Added @Override annotation above signature"
[aai/champ.git] / src / test / java / org / openecomp / aai / champ / exceptions / ChampExceptionTest.java
1 /**
2  * ============LICENSE_START==========================================
3  * org.onap.aai
4  * ===================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 Amdocs
7  * ===================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *        http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  */
22 package org.openecomp.aai.champ.exceptions;
23
24 import static org.junit.Assert.assertTrue;
25
26 import org.junit.Test;
27
28 public class ChampExceptionTest {
29
30         @Test
31         public void testChampIndexNotExistsException() {
32                 final ChampIndexNotExistsException e1 = new ChampIndexNotExistsException();
33
34                 assertTrue(e1.getMessage() == null);
35
36                 final ChampIndexNotExistsException e2 = new ChampIndexNotExistsException("foo");
37
38                 assertTrue(e2.getMessage().equals("foo"));
39
40                 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
41
42                 assertTrue(e3.getCause().equals(e2));
43
44                 final ChampIndexNotExistsException e4 = new ChampIndexNotExistsException("foo", e3);
45
46                 assertTrue(e4.getMessage().equals("foo"));
47                 assertTrue(e4.getCause().equals(e3));
48         }
49
50         @Test
51         public void testChampMarshallingException() {
52                 final ChampMarshallingException e1 = new ChampMarshallingException();
53
54                 assertTrue(e1.getMessage() == null);
55
56                 final ChampMarshallingException e2 = new ChampMarshallingException("foo");
57
58                 assertTrue(e2.getMessage().equals("foo"));
59
60                 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
61
62                 assertTrue(e3.getCause().equals(e2));
63
64                 final ChampMarshallingException e4 = new ChampMarshallingException("foo", e3);
65
66                 assertTrue(e4.getMessage().equals("foo"));
67                 assertTrue(e4.getCause().equals(e3));
68         }
69
70         @Test
71         public void testChampObjectNotExistsException() {
72                 final ChampObjectNotExistsException e1 = new ChampObjectNotExistsException();
73
74                 assertTrue(e1.getMessage() == null);
75
76                 final ChampObjectNotExistsException e2 = new ChampObjectNotExistsException("foo");
77
78                 assertTrue(e2.getMessage().equals("foo"));
79
80                 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
81
82                 assertTrue(e3.getCause().equals(e2));
83
84                 final ChampObjectNotExistsException e4 = new ChampObjectNotExistsException("foo", e3);
85
86                 assertTrue(e4.getMessage().equals("foo"));
87                 assertTrue(e4.getCause().equals(e3));
88         }
89
90         @Test
91         public void testChampRelationshipNotExistsException() {
92                 final ChampRelationshipNotExistsException e1 = new ChampRelationshipNotExistsException();
93
94                 assertTrue(e1.getMessage() == null);
95
96                 final ChampRelationshipNotExistsException e2 = new ChampRelationshipNotExistsException("foo");
97
98                 assertTrue(e2.getMessage().equals("foo"));
99
100                 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
101
102                 assertTrue(e3.getCause().equals(e2));
103
104                 final ChampRelationshipNotExistsException e4 = new ChampRelationshipNotExistsException("foo", e3);
105
106                 assertTrue(e4.getMessage().equals("foo"));
107                 assertTrue(e4.getCause().equals(e3));
108         }
109
110         @Test
111         public void testChampSchemaViolationException() {
112                 final ChampSchemaViolationException e1 = new ChampSchemaViolationException();
113
114                 assertTrue(e1.getMessage() == null);
115
116                 final ChampSchemaViolationException e2 = new ChampSchemaViolationException("foo");
117
118                 assertTrue(e2.getMessage().equals("foo"));
119
120                 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
121
122                 assertTrue(e3.getCause().equals(e2));
123
124                 final ChampSchemaViolationException e4 = new ChampSchemaViolationException("foo", e3);
125
126                 assertTrue(e4.getMessage().equals("foo"));
127                 assertTrue(e4.getCause().equals(e3));
128         }
129
130         @Test
131         public void testChampUnmarshallingException() {
132                 final ChampUnmarshallingException e1 = new ChampUnmarshallingException();
133
134                 assertTrue(e1.getMessage() == null);
135
136                 final ChampUnmarshallingException e2 = new ChampUnmarshallingException("foo");
137
138                 assertTrue(e2.getMessage().equals("foo"));
139
140                 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
141
142                 assertTrue(e3.getCause().equals(e2));
143
144                 final ChampUnmarshallingException e4 = new ChampUnmarshallingException("foo", e3);
145
146                 assertTrue(e4.getMessage().equals("foo"));
147                 assertTrue(e4.getCause().equals(e3));
148         }
149
150 }