Added test file to Transaction.java
[appc.git] / appc-sequence-generator / appc-sequence-generator-bundle / src / test / java / org / onap / appc / seqgen / objects / TransactionTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2019 IBM.
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  *
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.appc.seqgen.objects;
22
23 import static org.mockito.Mockito.mock;
24 import static org.junit.Assert.assertEquals;
25 import java.util.ArrayList;
26 import org.junit.Assert;
27 import org.junit.Before;
28 import org.junit.Test;
29 import java.util.Map;
30 import java.util.HashMap;
31
32 public class TransactionTest {
33
34     private Transaction transaction;
35
36     @Before
37     public void setUp() {
38         transaction = new Transaction();
39     }
40
41     @Test
42     public void get_set_transaction_id() {
43         Integer id = 133;
44         transaction.setTransactionId(id);
45         assertEquals(id, transaction.getTransactionId());
46     }
47
48     @Test
49     public void get_set_action() {
50         String action = "some_action";
51         transaction.setAction(action);
52         assertEquals(action, transaction.getAction());
53     }
54
55     @Test
56     public void get_set_action_level() {
57         String actionLevel = "some_action_level";
58         transaction.setActionLevel(actionLevel);
59         assertEquals(actionLevel, transaction.getActionLevel());
60     }
61
62     @Test
63     public void get_set_action_identifier() {
64         ActionIdentifier actionIdentifier = mock(ActionIdentifier.class);
65         transaction.setActionIdentifier(actionIdentifier);
66         assertEquals(actionIdentifier, transaction.getActionIdentifier());
67     }
68
69     @Test
70     public void get_set_payload() {
71         String payload = "some_payload";
72         transaction.setPayload(payload);
73         assertEquals(payload, transaction.getPayload());
74     }
75
76     @Test
77     public void get_setPreCheckOperator() {
78         String preCheckOperator = "some_preCheckOperator";
79         transaction.setPreCheckOperator(preCheckOperator);
80         assertEquals(preCheckOperator, transaction.getPreCheckOperator());
81     }
82
83     @Test
84     public void get_set_responses() {
85         ArrayList<Response> responses = new ArrayList<>();
86         responses.add(mock(Response.class));
87         transaction.setResponses(responses);
88         assertEquals(responses, transaction.getResponses());
89     }
90
91     @Test
92     public void get_set_precheckOptions() {
93         ArrayList<PreCheckOption> precheckOptions = new ArrayList<>();
94         precheckOptions.add(mock(PreCheckOption.class));
95         transaction.setPrecheckOptions(precheckOptions);
96         assertEquals(precheckOptions, transaction.getPrecheckOptions());
97     }
98     @Test
99     public void get_set_parameters() {
100         Map<String, String> parameters = new HashMap<>();
101         parameters.put("hello","world");
102         transaction.setParameters(parameters);
103         assertEquals(parameters, transaction.getParameters());
104     }
105
106
107 }