08ce5089b75e8fe30c74937e2fa4b2fefcc11986
[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.testng.Assert.*;
20
21 import org.testng.annotations.Test;
22
23 /**
24  * @author EVITALIY
25  * @since 04 Mar 18
26  */
27 public class AuditDataTest {
28
29     @Test
30     public void allPropertiesReadWhenPopulated() {
31
32         final long start = System.currentTimeMillis();
33         final long end = start + 100;
34         final String responseCode = "Response-Code";
35         final String responseDescription = "Response-Description";
36         final String ipAddress = "10.56.20.70";
37
38         AuditData data = AuditData.builder().startTime(start).endTime(end).statusCode(StatusCode.COMPLETE)
39             .responseCode(responseCode).responseDescription(responseDescription).clientIpAddress(ipAddress).build();
40
41         assertEquals(data.getClientIpAddress(), ipAddress);
42         assertEquals(data.getEndTime(), end);
43         assertEquals(data.getStartTime(), start);
44         assertEquals(data.getResponseCode(), responseCode);
45         assertEquals(data.getResponseDescription(), responseDescription);
46         assertEquals(data.getStatusCode(), StatusCode.COMPLETE);
47     }
48
49     @Test
50     public void allPropertiesEmptyWhenUnpopulated() {
51         AuditData data = AuditData.builder().build();
52         assertEquals(data.getStartTime(), 0);
53         assertEquals(data.getEndTime(), 0);
54         assertNull(data.getClientIpAddress());
55         assertNull(data.getResponseCode());
56         assertNull(data.getResponseDescription());
57         assertNull(data.getStatusCode());
58     }
59 }