[AAI] Fix doc config files
[aai/aai-common.git] / aai-els-onap-logging / src / test / java / org / onap / aai / logging / ErrorObjectTest.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
21 package org.onap.aai.logging;
22
23 import org.junit.Test;
24
25 import javax.ws.rs.core.Response;
26
27 import static org.junit.Assert.assertEquals;
28
29 public class ErrorObjectTest {
30     private ErrorObject errorObject;
31     private static final String ERROR_DISPOSITION = "5";
32     private static final String ERROR_SEVERITY = "ERROR";
33     private static final String ERROR_CATEGORY = "4";
34     private static final Integer ERROR_HTTP_RESPONSE_CODE = new Integer(401);
35     private static final String ERROR_REST_CODE = "3300";
36     private static final String ERROR_CODE = "4000";
37     private static final String ERROR_TEXT = "Test data error";
38     private static final String ERROR_PATTERN = "ERR.5.4.4000";
39     private static final String ERROR_SEVERITY_CODE = "2";
40     @Test
41     public void errorObjectDefaultConstructorTest() {
42         errorObject = new ErrorObject();
43         assertEquals("3002", errorObject.getRESTErrorCode());
44         assertEquals(Response.Status.fromStatusCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()), errorObject.getHTTPResponseCode());
45         assertEquals(AaiElsErrorCode.UNKNOWN_ERROR,errorObject.getAaiElsErrorCode());
46         assertEquals(ERROR_SEVERITY_CODE, errorObject.getSeverityCode(ERROR_SEVERITY));
47     }
48     @Test
49     public void errorObjectConstructor7Test() {
50         errorObject = new ErrorObject(ERROR_DISPOSITION, ERROR_CATEGORY, ERROR_SEVERITY, ERROR_HTTP_RESPONSE_CODE,
51             ERROR_REST_CODE, ERROR_CODE, ERROR_TEXT);
52         assertEquals(ERROR_DISPOSITION, errorObject.getDisposition());
53         assertEquals(ERROR_SEVERITY, errorObject.getSeverity());
54         assertEquals(ERROR_CATEGORY, errorObject.getCategory());
55         assertEquals(Response.Status.fromStatusCode(ERROR_HTTP_RESPONSE_CODE), errorObject.getHTTPResponseCode());
56         assertEquals(ERROR_REST_CODE, errorObject.getRESTErrorCode());
57         assertEquals(ERROR_CODE, errorObject.getErrorCode());
58         assertEquals(ERROR_TEXT, errorObject.getErrorText());
59         assertEquals(AaiElsErrorCode.UNKNOWN_ERROR,errorObject.getAaiElsErrorCode());
60         assertEquals(ERROR_SEVERITY_CODE, errorObject.getSeverityCode(ERROR_SEVERITY));
61     }
62
63     @Test
64     public void errorObjectConstructor5Test() {
65         errorObject = new ErrorObject(ERROR_SEVERITY, ERROR_CODE, ERROR_TEXT, ERROR_DISPOSITION, ERROR_CATEGORY);
66         assertEquals(ERROR_DISPOSITION, errorObject.getDisposition());
67         assertEquals(ERROR_SEVERITY, errorObject.getSeverity());
68         assertEquals(ERROR_CATEGORY, errorObject.getCategory());
69         assertEquals(Response.Status.fromStatusCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()), errorObject.getHTTPResponseCode());
70         assertEquals("3002", errorObject.getRESTErrorCode());
71         assertEquals(ERROR_CODE, errorObject.getErrorCode());
72         assertEquals(ERROR_TEXT, errorObject.getErrorText());
73         assertEquals(AaiElsErrorCode.UNKNOWN_ERROR,errorObject.getAaiElsErrorCode());
74         assertEquals(ERROR_PATTERN, errorObject.getErrorCodeString());
75         assertEquals(ERROR_SEVERITY_CODE, errorObject.getSeverityCode(ERROR_SEVERITY));
76     }
77
78     @Test
79     public void errorObjectConstructor6Test() {
80         errorObject = new ErrorObject(ERROR_SEVERITY, ERROR_HTTP_RESPONSE_CODE, ERROR_CODE, ERROR_TEXT, ERROR_DISPOSITION, ERROR_CATEGORY);
81         assertEquals(ERROR_DISPOSITION, errorObject.getDisposition());
82         assertEquals(ERROR_SEVERITY, errorObject.getSeverity());
83         assertEquals(ERROR_CATEGORY, errorObject.getCategory());
84         assertEquals(Response.Status.fromStatusCode(ERROR_HTTP_RESPONSE_CODE), errorObject.getHTTPResponseCode());
85         assertEquals("3002", errorObject.getRESTErrorCode());
86         assertEquals(ERROR_CODE, errorObject.getErrorCode());
87         assertEquals(ERROR_TEXT, errorObject.getErrorText());
88         assertEquals(AaiElsErrorCode.UNKNOWN_ERROR, errorObject.getAaiElsErrorCode());
89         assertEquals(ERROR_PATTERN, errorObject.getErrorCodeString());
90         assertEquals(ERROR_SEVERITY_CODE, errorObject.getSeverityCode(ERROR_SEVERITY));
91
92     }
93
94
95 }