9b699448b1f4b0816b5708a2f29972e9267ec8b0
[vfc/nfvo/resmanagement.git] /
1 /*
2  * Copyright 2016-2017 Huawei Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.vfc.nfvo.res.common.util.response;
18
19 import static org.junit.Assert.*;
20
21 import java.lang.reflect.Constructor;
22 import java.lang.reflect.Modifier;
23 import java.util.Map;
24
25 import org.junit.Test;
26 import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil;
27 import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil;
28
29 import mockit.Mock;
30 import mockit.MockUp;
31 import net.sf.json.JSONObject;
32
33 public class RoaResponseUtilTest {
34
35     @Test
36     public void testGet() {
37         new MockUp<ResponseUtil>() {
38
39             @Mock
40             public JSONObject genHttpResponse(int retCode, String msg, Map<String, Object> map) {
41                 return null;
42             }
43         };
44         JSONObject result = RoaResponseUtil.get(null);
45         JSONObject expectedResult = null;
46         assertEquals(expectedResult, result);
47     }
48
49     @Test
50     public void testAdd() {
51         int a = 0;
52         new MockUp<ResponseUtil>() {
53
54             @Mock
55             public JSONObject genHttpResponse(int retCode, String msg) {
56                 return null;
57             }
58         };
59         JSONObject result = RoaResponseUtil.add(a);
60         JSONObject expectedResult = null;
61         assertEquals(expectedResult, result);
62     }
63
64     @Test
65     public void testAdd1() {
66         int a = 2;
67         new MockUp<ResponseUtil>() {
68
69             @Mock
70             public JSONObject genHttpResponse(int retCode, String msg) {
71                 return null;
72             }
73         };
74         JSONObject result = RoaResponseUtil.add(a);
75         JSONObject expectedResult = null;
76         assertEquals(expectedResult, result);
77     }
78
79     @Test
80     public void testUpdate() {
81         int a = 0;
82         new MockUp<ResponseUtil>() {
83
84             @Mock
85             public JSONObject genHttpResponse(int retCode, String msg) {
86                 return null;
87             }
88         };
89         JSONObject result = RoaResponseUtil.update(a);
90         JSONObject expectedResult = null;
91         assertEquals(expectedResult, result);
92     }
93
94     @Test
95     public void testUpdate1() {
96         int a = 2;
97         new MockUp<ResponseUtil>() {
98
99             @Mock
100             public JSONObject genHttpResponse(int retCode, String msg) {
101                 return null;
102             }
103         };
104         JSONObject result = RoaResponseUtil.update(a);
105         JSONObject expectedResult = null;
106         assertEquals(expectedResult, result);
107     }
108
109     @Test
110     public void testDelete() {
111         int a = -1;
112         new MockUp<ResponseUtil>() {
113
114             @Mock
115             public JSONObject genHttpResponse(int retCode, String msg) {
116                 return null;
117             }
118         };
119         JSONObject result = RoaResponseUtil.delete(a);
120         JSONObject expectedResult = null;
121         assertEquals(expectedResult, result);
122     }
123
124     @Test
125     public void testDelete1() {
126         int a = 0;
127         new MockUp<ResponseUtil>() {
128
129             @Mock
130             public JSONObject genHttpResponse(int retCode, String msg) {
131                 return null;
132             }
133         };
134         JSONObject result = RoaResponseUtil.delete(a);
135         JSONObject expectedResult = null;
136         assertEquals(expectedResult, result);
137     }
138
139     @Test
140     public void testPrivateConstructor() throws Exception {
141         Constructor constructor = RoaResponseUtil.class.getDeclaredConstructor();
142         assertTrue("Constructor is not private", Modifier.isPrivate(constructor.getModifiers()));
143
144         constructor.setAccessible(true);
145         constructor.newInstance();
146     }
147
148 }