2 * ============LICENSE_START==========================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 package org.onap.aai.champ.exceptions;
24 import static org.junit.Assert.assertTrue;
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;
34 public class ChampExceptionTest {
37 public void testChampIndexNotExistsException() {
38 final ChampIndexNotExistsException e1 = new ChampIndexNotExistsException();
40 assertTrue(e1.getMessage() == null);
42 final ChampIndexNotExistsException e2 = new ChampIndexNotExistsException("foo");
44 assertTrue(e2.getMessage().equals("foo"));
46 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
48 assertTrue(e3.getCause().equals(e2));
50 final ChampIndexNotExistsException e4 = new ChampIndexNotExistsException("foo", e3);
52 assertTrue(e4.getMessage().equals("foo"));
53 assertTrue(e4.getCause().equals(e3));
57 public void testChampMarshallingException() {
58 final ChampMarshallingException e1 = new ChampMarshallingException();
60 assertTrue(e1.getMessage() == null);
62 final ChampMarshallingException e2 = new ChampMarshallingException("foo");
64 assertTrue(e2.getMessage().equals("foo"));
66 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
68 assertTrue(e3.getCause().equals(e2));
70 final ChampMarshallingException e4 = new ChampMarshallingException("foo", e3);
72 assertTrue(e4.getMessage().equals("foo"));
73 assertTrue(e4.getCause().equals(e3));
77 public void testChampObjectNotExistsException() {
78 final ChampObjectNotExistsException e1 = new ChampObjectNotExistsException();
80 assertTrue(e1.getMessage() == null);
82 final ChampObjectNotExistsException e2 = new ChampObjectNotExistsException("foo");
84 assertTrue(e2.getMessage().equals("foo"));
86 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
88 assertTrue(e3.getCause().equals(e2));
90 final ChampObjectNotExistsException e4 = new ChampObjectNotExistsException("foo", e3);
92 assertTrue(e4.getMessage().equals("foo"));
93 assertTrue(e4.getCause().equals(e3));
97 public void testChampRelationshipNotExistsException() {
98 final ChampRelationshipNotExistsException e1 = new ChampRelationshipNotExistsException();
100 assertTrue(e1.getMessage() == null);
102 final ChampRelationshipNotExistsException e2 = new ChampRelationshipNotExistsException("foo");
104 assertTrue(e2.getMessage().equals("foo"));
106 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
108 assertTrue(e3.getCause().equals(e2));
110 final ChampRelationshipNotExistsException e4 = new ChampRelationshipNotExistsException("foo", e3);
112 assertTrue(e4.getMessage().equals("foo"));
113 assertTrue(e4.getCause().equals(e3));
117 public void testChampSchemaViolationException() {
118 final ChampSchemaViolationException e1 = new ChampSchemaViolationException();
120 assertTrue(e1.getMessage() == null);
122 final ChampSchemaViolationException e2 = new ChampSchemaViolationException("foo");
124 assertTrue(e2.getMessage().equals("foo"));
126 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
128 assertTrue(e3.getCause().equals(e2));
130 final ChampSchemaViolationException e4 = new ChampSchemaViolationException("foo", e3);
132 assertTrue(e4.getMessage().equals("foo"));
133 assertTrue(e4.getCause().equals(e3));
137 public void testChampUnmarshallingException() {
138 final ChampUnmarshallingException e1 = new ChampUnmarshallingException();
140 assertTrue(e1.getMessage() == null);
142 final ChampUnmarshallingException e2 = new ChampUnmarshallingException("foo");
144 assertTrue(e2.getMessage().equals("foo"));
146 final ChampIndexNotExistsException e3 = new ChampIndexNotExistsException(e2);
148 assertTrue(e3.getCause().equals(e2));
150 final ChampUnmarshallingException e4 = new ChampUnmarshallingException("foo", e3);
152 assertTrue(e4.getMessage().equals("foo"));
153 assertTrue(e4.getCause().equals(e3));