Unit test coverage
[appc.git] / appc-dispatcher / appc-dispatcher-common / domain-model-lib / src / test / java / org / onap / appc / domainmodel / lcm / TestCommonHeader.java
1 /*
2 * ============LICENSE_START=======================================================
3 * ONAP : APPC
4 * ================================================================================
5 * Copyright 2018 TechMahindra
6 *=================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *     http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
19 */
20 package org.onap.appc.domainmodel.lcm;
21
22 import static org.junit.Assert.*;
23
24 import org.junit.Assert;
25 import org.junit.Before;
26 import org.junit.Test;
27
28 import org.onap.appc.domainmodel.lcm.Flags.Mode;
29
30 public class TestCommonHeader {
31     private CommonHeader commonHeader;
32
33     @Before
34     public void setUp() {
35         commonHeader =new  CommonHeader();
36     }
37
38     @Test
39     public void testgetRpcName() {
40         commonHeader.setApiVer("2.0");
41         Assert.assertNotNull(commonHeader.getApiVer());
42         Assert.assertEquals(commonHeader.getApiVer(), "2.0");
43     }
44
45     @Test
46     public void testGetOriginatorId() {
47         commonHeader.setOriginatorId("AAAA");
48         Assert.assertNotNull(commonHeader.getOriginatorId());
49         Assert.assertEquals(commonHeader.getOriginatorId(), "AAAA");
50     }
51
52     @Test
53     public void testGetRequestId() {
54         commonHeader.setRequestId("1111ABCD");
55         Assert.assertNotNull(commonHeader.getRequestId());
56         Assert.assertEquals(commonHeader.getRequestId(), "1111ABCD");
57     }
58
59     @Test
60     public void testGetSubRequestId() {
61         commonHeader.setSubRequestId("1111");
62         Assert.assertNotNull(commonHeader.getSubRequestId());
63         Assert.assertEquals(commonHeader.getSubRequestId(), "1111");
64     }
65
66     @Test
67     public void testGetFlags() {
68         Flags flags=new Flags();
69         flags.setTtl(60);
70         Mode mode=Mode.EXCLUSIVE;
71         flags.setMode(mode);
72         flags.setForce(false);
73         commonHeader.setFlags(flags);
74         Assert.assertNotNull(commonHeader.getFlags());
75         Assert.assertEquals(60,commonHeader.getFlags().getTtl());
76         Assert.assertEquals(Mode.EXCLUSIVE,commonHeader.getFlags().getMode());
77         Assert.assertEquals(false,commonHeader.getFlags().isForce());
78         
79     }
80     @Test
81     public void testToString_ReturnNonEmptyString() {
82         assertNotEquals(commonHeader.toString(), "");
83         assertNotEquals(commonHeader.toString(), null);
84     }
85
86     @Test
87     public void testToString_ContainsString() {
88         assertTrue(commonHeader.toString().contains("CommonHeader{flags"));
89     }
90
91 }