Added tests for appc.flow.Response
[appc.git] / appc-config / appc-flow-controller / provider / src / test / java / org / onap / appc / flow / controller / data / ResponseTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2018 Nokia Intellectual Property. 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  *
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.appc.flow.controller.data;
22
23 import static org.mockito.Mockito.mock;
24 import static org.mockito.Mockito.when;
25
26 import org.junit.Assert;
27 import org.junit.Before;
28 import org.junit.Test;
29
30 public class ResponseTest {
31
32     private Response response;
33
34     @Before
35     public void setUp() {
36         response = new Response();
37     }
38
39     @Test
40     public void get_set_response_action() {
41         ResponseAction ra = mock(ResponseAction.class);
42         response.setResponseAction(ra);
43         Assert.assertEquals(ra, response.getResponseAction());
44     }
45
46     @Test
47     public void get_set_response_action_handler() {
48         String rah = "response_action_handler";
49         response.setResponseActionHanlder(rah);
50         Assert.assertEquals(rah, response.getResponseActionHanlder());
51     }
52
53     @Test
54     public void get_set_response_code() {
55         String responseCode = "response_code";
56         response.setResponseCode(responseCode);
57         Assert.assertEquals(responseCode, response.getResponseCode());
58     }
59
60     @Test
61     public void get_set_response_message() {
62         String responseMessage = "response_message";
63         response.setResponseMessage(responseMessage);
64         Assert.assertEquals(responseMessage, response.getResponseMessage());
65     }
66
67     @Test
68     public void to_string() {
69         response.setResponseCode("code");
70         response.setResponseMessage("msg");
71         response.setResponseActionHanlder("rah");
72
73         ResponseAction ra = mock(ResponseAction.class);
74         when(ra.toString()).thenReturn("ra-toString");
75
76         response.setResponseAction(ra);
77
78         Assert.assertEquals(
79             "Response [responseCode=code, responseMessage=msg, responseAction=ra-toString, responseActionHanlder=rah]",
80             response.toString());
81     }
82
83 }