d79e5f6294b140e3a8c290d39f0aaf47f814748a
[so.git] / mso-api-handlers / mso-api-handler-infra / src / test / java / org / onap / so / apihandlerinfra / tasksbeans / VariablesTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
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
21 package org.onap.so.apihandlerinfra.tasksbeans;
22
23 import org.junit.After;
24 import org.junit.Before;
25 import org.junit.Test;
26 import static org.junit.Assert.*;
27 import static org.mockito.Mockito.mock;
28 import static org.mockito.Mockito.verify;
29 import static org.mockito.Mockito.when;
30
31 public class VariablesTest {
32
33         Variables _variables;
34         protected Value _source;
35         protected Value _responseValue;
36     protected Value _requestorId;
37    
38     @Before
39         public void setUp() {
40         _variables = mock(Variables.class);
41         _source = mock(Value.class);
42         _responseValue = mock(Value.class);
43         _requestorId = mock(Value.class);
44         
45                 when(_variables.getSource()).thenReturn(_source);
46                 when(_variables.getRequestorId()).thenReturn(_requestorId);
47                 when(_variables.getResponseValue()).thenReturn(_responseValue);
48                 
49         }
50
51         @After
52         public void tearDown() {
53                 _variables = null;
54                 _source = null;
55                 _responseValue = null;
56                 _requestorId = null;
57         }
58         
59         @Test
60     public void testGetSource() {
61                 _variables.setSource(_source);
62                 assertTrue(_variables.getSource().equals(_source));
63     }
64
65         @Test
66         public void testSetSource(){
67                 _variables.setSource(_source);
68                 verify(_variables).setSource(_source);
69                 }       
70         
71         @Test
72     public void testGetResponseValue() {
73                 _variables.setResponseValue(_responseValue);
74                 assertTrue(_variables.getResponseValue().equals(_responseValue));
75     }
76
77         @Test
78         public void testSetResponseValue(){
79                 _variables.setResponseValue(_responseValue);
80                 verify(_variables).setResponseValue(_responseValue);
81                 }       
82         
83         @Test
84     public void testGetRequestorId() {
85                 _variables.setRequestorId(_requestorId);
86                 assertTrue(_variables.getRequestorId().equals(_requestorId));
87     }
88
89         @Test
90         public void testSetRequestorId(){
91                 _variables.setRequestorId(_requestorId);
92                 verify(_variables).setRequestorId(_requestorId);
93                 }       
94         
95 }