Dmaap micro service jar
[appc.git] / services / appc-dmaap-service / 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-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
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  * ============LICENSE_END=========================================================
22  */
23 package org.onap.appc.listener.LCM.model;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotEquals;
27
28 import java.util.HashMap;
29 import java.util.Map;
30 import org.junit.Before;
31 import org.junit.Test;
32
33 public class CommonHeaderTest {
34
35     private CommonHeader commonHeader;
36
37     @Before
38     public void setup() {
39         commonHeader = new CommonHeader();
40     }
41
42     @Test
43     public void should_set_properties() {
44
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");
50
51         Map<String, String> flags = new HashMap<>();
52         flags.put("key1", "flag1");
53         flags.put("key2", "flag2");
54         flags.put("key3", "flag3");
55
56         commonHeader.setFlags(flags);
57
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());
64     }
65
66     @Test
67     public void should_initialize_parameters_from_constructor() {
68
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");
74
75         Map<String, String> flags = new HashMap<>();
76         flags.put("key1", "flag1");
77         flags.put("key2", "flag2");
78         flags.put("key3", "flag3");
79
80         commonHeader.setFlags(flags);
81
82         CommonHeader testObject = new CommonHeader(commonHeader);
83
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());
90     }
91 }