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.testng.Assert.*;
21 import org.testng.annotations.Test;
27 public class AuditDataTest {
30 public void allPropertiesReadWhenPopulated() {
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";
38 AuditData data = AuditData.builder().startTime(start).endTime(end).statusCode(StatusCode.COMPLETE)
39 .responseCode(responseCode).responseDescription(responseDescription).clientIpAddress(ipAddress).build();
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);
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());