Increase code coverage on aai-common: aai-els-onap-logging library
[aai/aai-common.git] / aai-els-onap-logging / src / test / java / org / onap / aai / exceptions / AAIExceptionWithInfoTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 package org.onap.aai.exceptions;
21
22 import org.junit.Test;
23
24 import java.io.IOException;
25 import java.util.HashMap;
26
27 import static org.junit.Assert.assertEquals;
28 import static org.junit.Assert.assertNotNull;
29
30 public class AAIExceptionWithInfoTest {
31
32     private AAIExceptionWithInfo aaiException;
33     private static final String testInfo = "Test Info";
34     private static final String testDetails = "Test Details";
35
36     @Test
37     public void aaiExceptionWithInfoTest() {
38
39         aaiException = new AAIExceptionWithInfo(new HashMap<String, Object>(), testInfo );
40
41         assertEquals(testInfo, aaiException.getInfo());
42         assertNotNull(aaiException.getInfoHash());
43     }
44
45     @Test
46     public void aaiExceptionWithCodeInfoTest() {
47         aaiException = new AAIExceptionWithInfo("AAI_3300", new HashMap<String, Object>(), testInfo );
48
49         assertEquals(testInfo, aaiException.getInfo());
50         assertEquals("AAI_3300", aaiException.getCode());
51         assertNotNull(aaiException.getInfoHash());
52     }
53
54     @Test
55     public void aaiExceptionWithCodeDetailsInfoTest() {
56
57         aaiException = new AAIExceptionWithInfo("AAI_3300", testDetails, new HashMap<String, Object>(), testInfo );
58
59         assertEquals(testInfo, aaiException.getInfo());
60         assertEquals("AAI_3300", aaiException.getCode());
61         assertEquals(testDetails, aaiException.getMessage());
62         assertNotNull(aaiException.getInfoHash());
63     }
64
65     @Test
66     public void aaiExceptionWithCodeThrowableDetailsInfoTest() {
67
68         aaiException = new AAIExceptionWithInfo("AAI_3300", new IOException("File not found"), testDetails, new HashMap<String, Object>(), testInfo );
69
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());
76     }
77
78 }
79