ea822f899019dec5b3c38bb77de7667149e18b94
[appc.git] / appc-event-listener / appc-event-listener-bundle / src / test / java / org / onap / appc / listener / LCM / model / CommonHeaderTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
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
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
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.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24 package org.onap.appc.listener.LCM.model;
25
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertNotEquals;
28
29 import java.util.HashMap;
30 import java.util.Map;
31 import org.junit.Before;
32 import org.junit.Test;
33
34 public class CommonHeaderTest {
35
36     private CommonHeader commonHeader;
37
38     @Before
39     public void setup() {
40         commonHeader = new CommonHeader();
41     }
42
43     @Test
44     public void should_set_properties() {
45
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");
51
52         Map<String, String> flags = new HashMap<>();
53         flags.put("key1", "flag1");
54         flags.put("key2", "flag2");
55         flags.put("key3", "flag3");
56
57         commonHeader.setFlags(flags);
58
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());
65     }
66
67     @Test
68     public void should_initialize_parameters_from_constructor() {
69
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");
75
76         Map<String, String> flags = new HashMap<>();
77         flags.put("key1", "flag1");
78         flags.put("key2", "flag2");
79         flags.put("key3", "flag3");
80
81         commonHeader.setFlags(flags);
82
83         CommonHeader testObject = new CommonHeader(commonHeader);
84
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());
91     }
92 }