Sonar fix 20/79420/1
authorKanagaraj Manickam <kanagaraj.manickam@huawei.com>
Fri, 1 Mar 2019 04:43:51 +0000 (10:13 +0530)
committerKanagaraj Manickam <kanagaraj.manickam@huawei.com>
Fri, 1 Mar 2019 04:44:32 +0000 (10:14 +0530)
Issue-ID: VFC-1266
Change-Id: Id3429c606f9370bf6e373abd8b7b76067f013eee
Signed-off-by: Kanagaraj Manickam <kanagaraj.manickam@huawei.com>
.gitignore
service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/conf/ConfigTest.java [new file with mode: 0644]
service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/util/request/RequestUtilTest.java
service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/DefaultAsyncCallbackTest.java [new file with mode: 0644]
service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/ExceptionArgsTest.java [new file with mode: 0644]
service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/HttpsRestTest.java [new file with mode: 0644]
service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/TestHttpRest.java
service/src/test/java/org/onap/vfc/nfvo/multivimproxy/service/adapter/impl/MultivimProxyAdapter2MSBManagerTest.java [new file with mode: 0644]
service/src/test/java/org/onap/vfc/nfvo/multivimproxy/service/adapter/impl/MultivimProxyAdapterMgrServiceTest.java [new file with mode: 0644]
service/src/test/java/org/onap/vfc/nfvo/multivimproxy/service/rest/ProxyRoaTest.java [new file with mode: 0644]

index 1f25160..ae8480e 100644 (file)
@@ -1,4 +1,4 @@
-/target/
+target/
 .iml
 .project
 .settings/
diff --git a/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/conf/ConfigTest.java b/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/conf/ConfigTest.java
new file mode 100644 (file)
index 0000000..3a7b7b6
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2018 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.multivimproxy.common.conf;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.onap.vfc.nfvo.multivimproxy.common.constant.Constant;
+
+import java.util.Properties;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+
+public class ConfigTest {
+
+
+    @Before
+    public void setUp() throws Exception {
+    }
+    @Test
+    public void testGetter()
+    {
+        Config.getHost();
+        Config.getCloudRegionId();
+        Config.getOpenstackPrefix();
+        Config.getCloudOwner();
+        Config.getGlobalCustomerId();
+        Config.getPort();
+        Config.getServiceType();
+        Config.getTenantId();
+    }
+ /*    @Test(expected = RuntimeException.class)
+    public void testException() throws Exception
+    {
+       Properties prps =mock(Properties.class);
+        prps.load(Config.class.getClassLoader().getResourceAsStream(Constant.CONF));
+    }
+*/
+}
index 2c8b6c9..471bb82 100644 (file)
@@ -189,7 +189,7 @@ public class RequestUtilTest {
         };
         JSONObject result = RequestUtil.getAllJsonRequestBody(context);
         JSONObject expectedResult = new JSONObject();
-        expectedResult.put("header", new HashMap<String, String>());
+       expectedResult.put("header", new HashMap<String, String>());
         assertEquals(expectedResult, result);
     }
 
