Unit test coverage
[appc.git] / appc-dispatcher / appc-dispatcher-common / domain-model-lib / src / test / java / org / onap / appc / domainmodel / lcm / TestTransactionRecord.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 import org.junit.Assert;
24 import org.junit.Before;
25 import org.junit.Test;
26
27 public class TestTransactionRecord {
28
29     private TransactionRecord transactionRecord;
30
31     @Before
32     public void setUp() {
33         transactionRecord = new TransactionRecord();
34     }
35
36     @Test
37     public void testGetTransactionId() {
38         transactionRecord.setTransactionId("1234");
39         Assert.assertNotNull(transactionRecord.getTransactionId());
40         Assert.assertEquals(transactionRecord.getTransactionId(), "1234");
41     }
42
43     @Test
44     public void testGetRequestId() {
45         transactionRecord.setRequestId("1298ABC");
46         Assert.assertNotNull(transactionRecord.getRequestId());
47         Assert.assertEquals(transactionRecord.getRequestId(), "1298ABC");
48     }
49
50     @Test
51     public void testGetSubRequestId() {
52         transactionRecord.setSubRequestId("1298");
53         Assert.assertNotNull(transactionRecord.getSubRequestId());
54         Assert.assertEquals(transactionRecord.getSubRequestId(), "1298");
55     }
56
57     @Test
58     public void testGetOriginatorId() {
59         transactionRecord.setOriginatorId("1111");
60         Assert.assertNotNull(transactionRecord.getOriginatorId());
61         Assert.assertEquals(transactionRecord.getOriginatorId(), "1111");
62     }
63
64     @Test
65     public void testGetTargetId() {
66         transactionRecord.setTargetId("2222");
67         Assert.assertNotNull(transactionRecord.getTargetId());
68         Assert.assertEquals(transactionRecord.getTargetId(), "2222");
69     }
70
71     @Test
72     public void testGetTargetType() {
73         transactionRecord.setTargetType("A");
74         Assert.assertNotNull(transactionRecord.getTargetType());
75         Assert.assertEquals(transactionRecord.getTargetType(), "A");
76     }
77
78     @Test
79     public void testGetResultCode() {
80         transactionRecord.setResultCode(200);
81         Assert.assertNotNull(transactionRecord.getResultCode());
82         Assert.assertEquals(transactionRecord.getResultCode(), 200);
83     }
84
85     @Test
86     public void testGetDescription() {
87         transactionRecord.setDescription("SUCCESS");
88         Assert.assertNotNull(transactionRecord.getDescription());
89         Assert.assertEquals(transactionRecord.getDescription(), "SUCCESS");
90     }
91
92     @Test
93     public void testGetServiceInstanceId() {
94         transactionRecord.setServiceInstanceId("A1");
95         Assert.assertNotNull(transactionRecord.getServiceInstanceId());
96         Assert.assertEquals(transactionRecord.getServiceInstanceId(), "A1");
97     }
98
99     @Test
100     public void testGetVnfcName() {
101         transactionRecord.setVnfcName("Vnf1");
102         Assert.assertNotNull(transactionRecord.getVnfcName());
103         Assert.assertEquals(transactionRecord.getVnfcName(), "Vnf1");
104     }
105
106     @Test
107     public void testGetVserverId() {
108         transactionRecord.setVserverId("V1");
109         Assert.assertNotNull(transactionRecord.getVserverId());
110         Assert.assertEquals(transactionRecord.getVserverId(), "V1");
111     }
112
113     @Test
114     public void testGetVfModuleId() {
115         transactionRecord.setVfModuleId("M1");
116         Assert.assertNotNull(transactionRecord.getVfModuleId());
117         Assert.assertEquals(transactionRecord.getVfModuleId(), "M1");
118     }
119
120     @Test
121     public void testToString_ReturnNonEmptyString() {
122         assertNotEquals(transactionRecord.toString(), "");
123         assertNotEquals(transactionRecord.toString(), null);
124     }
125
126     @Test
127     public void testToString_ContainsString() {
128         assertTrue(transactionRecord.toString().contains("TransactionRecord{transactionId"));
129     }
130 }