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=========================================================
20 package org.onap.aai.exceptions;
22 import org.junit.Test;
24 import java.io.IOException;
25 import java.util.HashMap;
27 import static org.junit.Assert.assertEquals;
28 import static org.junit.Assert.assertNotNull;
30 public class AAIExceptionWithInfoTest {
32 private AAIExceptionWithInfo aaiException;
33 private static final String testInfo = "Test Info";
34 private static final String testDetails = "Test Details";
37 public void aaiExceptionWithInfoTest() {
39 aaiException = new AAIExceptionWithInfo(new HashMap<String, Object>(), testInfo );
41 assertEquals(testInfo, aaiException.getInfo());
42 assertNotNull(aaiException.getInfoHash());
46 public void aaiExceptionWithCodeInfoTest() {
47 aaiException = new AAIExceptionWithInfo("AAI_3300", new HashMap<String, Object>(), testInfo );
49 assertEquals(testInfo, aaiException.getInfo());
50 assertEquals("AAI_3300", aaiException.getCode());
51 assertNotNull(aaiException.getInfoHash());
55 public void aaiExceptionWithCodeDetailsInfoTest() {
57 aaiException = new AAIExceptionWithInfo("AAI_3300", testDetails, new HashMap<String, Object>(), testInfo );
59 assertEquals(testInfo, aaiException.getInfo());
60 assertEquals("AAI_3300", aaiException.getCode());
61 assertEquals(testDetails, aaiException.getMessage());
62 assertNotNull(aaiException.getInfoHash());
66 public void aaiExceptionWithCodeThrowableDetailsInfoTest() {
68 aaiException = new AAIExceptionWithInfo("AAI_3300", new IOException("File not found"), testDetails, new HashMap<String, Object>(), testInfo );
70 assertEquals(testInfo, aaiException.getInfo());
71 assertEquals("AAI_3300", aaiException.getCode());
72 assertEquals(testDetails, aaiException.getMessage());
73 assertNotNull(aaiException.getInfoHash());
74 Throwable t = aaiException.getCause();
75 assertEquals("java.io.IOException: File not found", t.toString());