diff --git a/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/DefaultAsyncCallbackTest.java b/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/DefaultAsyncCallbackTest.java
new file mode 100644 (file)
index 0000000..e92ca86
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2018 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.multivimproxy.common.util.restclient;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class DefaultAsyncCallbackTest {
+    DefaultAsyncCallback defaultAsyncCallback = new DefaultAsyncCallback();
+
+    @Test
+    public void testCallback() {
+        defaultAsyncCallback.callback(null);
+    }
+
+    @Test
+    public void testHandleExcepion() {
+        defaultAsyncCallback.handleExcepion(null);
+    }
+}
\ No newline at end of file
diff --git a/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/ExceptionArgsTest.java b/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/ExceptionArgsTest.java
new file mode 100644 (file)
index 0000000..106f015
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2018 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.multivimproxy.common.util.restclient;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class ExceptionArgsTest {
+
+
+    ExceptionArgs exceptionArgs= new ExceptionArgs();
+    ExceptionArgs exceptionArgs2= new ExceptionArgs(null,null,null,null);
+    String[] descArgs={"a","b"};
+    String[] reasonArgs={"a","b"};
+    String[] detailArgs={"a","b"};
+    String[] adviceArgs={"a","b"};
+    @Before
+    public void setUp() throws Exception {
+    }
+    @Test
+    public void testGetterSetter()
+    {
+        exceptionArgs.setAdviceArgs(adviceArgs);
+        exceptionArgs.setDescArgs(descArgs);
+        exceptionArgs.setDetailArgs(detailArgs);
+        exceptionArgs.setReasonArgs(reasonArgs);
+        exceptionArgs.getAdviceArgs();
+        exceptionArgs.getDescArgs();
+        exceptionArgs.getDetailArgs();
+        exceptionArgs.getReasonArgs();
+    }
+
+}
\ No newline at end of file
diff --git a/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/HttpsRestTest.java b/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/HttpsRestTest.java
new file mode 100644 (file)
index 0000000..b988897
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2018 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.multivimproxy.common.util.restclient;
+
+
+import org.eclipse.jetty.client.HttpClient;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import static org.mockito.Mockito.*;
+
+
+public class HttpsRestTest {
+
+
+    @InjectMocks
+    HttpsRest httpsRest;
+    @Mock
+    HttpClient client;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+    }
+
+   /* @Test
+    public void testInitHttpsRest() throws Exception {
+       // httpsRest.initHttpsRest();
+
+    }
+    @Test(expected = Exception.class)
+    public void testInitHttpsRestIsNull() throws Exception {
+        //doThrow(Exception.class).when(client).start();
+        //verify(client).start();
+
+
+    }*/
+
+    @Test
+    public void testGet() throws Exception {
+        httpsRest.get("huawei", null);
+    }
+
+    @Test
+    public void testHead() throws Exception {
+        httpsRest.head("huawei", null);
+    }
+
+    @Test
+    public void testHead2() throws Exception {
+        httpsRest.head("huawei", null, null);
+    }
+
+    @Test
+    public void testAsyncGet() throws Exception {
+        httpsRest.asyncGet("huawei", null, null);
+    }
+
+    @Test
+    public void testAsyncGet2() throws Exception {
+        httpsRest.asyncGet("huawei", null, null, null);
+    }
+
+    @Test
+    public void testPut() throws Exception {
+        httpsRest.put("huawei", null);
+    }
+
+    @Test
+    public void testDelete() throws Exception {
+        httpsRest.delete("huawei", null);
+
+    }
+
+    @Test
+    public void testPatch() throws Exception {
+        httpsRest.patch("huawei", null);
+    }
+
+    @Test
+    public void testPatch2() throws Exception {
+        httpsRest.patch("huawei", null, null);
+    }
+
+    @Test
+    public void testPost() throws Exception {
+        httpsRest.post("huawei", null);
+    }
+
+
+}
\ No newline at end of file
index bbcb675..65ef65a 100644 (file)
@@ -98,6 +98,12 @@ public class TestHttpRest {
      * @throws Exception
      * @since
      */
+    @Test(expected = ServiceException.class)
+    public void testInitHttpRestIsNull() throws Exception
+    {
+        HttpRest httpRest = new HttpRest();
+        httpRest.initHttpRest(null);
+    }
     @Test
     public void testInitHttpRest() throws Exception {
         final RestfulOptions options = new RestfulOptions();
diff --git a/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/service/adapter/impl/MultivimProxyAdapter2MSBManagerTest.java b/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/service/adapter/impl/MultivimProxyAdapter2MSBManagerTest.java
new file mode 100644 (file)
index 0000000..8b59b24
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2018 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.multivimproxy.service.adapter.impl;
+
+import net.sf.json.JSONObject;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+
+public class MultivimProxyAdapter2MSBManagerTest {
+
+    Map map=mock(Map.class);
+    MultivimProxyAdapter2MSBManager multivimProxyAdapter2MSBManager;
+    @Before
+    public void setUp()
+    {
+        multivimProxyAdapter2MSBManager=new MultivimProxyAdapter2MSBManager();
+
+    }
+    @Test
+    public void testRegisterProxy()
+    {
+        JSONObject jobj= new JSONObject();
+        jobj.put("name","huawei");
+
+        multivimProxyAdapter2MSBManager.registerProxy(map,jobj);
+    }
+    @Test
+    public void testUnregisterProxy() {
+        multivimProxyAdapter2MSBManager.unregisterProxy(map);
+    }
+    }
+
diff --git a/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/service/adapter/impl/MultivimProxyAdapterMgrServiceTest.java b/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/service/adapter/impl/MultivimProxyAdapterMgrServiceTest.java
new file mode 100644 (file)
index 0000000..700f107
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2018 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.multivimproxy.service.adapter.impl;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+public class MultivimProxyAdapterMgrServiceTest {
+
+    MultivimProxyAdapterMgrService mgrService;
+
+    @Before
+    public void setUp() throws Exception {
+        mgrService = new MultivimProxyAdapterMgrService();
+    }
+
+    @Test
+    public void testRegister() {
+        mgrService.register();
+
+    }
+
+    @Test
+    public void testReadVimAdapterInfoFromJson() throws Exception{
+        MultivimProxyAdapterMgrService.readVimAdapterInfoFromJson();
+    }
+
+
+}
+
diff --git a/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/service/rest/ProxyRoaTest.java b/service/src/test/java/org/onap/vfc/nfvo/multivimproxy/service/rest/ProxyRoaTest.java
new file mode 100644 (file)
index 0000000..b258816
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2018 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.multivimproxy.service.rest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import mockit.Mocked;
+import net.sf.json.JSONObject;
+import org.apache.cxf.jaxrs.impl.HttpServletRequestFilter;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.vfc.nfvo.multivimproxy.common.util.request.RequestUtil;
+
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.List;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ProxyRoaTest {
+    ProxyRoa proxyRoa;
+
+    HttpServletRequest httpServletRequest= mock(HttpServletRequest.class);
+
+    HttpServletResponse httpServletResponse= mock(HttpServletResponse.class);
+
+    @Before
+    public void setUp() throws Exception {
+        proxyRoa = new ProxyRoa();
+    }
+
+    @Test
+    public void testApidoc() throws Exception {
+        proxyRoa.apidoc();
+    }
+
+    /*@Test
+    public void testCreateTokens() {
+
+       proxyRoa.createTokens(httpServletRequest, httpServletResponse);
+    }
+    @Test
+    public void testProxyPost() {
+
+        proxyRoa.proxyPost(httpServletRequest, httpServletResponse);
+    }
+    @Test
+    public void testProxyPut() {
+
+        proxyRoa.porxyPut(httpServletRequest, httpServletResponse);
+    }
+*/
+}
\ No newline at end of file