Merge "Added @Override annotation above signature"
[aai/champ.git] / src / test / java / org / onap / 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.onap.aai.champ.exceptions;
23
24 import static org.junit.Assert.assertTrue;
25
26 import org.junit.Test;
27 import org.onap.aai.champ.exceptions.ChampIndexNotExistsException;
28 import org.onap.aai.champ.exceptions.ChampMarshallingException;
29 import org.onap.aai.champ.exceptions.ChampObjectNotExistsException;
30 import org.onap.aai.champ.exceptions.ChampRelationshipNotExistsException;
31 import org.onap.aai.champ.exceptions.ChampSchemaViolationException;
32 import org.onap.aai.champ.exceptions.ChampUnmarshallingException;
33
34 public class ChampExceptionTest {
35
36         @Test
37         public void testChampIndexNotExistsException() {
38                 final ChampIndexNotExistsException e1 = new ChampIndexNotExistsException();
39
40                 assertTrue(e1.getMessage() == null);
41
42                 final ChampIndexNotExistsException e2 = new ChampIndexNotExistsException("foo");
43
44                 assertTrue(e2.getMessage().equals("foo"));
45
46                 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
47
48                 assertTrue(e3.getCause().equals(e2));
49
50                 final ChampIndexNotExistsException e4 = new ChampIndexNotExistsException("foo", e3);
51
52                 assertTrue(e4.getMessage().equals("foo"));
53                 assertTrue(e4.getCause().equals(e3));
54         }
55
56         @Test
57         public void testChampMarshallingException() {
58                 final ChampMarshallingException e1 = new ChampMarshallingException();
59
60                 assertTrue(e1.getMessage() == null);
61
62                 final ChampMarshallingException e2 = new ChampMarshallingException("foo");
63
64                 assertTrue(e2.getMessage().equals("foo"));
65
66                 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
67
68                 assertTrue(e3.getCause().equals(e2));
69
70                 final ChampMarshallingException e4 = new ChampMarshallingException("foo", e3);
71
72                 assertTrue(e4.getMessage().equals("foo"));
73                 assertTrue(e4.getCause().equals(e3));
74         }
75
76         @Test
77         public void testChampObjectNotExistsException() {
78                 final ChampObjectNotExistsException e1 = new ChampObjectNotExistsException();
79
80                 assertTrue(e1.getMessage() == null);
81
82                 final ChampObjectNotExistsException e2 = new ChampObjectNotExistsException("foo");
83
84                 assertTrue(e2.getMessage().equals("foo"));
85
86                 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
87
88                 assertTrue(e3.getCause().equals(e2));
89
90                 final ChampObjectNotExistsException e4 = new ChampObjectNotExistsException("foo", e3);
91
92                 assertTrue(e4.getMessage().equals("foo"));
93                 assertTrue(e4.getCause().equals(e3));
94         }
95
96         @Test
97         public void testChampRelationshipNotExistsException() {
98                 final ChampRelationshipNotExistsException e1 = new ChampRelationshipNotExistsException();
99
100                 assertTrue(e1.getMessage() == null);
101
102                 final ChampRelationshipNotExistsException e2 = new ChampRelationshipNotExistsException("foo");
103
104                 assertTrue(e2.getMessage().equals("foo"));
105
106                 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
107
108                 assertTrue(e3.getCause().equals(e2));
109
110                 final ChampRelationshipNotExistsException e4 = new ChampRelationshipNotExistsException("foo", e3);
111
112                 assertTrue(e4.getMessage().equals("foo"));
113                 assertTrue(e4.getCause().equals(e3));
114         }
115
116         @Test
117         public void testChampSchemaViolationException() {
118                 final ChampSchemaViolationException e1 = new ChampSchemaViolationException();
119
120                 assertTrue(e1.getMessage() == null);
121
122                 final ChampSchemaViolationException e2 = new ChampSchemaViolationException("foo");
123
124                 assertTrue(e2.getMessage().equals("foo"));
125
126                 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
127
128                 assertTrue(e3.getCause().equals(e2));
129
130                 final ChampSchemaViolationException e4 = new ChampSchemaViolationException("foo", e3);
131
132                 assertTrue(e4.getMessage().equals("foo"));
133                 assertTrue(e4.getCause().equals(e3));
134         }
135
136         @Test
137         public void testChampUnmarshallingException() {
138                 final ChampUnmarshallingException e1 = new ChampUnmarshallingException();
139
140                 assertTrue(e1.getMessage() == null);
141
142                 final ChampUnmarshallingException e2 = new ChampUnmarshallingException("foo");
143
144                 assertTrue(e2.getMessage().equals("foo"));
145
146                 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
147
148                 assertTrue(e3.getCause().equals(e2));
149
150                 final ChampUnmarshallingException e4 = new ChampUnmarshallingException("foo", e3);
151
152                 assertTrue(e4.getMessage().equals("foo"));
153                 assertTrue(e4.getCause().equals(e3));
154         }
155
156 }