2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.aai.exceptions;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
26 import java.io.IOException;
27 import java.util.HashMap;
29 import org.junit.Test;
31 public class AAIExceptionWithInfoTest {
33 private AAIExceptionWithInfo aaiException;
34 private static final String testInfo = "Test Info";
35 private static final String testDetails = "Test Details";
38 public void aaiExceptionWithInfoTest() {
40 aaiException = new AAIExceptionWithInfo(new HashMap<String, Object>(), testInfo);
42 assertEquals(testInfo, aaiException.getInfo());
43 assertNotNull(aaiException.getInfoHash());
47 public void aaiExceptionWithCodeInfoTest() {
48 aaiException = new AAIExceptionWithInfo("AAI_3300", new HashMap<String, Object>(), testInfo);
50 assertEquals(testInfo, aaiException.getInfo());
51 assertEquals("AAI_3300", aaiException.getCode());
52 assertNotNull(aaiException.getInfoHash());
56 public void aaiExceptionWithCodeDetailsInfoTest() {
58 aaiException = new AAIExceptionWithInfo("AAI_3300", testDetails, new HashMap<String, Object>(), testInfo);
60 assertEquals(testInfo, aaiException.getInfo());
61 assertEquals("AAI_3300", aaiException.getCode());
62 assertEquals(testDetails, aaiException.getMessage());
63 assertNotNull(aaiException.getInfoHash());
67 public void aaiExceptionWithCodeThrowableDetailsInfoTest() {
69 aaiException = new AAIExceptionWithInfo("AAI_3300", new IOException("File not found"), testDetails,
70 new HashMap<String, Object>(), testInfo);
72 assertEquals(testInfo, aaiException.getInfo());
73 assertEquals("AAI_3300", aaiException.getCode());
74 assertEquals(testDetails, aaiException.getMessage());
75 assertNotNull(aaiException.getInfoHash());
76 Throwable t = aaiException.getCause();
77 assertEquals("java.io.IOException: File not found", t.toString());