2 * Copyright 2016-2017 Huawei Technologies Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.openo.nfvo.resmanagement.common.util.response;
19 import static org.junit.Assert.*;
21 import java.lang.reflect.Constructor;
22 import java.lang.reflect.Modifier;
25 import org.junit.Test;
29 import net.sf.json.JSONObject;
31 public class RoaResponseUtilTest {
34 public void testGet() {
35 new MockUp<ResponseUtil>() {
38 public JSONObject genHttpResponse(int retCode, String msg, Map<String, Object> map) {
42 JSONObject result = RoaResponseUtil.get(null);
43 JSONObject expectedResult = null;
44 assertEquals(expectedResult, result);
48 public void testAdd() {
50 new MockUp<ResponseUtil>() {
53 public JSONObject genHttpResponse(int retCode, String msg) {
57 JSONObject result = RoaResponseUtil.add(a);
58 JSONObject expectedResult = null;
59 assertEquals(expectedResult, result);
63 public void testAdd1() {
65 new MockUp<ResponseUtil>() {
68 public JSONObject genHttpResponse(int retCode, String msg) {
72 JSONObject result = RoaResponseUtil.add(a);
73 JSONObject expectedResult = null;
74 assertEquals(expectedResult, result);
78 public void testUpdate() {
80 new MockUp<ResponseUtil>() {
83 public JSONObject genHttpResponse(int retCode, String msg) {
87 JSONObject result = RoaResponseUtil.update(a);
88 JSONObject expectedResult = null;
89 assertEquals(expectedResult, result);
93 public void testUpdate1() {
95 new MockUp<ResponseUtil>() {
98 public JSONObject genHttpResponse(int retCode, String msg) {
102 JSONObject result = RoaResponseUtil.update(a);
103 JSONObject expectedResult = null;
104 assertEquals(expectedResult, result);
108 public void testDelete() {
110 new MockUp<ResponseUtil>() {
113 public JSONObject genHttpResponse(int retCode, String msg) {
117 JSONObject result = RoaResponseUtil.delete(a);
118 JSONObject expectedResult = null;
119 assertEquals(expectedResult, result);
123 public void testDelete1() {
125 new MockUp<ResponseUtil>() {
128 public JSONObject genHttpResponse(int retCode, String msg) {
132 JSONObject result = RoaResponseUtil.delete(a);
133 JSONObject expectedResult = null;
134 assertEquals(expectedResult, result);
138 public void testPrivateConstructor() throws Exception {
139 Constructor constructor = RoaResponseUtil.class.getDeclaredConstructor();
140 assertTrue("Constructor is not private", Modifier.isPrivate(constructor.getModifiers()));
142 constructor.setAccessible(true);
143 constructor.newInstance();