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.onap.vfc.nfvo.res.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;
26 import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil;
27 import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil;
31 import net.sf.json.JSONObject;
33 public class RoaResponseUtilTest {
36 public void testGet() {
37 new MockUp<ResponseUtil>() {
40 public JSONObject genHttpResponse(int retCode, String msg, Map<String, Object> map) {
44 JSONObject result = RoaResponseUtil.get(null);
45 JSONObject expectedResult = null;
46 assertEquals(expectedResult, result);
50 public void testAdd() {
52 new MockUp<ResponseUtil>() {
55 public JSONObject genHttpResponse(int retCode, String msg) {
59 JSONObject result = RoaResponseUtil.add(a);
60 JSONObject expectedResult = null;
61 assertEquals(expectedResult, result);
65 public void testAdd1() {
67 new MockUp<ResponseUtil>() {
70 public JSONObject genHttpResponse(int retCode, String msg) {
74 JSONObject result = RoaResponseUtil.add(a);
75 JSONObject expectedResult = null;
76 assertEquals(expectedResult, result);
80 public void testUpdate() {
82 new MockUp<ResponseUtil>() {
85 public JSONObject genHttpResponse(int retCode, String msg) {
89 JSONObject result = RoaResponseUtil.update(a);
90 JSONObject expectedResult = null;
91 assertEquals(expectedResult, result);
95 public void testUpdate1() {
97 new MockUp<ResponseUtil>() {
100 public JSONObject genHttpResponse(int retCode, String msg) {
104 JSONObject result = RoaResponseUtil.update(a);
105 JSONObject expectedResult = null;
106 assertEquals(expectedResult, result);
110 public void testDelete() {
112 new MockUp<ResponseUtil>() {
115 public JSONObject genHttpResponse(int retCode, String msg) {
119 JSONObject result = RoaResponseUtil.delete(a);
120 JSONObject expectedResult = null;
121 assertEquals(expectedResult, result);
125 public void testDelete1() {
127 new MockUp<ResponseUtil>() {
130 public JSONObject genHttpResponse(int retCode, String msg) {
134 JSONObject result = RoaResponseUtil.delete(a);
135 JSONObject expectedResult = null;
136 assertEquals(expectedResult, result);
140 public void testPrivateConstructor() throws Exception {
141 Constructor constructor = RoaResponseUtil.class.getDeclaredConstructor();
142 assertTrue("Constructor is not private", Modifier.isPrivate(constructor.getModifiers()));
144 constructor.setAccessible(true);
145 constructor.newInstance();