2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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 * ============LICENSE_END=========================================================
23 package org.onap.appc.listener.LCM.model;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotEquals;
28 import java.util.HashMap;
30 import org.junit.Before;
31 import org.junit.Test;
33 public class CommonHeaderTest {
35 private CommonHeader commonHeader;
39 commonHeader = new CommonHeader();
43 public void should_set_properties() {
45 commonHeader.setTimeStamp("test-timestamp");
46 commonHeader.setApiVer("test-api-version");
47 commonHeader.setOriginatorId("test-originator-id");
48 commonHeader.setRequestID("test-request-id");
49 commonHeader.setSubRequestId("test-subrequest-id");
51 Map<String, String> flags = new HashMap<>();
52 flags.put("key1", "flag1");
53 flags.put("key2", "flag2");
54 flags.put("key3", "flag3");
56 commonHeader.setFlags(flags);
58 assertEquals("test-timestamp", commonHeader.getTimeStamp());
59 assertEquals("test-api-version", commonHeader.getApiVer());
60 assertEquals("test-originator-id", commonHeader.getOriginatorId());
61 assertEquals("test-request-id", commonHeader.getRequestID());
62 assertEquals("test-subrequest-id", commonHeader.getSubRequestId());
63 assertEquals(flags, commonHeader.getFlags());
67 public void should_initialize_parameters_from_constructor() {
69 commonHeader.setTimeStamp("test-timestamp");
70 commonHeader.setApiVer("test-api-version");
71 commonHeader.setOriginatorId("test-originator-id");
72 commonHeader.setRequestID("test-request-id");
73 commonHeader.setSubRequestId("test-subrequest-id");
75 Map<String, String> flags = new HashMap<>();
76 flags.put("key1", "flag1");
77 flags.put("key2", "flag2");
78 flags.put("key3", "flag3");
80 commonHeader.setFlags(flags);
82 CommonHeader testObject = new CommonHeader(commonHeader);
84 assertNotEquals(commonHeader.getTimeStamp(), testObject.getTimeStamp());
85 assertEquals(commonHeader.getApiVer(), testObject.getApiVer());
86 assertEquals(commonHeader.getOriginatorId(), testObject.getOriginatorId());
87 assertEquals(commonHeader.getRequestID(), testObject.getRequestID());
88 assertEquals(commonHeader.getSubRequestId(), testObject.getSubRequestId());
89 assertEquals(commonHeader.getFlags(), testObject.getFlags());