98da27dcc5202d8aa85e6eaf0dbd08148c9679bb
[sdc.git] /
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.sdc.logging.api;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertNull;
21
22 import org.junit.Test;
23
24 /**
25  * Test correct population of audit data.
26  *
27  * @author EVITALIY
28  * @since 04 Mar 18
29  */
30 public class AuditDataTest {
31
32     @Test
33     public void allPropertiesReadWhenPopulated() {
34
35         final long start = System.currentTimeMillis();
36         final long end = start + 100;
37         final String responseCode = "Response-Code";
38         final String responseDescription = "Response-Description";
39         final String ipAddress = "DUMMY.IP.ADDRESS";
40
41         AuditData data = AuditData.builder().startTime(start).endTime(end).statusCode(StatusCode.COMPLETE)
42                                   .responseCode(responseCode).responseDescription(responseDescription)
43                                   .clientIpAddress(ipAddress).build();
44
45         assertEquals(ipAddress, data.getClientIpAddress());
46         assertEquals(end, data.getEndTime());
47         assertEquals(start, data.getStartTime());
48         assertEquals(responseCode, data.getResponseCode());
49         assertEquals(responseDescription, data.getResponseDescription());
50         assertEquals(StatusCode.COMPLETE, data.getStatusCode());
51     }
52
53     @Test
54     public void allPropertiesEmptyWhenUnpopulated() {
55         AuditData data = AuditData.builder().build();
56         assertEquals(0, data.getStartTime());
57         assertEquals(0, data.getEndTime());
58         assertNull(data.getClientIpAddress());
59         assertNull(data.getResponseCode());
60         assertNull(data.getResponseDescription());
61         assertNull(data.getStatusCode());
62     }
63 }