2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2018 Nokia Solutions and Networks
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
24 package org.onap.appc.listener.LCM.model;
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertNotEquals;
29 import java.util.HashMap;
31 import org.junit.Before;
32 import org.junit.Test;
34 public class CommonHeaderTest {
36 private CommonHeader commonHeader;
40 commonHeader = new CommonHeader();
44 public void should_set_properties() {
46 commonHeader.setTimeStamp("test-timestamp");
47 commonHeader.setApiVer("test-api-version");
48 commonHeader.setOriginatorId("test-originator-id");
49 commonHeader.setRequestID("test-request-id");
50 commonHeader.setSubRequestId("test-subrequest-id");
52 Map<String, String> flags = new HashMap<>();
53 flags.put("key1", "flag1");
54 flags.put("key2", "flag2");
55 flags.put("key3", "flag3");
57 commonHeader.setFlags(flags);
59 assertEquals("test-timestamp", commonHeader.getTimeStamp());
60 assertEquals("test-api-version", commonHeader.getApiVer());
61 assertEquals("test-originator-id", commonHeader.getOriginatorId());
62 assertEquals("test-request-id", commonHeader.getRequestID());
63 assertEquals("test-subrequest-id", commonHeader.getSubRequestId());
64 assertEquals(flags, commonHeader.getFlags());
68 public void should_initialize_parameters_from_constructor() {
70 commonHeader.setTimeStamp("test-timestamp");
71 commonHeader.setApiVer("test-api-version");
72 commonHeader.setOriginatorId("test-originator-id");
73 commonHeader.setRequestID("test-request-id");
74 commonHeader.setSubRequestId("test-subrequest-id");
76 Map<String, String> flags = new HashMap<>();
77 flags.put("key1", "flag1");
78 flags.put("key2", "flag2");
79 flags.put("key3", "flag3");
81 commonHeader.setFlags(flags);
83 CommonHeader testObject = new CommonHeader(commonHeader);
85 assertNotEquals(commonHeader.getTimeStamp(), testObject.getTimeStamp());
86 assertEquals(commonHeader.getApiVer(), testObject.getApiVer());
87 assertEquals(commonHeader.getOriginatorId(), testObject.getOriginatorId());
88 assertEquals(commonHeader.getRequestID(), testObject.getRequestID());
89 assertEquals(commonHeader.getSubRequestId(), testObject.getSubRequestId());
90 assertEquals(commonHeader.getFlags(), testObject.getFlags());