1e305876911fbfd35bb1f413a4d2cf079c75be84
[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.openo.nfvo.resmanagement.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
27 import mockit.Mock;
28 import mockit.MockUp;
29 import net.sf.json.JSONObject;
30
31 public class RoaResponseUtilTest {
32
33     @Test
34     public void testGet() {
35         new MockUp<ResponseUtil>() {
36
37             @Mock
38             public JSONObject genHttpResponse(int retCode, String msg, Map<String, Object> map) {
39                 return null;
40             }
41         };
42         JSONObject result = RoaResponseUtil.get(null);
43         JSONObject expectedResult = null;
44         assertEquals(expectedResult, result);
45     }
46
47     @Test
48     public void testAdd() {
49         int a = 0;
50         new MockUp<ResponseUtil>() {
51
52             @Mock
53             public JSONObject genHttpResponse(int retCode, String msg) {
54                 return null;
55             }
56         };
57         JSONObject result = RoaResponseUtil.add(a);
58         JSONObject expectedResult = null;
59         assertEquals(expectedResult, result);
60     }
61
62     @Test
63     public void testAdd1() {
64         int a = 2;
65         new MockUp<ResponseUtil>() {
66
67             @Mock
68             public JSONObject genHttpResponse(int retCode, String msg) {
69                 return null;
70             }
71         };
72         JSONObject result = RoaResponseUtil.add(a);
73         JSONObject expectedResult = null;
74         assertEquals(expectedResult, result);
75     }
76
77     @Test
78     public void testUpdate() {
79         int a = 0;
80         new MockUp<ResponseUtil>() {
81
82             @Mock
83             public JSONObject genHttpResponse(int retCode, String msg) {
84                 return null;
85             }
86         };
87         JSONObject result = RoaResponseUtil.update(a);
88         JSONObject expectedResult = null;
89         assertEquals(expectedResult, result);
90     }
91
92     @Test
93     public void testUpdate1() {
94         int a = 2;
95         new MockUp<ResponseUtil>() {
96
97             @Mock
98             public JSONObject genHttpResponse(int retCode, String msg) {
99                 return null;
100             }
101         };
102         JSONObject result = RoaResponseUtil.update(a);
103         JSONObject expectedResult = null;
104         assertEquals(expectedResult, result);
105     }
106
107     @Test
108     public void testDelete() {
109         int a = -1;
110         new MockUp<ResponseUtil>() {
111
112             @Mock
113             public JSONObject genHttpResponse(int retCode, String msg) {
114                 return null;
115             }
116         };
117         JSONObject result = RoaResponseUtil.delete(a);
118         JSONObject expectedResult = null;
119         assertEquals(expectedResult, result);
120     }
121
122     @Test
123     public void testDelete1() {
124         int a = 0;
125         new MockUp<ResponseUtil>() {
126
127             @Mock
128             public JSONObject genHttpResponse(int retCode, String msg) {
129                 return null;
130             }
131         };
132         JSONObject result = RoaResponseUtil.delete(a);
133         JSONObject expectedResult = null;
134         assertEquals(expectedResult, result);
135     }
136
137     @Test
138     public void testPrivateConstructor() throws Exception {
139         Constructor constructor = RoaResponseUtil.class.getDeclaredConstructor();
140         assertTrue("Constructor is not private", Modifier.isPrivate(constructor.getModifiers()));
141
142         constructor.setAccessible(true);
143         constructor.newInstance();
144     }
145
146 }