added test cases to TestTransactionRecord.java
[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 * Modifications Copyright 2018 TechMahindra
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 * ============LICENSE_END=========================================================
21 */
22 package org.onap.appc.domainmodel.lcm;
23
24 import static org.junit.Assert.*;
25
26 import java.time.Instant;
27
28 import org.junit.Assert;
29 import org.junit.Before;
30 import org.junit.Test;
31
32 public class TestTransactionRecord {
33
34     private TransactionRecord transactionRecord;
35
36     @Before
37     public void setUp() {
38         transactionRecord = new TransactionRecord();
39     }
40
41     @Test
42     public void testGetTransactionId() {
43         transactionRecord.setTransactionId("1234");
44         Assert.assertNotNull(transactionRecord.getTransactionId());
45         Assert.assertEquals(transactionRecord.getTransactionId(), "1234");
46     }
47
48     @Test
49     public void testGetRequestId() {
50         transactionRecord.setRequestId("1298ABC");
51         Assert.assertNotNull(transactionRecord.getRequestId());
52         Assert.assertEquals(transactionRecord.getRequestId(), "1298ABC");
53     }
54
55     @Test
56     public void testGetSubRequestId() {
57         transactionRecord.setSubRequestId("1298");
58         Assert.assertNotNull(transactionRecord.getSubRequestId());
59         Assert.assertEquals(transactionRecord.getSubRequestId(), "1298");
60     }
61
62     @Test
63     public void testGetOriginatorId() {
64         transactionRecord.setOriginatorId("1111");
65         Assert.assertNotNull(transactionRecord.getOriginatorId());
66         Assert.assertEquals(transactionRecord.getOriginatorId(), "1111");
67     }
68
69     @Test
70     public void testGetTargetId() {
71         transactionRecord.setTargetId("2222");
72         Assert.assertNotNull(transactionRecord.getTargetId());
73         Assert.assertEquals(transactionRecord.getTargetId(), "2222");
74     }
75
76     @Test
77     public void testGetTargetType() {
78         transactionRecord.setTargetType("A");
79         Assert.assertNotNull(transactionRecord.getTargetType());
80         Assert.assertEquals(transactionRecord.getTargetType(), "A");
81     }
82
83     @Test
84     public void testGetResultCode() {
85         transactionRecord.setResultCode(200);
86         Assert.assertNotNull(transactionRecord.getResultCode());
87         Assert.assertEquals(transactionRecord.getResultCode(), 200);
88     }
89
90     @Test
91     public void testGetDescription() {
92         transactionRecord.setDescription("SUCCESS");
93         Assert.assertNotNull(transactionRecord.getDescription());
94         Assert.assertEquals(transactionRecord.getDescription(), "SUCCESS");
95     }
96
97     @Test
98     public void testGetServiceInstanceId() {
99         transactionRecord.setServiceInstanceId("A1");
100         Assert.assertNotNull(transactionRecord.getServiceInstanceId());
101         Assert.assertEquals(transactionRecord.getServiceInstanceId(), "A1");
102     }
103
104     @Test
105     public void testGetVnfcName() {
106         transactionRecord.setVnfcName("Vnf1");
107         Assert.assertNotNull(transactionRecord.getVnfcName());
108         Assert.assertEquals(transactionRecord.getVnfcName(), "Vnf1");
109     }
110
111     @Test
112     public void testGetVserverId() {
113         transactionRecord.setVserverId("V1");
114         Assert.assertNotNull(transactionRecord.getVserverId());
115         Assert.assertEquals(transactionRecord.getVserverId(), "V1");
116     }
117
118     @Test
119     public void testGetVfModuleId() {
120         transactionRecord.setVfModuleId("M1");
121         Assert.assertNotNull(transactionRecord.getVfModuleId());
122         Assert.assertEquals(transactionRecord.getVfModuleId(), "M1");
123     }
124
125     @Test
126     public void testToString_ReturnNonEmptyString() {
127         assertNotEquals(transactionRecord.toString(), "");
128         assertNotEquals(transactionRecord.toString(), null);
129     }
130
131     @Test
132     public void testToString_ContainsString() {
133         assertTrue(transactionRecord.toString().contains("TransactionRecord{transactionId"));
134     }
135     
136     @Test
137     public void testGetOriginTimeStamp() {
138         Instant instant= Instant.now();
139         transactionRecord.setOriginTimestamp(instant);
140         assertEquals(instant, transactionRecord.getOriginTimestamp());
141     }
142     
143     @Test
144     public void testGetStartTime() {
145         Instant instant= Instant.now();
146         transactionRecord.setStartTime(instant);
147         assertEquals(instant, transactionRecord.getStartTime());
148     }
149     
150     @Test
151     public void testGetEndTime() {
152         Instant instant= Instant.now();
153         transactionRecord.setEndTime(instant);
154         assertEquals(instant, transactionRecord.getEndTime());
155     }
156     
157     @Test
158     public void testGetOperation() {
159         VNFOperation vnfOperation= VNFOperation.ActionStatus;
160         transactionRecord.setOperation(vnfOperation);
161         assertEquals(vnfOperation, transactionRecord.getOperation());
162     }
163     
164     @Test
165     public void testGetMode() {
166         Flags.Mode mode= Flags.Mode.EXCLUSIVE;
167         transactionRecord.setMode(mode);
168         assertEquals("EXCLUSIVE", transactionRecord.getMode());
169     }
170     
171 }