2 * Copyright © 2016-2018 European Support Limited
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.openecomp.sdc.logging.api;
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertNull;
22 import org.junit.Test;
25 * Test correct population of audit data.
30 public class AuditDataTest {
33 public void allPropertiesReadWhenPopulated() {
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";
41 AuditData data = AuditData.builder().startTime(start).endTime(end).statusCode(StatusCode.COMPLETE)
42 .responseCode(responseCode).responseDescription(responseDescription)
43 .clientIpAddress(ipAddress).build();
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());
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());