2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.appc.domainmodel.lcm;
24 import static org.junit.Assert.*;
26 import java.time.Instant;
28 import org.junit.Assert;
29 import org.junit.Before;
30 import org.junit.Test;
32 public class TestTransactionRecord {
34 private TransactionRecord transactionRecord;
38 transactionRecord = new TransactionRecord();
42 public void testGetTransactionId() {
43 transactionRecord.setTransactionId("1234");
44 Assert.assertNotNull(transactionRecord.getTransactionId());
45 Assert.assertEquals(transactionRecord.getTransactionId(), "1234");
49 public void testGetRequestId() {
50 transactionRecord.setRequestId("1298ABC");
51 Assert.assertNotNull(transactionRecord.getRequestId());
52 Assert.assertEquals(transactionRecord.getRequestId(), "1298ABC");
56 public void testGetSubRequestId() {
57 transactionRecord.setSubRequestId("1298");
58 Assert.assertNotNull(transactionRecord.getSubRequestId());
59 Assert.assertEquals(transactionRecord.getSubRequestId(), "1298");
63 public void testGetOriginatorId() {
64 transactionRecord.setOriginatorId("1111");
65 Assert.assertNotNull(transactionRecord.getOriginatorId());
66 Assert.assertEquals(transactionRecord.getOriginatorId(), "1111");
70 public void testGetTargetId() {
71 transactionRecord.setTargetId("2222");
72 Assert.assertNotNull(transactionRecord.getTargetId());
73 Assert.assertEquals(transactionRecord.getTargetId(), "2222");
77 public void testGetTargetType() {
78 transactionRecord.setTargetType("A");
79 Assert.assertNotNull(transactionRecord.getTargetType());
80 Assert.assertEquals(transactionRecord.getTargetType(), "A");
84 public void testGetResultCode() {
85 transactionRecord.setResultCode(200);
86 Assert.assertNotNull(transactionRecord.getResultCode());
87 Assert.assertEquals(transactionRecord.getResultCode(), 200);
91 public void testGetDescription() {
92 transactionRecord.setDescription("SUCCESS");
93 Assert.assertNotNull(transactionRecord.getDescription());
94 Assert.assertEquals(transactionRecord.getDescription(), "SUCCESS");
98 public void testGetServiceInstanceId() {
99 transactionRecord.setServiceInstanceId("A1");
100 Assert.assertNotNull(transactionRecord.getServiceInstanceId());
101 Assert.assertEquals(transactionRecord.getServiceInstanceId(), "A1");
105 public void testGetVnfcName() {
106 transactionRecord.setVnfcName("Vnf1");
107 Assert.assertNotNull(transactionRecord.getVnfcName());
108 Assert.assertEquals(transactionRecord.getVnfcName(), "Vnf1");
112 public void testGetVserverId() {
113 transactionRecord.setVserverId("V1");
114 Assert.assertNotNull(transactionRecord.getVserverId());
115 Assert.assertEquals(transactionRecord.getVserverId(), "V1");
119 public void testGetVfModuleId() {
120 transactionRecord.setVfModuleId("M1");
121 Assert.assertNotNull(transactionRecord.getVfModuleId());
122 Assert.assertEquals(transactionRecord.getVfModuleId(), "M1");
126 public void testToString_ReturnNonEmptyString() {
127 assertNotEquals(transactionRecord.toString(), "");
128 assertNotEquals(transactionRecord.toString(), null);
132 public void testToString_ContainsString() {
133 assertTrue(transactionRecord.toString().contains("TransactionRecord{transactionId"));
137 public void testGetOriginTimeStamp() {
138 Instant instant= Instant.now();
139 transactionRecord.setOriginTimestamp(instant);
140 assertEquals(instant, transactionRecord.getOriginTimestamp());
144 public void testGetStartTime() {
145 Instant instant= Instant.now();
146 transactionRecord.setStartTime(instant);
147 assertEquals(instant, transactionRecord.getStartTime());
151 public void testGetEndTime() {
152 Instant instant= Instant.now();
153 transactionRecord.setEndTime(instant);
154 assertEquals(instant, transactionRecord.getEndTime());
158 public void testGetOperation() {
159 VNFOperation vnfOperation= VNFOperation.ActionStatus;
160 transactionRecord.setOperation(vnfOperation);
161 assertEquals(vnfOperation, transactionRecord.getOperation());
165 public void testGetMode() {
166 Flags.Mode mode= Flags.Mode.EXCLUSIVE;
167 transactionRecord.setMode(mode);
168 assertEquals("EXCLUSIVE", transactionRecord.getMode());