summaryrefslogtreecommitdiffstats
path: root/juju
diff options
context:
space:
mode:
Diffstat (limited to 'juju')
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/pom.xml31
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/ConfigRoa.java165
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/ConfigRoaTest.java55
3 files changed, 124 insertions, 127 deletions
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/pom.xml b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/pom.xml
index 8b7757c..6dc7b69 100644
--- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/pom.xml
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/pom.xml
@@ -214,24 +214,41 @@
<version>2.2.2</version>
</dependency>
<!--authorization.filter -->
+ <!-- UT coverage dependency start -->
<dependency>
- <groupId>org.jmockit</groupId>
- <artifactId>jmockit</artifactId>
- <version>1.19</version>
- <type>jar</type>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-core</artifactId>
+ <version>1.5.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.5.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
- <artifactId>jmockit-coverage</artifactId>
+ <artifactId>jmockit</artifactId>
<version>1.19</version>
- <type>jar</type>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.11</version>
+ <version>4.12</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit-coverage</artifactId>
+ <version>1.19</version>
<scope>test</scope>
</dependency>
+
+ <!-- UT coverage dependency end -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/ConfigRoa.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/ConfigRoa.java
index 613f5cc..1e6bf03 100644
--- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/ConfigRoa.java
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/ConfigRoa.java
@@ -16,9 +16,11 @@
package org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.rest;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
+import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.EntityUtils;
+import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.SwitchController;
+import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.restclient.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -30,26 +32,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.EntityUtils;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.FileUtils;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.JujuConfigUtil;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.SwitchController;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.VnfmUtil;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.EntityUtils.ExeRes;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.servicetoken.JujuVnfmRestfulUtil;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.servicetoken.VnfmRestfulUtil;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.adapter.impl.AdapterResourceManager;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.constant.Constant;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.constant.UrlConstant;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.restclient.ServiceException;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.restclient.RestfulResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import mockit.Mock;
-import mockit.MockUp;
-import net.sf.json.JSONObject;
-
/**
* <br/>
* <p>
@@ -112,52 +94,53 @@ public class ConfigRoa {
* @throws ServiceException
* @since NFVO 0.5
*/
- @GET
- @Path("/mock/{methodName}")
- public boolean mock(@PathParam("methodName") String methodName, @Context HttpServletRequest context,
- @Context HttpServletResponse resp) throws ServiceException {
- if("getVnfmById".equals(methodName)) {
- new MockUp<VnfmUtil>() {
-
- @Mock
- public JSONObject getVnfmById(String vnfmId) {
- JSONObject json = new JSONObject();
- json.put("vnfmId", vnfmId);
- json.put("vnfdId", "testVnfdId");
- json.put("vnfPackageId", "testPackageId");
- json.put("version", "1");
- json.put("url", JujuConfigUtil.getValue("jujuvnfm_server_url"));
- return json;
- }
- };
- } else if("execute".equals(methodName)) {
- new MockUp<EntityUtils>() {
-
- @Mock
- public ExeRes execute(String dir, List<String> command) {
- ExeRes er = new ExeRes();
- String resContent = null;
- try {
- resContent = new String(
- FileUtils.readFile(new File(JujuConfigUtil.getValue("juju_cmd_res_file")), "UTF-8"));
- } catch(Exception e) {
- LOG.error("mock fail",e);
- resContent = "mock fail";
- }
- er.setBody(resContent);
- return er;
- }
- };
- }else if("fetchDownloadUrlFromCatalog".equals(methodName)) {
- new MockUp<AdapterResourceManager>() {
- @Mock
- public String fetchDownloadUrlFromCatalog(String csarId){
- return JujuConfigUtil.getValue("catalog_download_url");
- }
- };
- }
- return true;
- }
+ /*
+ * @GET
+ * @Path("/mock/{methodName}")
+ * public boolean mock(@PathParam("methodName") String methodName, @Context HttpServletRequest
+ * context,
+ * @Context HttpServletResponse resp) throws ServiceException {
+ * if("getVnfmById".equals(methodName)) {
+ * new MockUp<VnfmUtil>() {
+ * @Mock
+ * public JSONObject getVnfmById(String vnfmId) {
+ * JSONObject json = new JSONObject();
+ * json.put("vnfmId", vnfmId);
+ * json.put("vnfdId", "testVnfdId");
+ * json.put("vnfPackageId", "testPackageId");
+ * json.put("version", "1");
+ * json.put("url", JujuConfigUtil.getValue("jujuvnfm_server_url"));
+ * return json;
+ * }
+ * };
+ * } else if("execute".equals(methodName)) {
+ * new MockUp<EntityUtils>() {
+ * @Mock
+ * public ExeRes execute(String dir, List<String> command) {
+ * ExeRes er = new ExeRes();
+ * String resContent = null;
+ * try {
+ * resContent = new String(
+ * FileUtils.readFile(new File(JujuConfigUtil.getValue("juju_cmd_res_file")), "UTF-8"));
+ * } catch(Exception e) {
+ * LOG.error("mock fail", e);
+ * resContent = "mock fail";
+ * }
+ * er.setBody(resContent);
+ * return er;
+ * }
+ * };
+ * } else if("fetchDownloadUrlFromCatalog".equals(methodName)) {
+ * new MockUp<AdapterResourceManager>() {
+ * @Mock
+ * public String fetchDownloadUrlFromCatalog(String csarId) {
+ * return JujuConfigUtil.getValue("catalog_download_url");
+ * }
+ * };
+ * }
+ * return true;
+ * }
+ */
/**
* <br/>
@@ -169,25 +152,27 @@ public class ConfigRoa {
* @throws ServiceException
* @since NFVO 0.5
*/
- @GET
- @Path("/unmock/{methodName}")
- public boolean unmock(@PathParam("methodName") String methodName, @Context HttpServletRequest context,
- @Context HttpServletResponse resp) throws ServiceException {
- if("getVnfmById".equals(methodName)) {
- new MockUp<VnfmUtil>() {
-
- @Mock
- public JSONObject getVnfmById(String vnfmId) {
- RestfulResponse rsp = VnfmRestfulUtil.getRemoteResponse(
- String.format(UrlConstant.REST_ESRINFO_GET, vnfmId), JujuVnfmRestfulUtil.GET_TYPE, null);
- if(rsp == null || rsp.getStatus() != Constant.HTTP_OK) {
- return null;
- }
- LOG.error("funtion=getVnfmById, status={}", rsp.getStatus());
- return JSONObject.fromObject(rsp.getResponseContent());
- }
- };
- }
- return true;
- }
+ /*
+ * @GET
+ * @Path("/unmock/{methodName}")
+ * public boolean unmock(@PathParam("methodName") String methodName, @Context HttpServletRequest
+ * context,
+ * @Context HttpServletResponse resp) throws ServiceException {
+ * if("getVnfmById".equals(methodName)) {
+ * new MockUp<VnfmUtil>() {
+ * @Mock
+ * public JSONObject getVnfmById(String vnfmId) {
+ * RestfulResponse rsp = VnfmRestfulUtil.getRemoteResponse(
+ * String.format(UrlConstant.REST_ESRINFO_GET, vnfmId), JujuVnfmRestfulUtil.GET_TYPE, null);
+ * if(rsp == null || rsp.getStatus() != Constant.HTTP_OK) {
+ * return null;
+ * }
+ * LOG.error("funtion=getVnfmById, status={}", rsp.getStatus());
+ * return JSONObject.fromObject(rsp.getResponseContent());
+ * }
+ * };
+ * }
+ * return true;
+ * }
+ */
}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/ConfigRoaTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/ConfigRoaTest.java
index 7531224..480f837 100644
--- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/ConfigRoaTest.java
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/ConfigRoaTest.java
@@ -13,27 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.rest;
-
-import static org.junit.Assert.*;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+package org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.rest;
import org.junit.Before;
import org.junit.Test;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.JujuConfigUtil;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.servicetoken.VnfmRestfulUtil;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.rest.ConfigRoa;
import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.restclient.ServiceException;
-import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.restclient.RestfulResponse;
import org.springframework.mock.web.MockHttpServletResponse;
-import mockit.Mock;
-import mockit.MockUp;
-import net.sf.json.JSONObject;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
public class ConfigRoaTest {
+
ConfigRoa roa;
@Before
@@ -65,22 +61,21 @@ public class ConfigRoaTest {
assertFalse(res);
}
- @Test
- public void testmock() throws ServiceException {
- HttpServletRequest context = null;
- HttpServletResponse resp = new MockHttpServletResponse();
- String methodName = "getVnfmById";
- JSONObject json = new JSONObject();
-
- new MockUp<JujuConfigUtil>() {
- @Mock
- public String getValue(String key) {
- return null;
- }
-
- };
- roa.mock(methodName, context, resp);
- roa.unmock(methodName, context, resp);
-
- }
+ /*
+ * @Test
+ * public void testmock() throws ServiceException {
+ * HttpServletRequest context = null;
+ * HttpServletResponse resp = new MockHttpServletResponse();
+ * String methodName = "getVnfmById";
+ * JSONObject json = new JSONObject();
+ * new MockUp<JujuConfigUtil>() {
+ * @Mock
+ * public String getValue(String key) {
+ * return null;
+ * }
+ * };
+ * roa.mock(methodName, context, resp);
+ * roa.unmock(methodName, context, resp);
+ * }
+ */
}