summaryrefslogtreecommitdiffstats
path: root/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test')
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/AsyncCallbackTest.java44
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/CryptUtilTest.java42
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/DownloadCsarManagerTest.java42
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/EntityUtilsTest.java63
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/FileUtil.java50
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/FileUtilsTest.java94
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/JujuConfigUtilTest.java35
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/LocalComandUtilsTest.java57
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/ResourceUtilTest.java40
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/SpringContextHolderTest.java44
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/StringUtilTest.java122
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/TestPojo.java47
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/UnCompressUtilTest.java78
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/VNFJsonUtilTest.java250
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/VnfmUtilTest.java123
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/YamlUtilTest.java48
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/HttpRestHelpTest.java58
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/HttpRestfulHelpTest.java58
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/JujuVnfmRestfulUtilTest.java247
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/VNFAuthConfigInfoTest.java68
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/VNFRestfulUtilTest.java257
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java224
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/module/AccessTokensTest.java98
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/module/ServiceTokenHelpTest.java28
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/activator/ROAJujuServicePostProcessorTest.java34
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/AdapterResourceManagerTest.java212
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/JujuAdapter2MSBManagerTest.java267
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/JujuClientManagerTest.java126
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/ProcessMockImpl.java76
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrServiceTest.java28
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/constant/ConstantTest.java42
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/constant/ParamConstantsTest.java35
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/constant/UrlConstantTest.java34
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuDriverTest.java309
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfdTest.java154
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfmInfoExampleTest.java165
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfmInfoTest.java182
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfmTest.java347
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/MSBRequestEntityTest.java79
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/VnfmOpResultTest.java129
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/VnfmTest.java347
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/exception/UnsupportedOperationExceptionTest.java36
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/juju/config/ConfigItemTest.java45
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/juju/config/ConfigTest.java40
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/juju/config/OptionsTest.java35
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/process/VnfMgrTest.java404
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/process/VnfResourceMgrTest.java80
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/ConfigRoaTest.java85
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/JujuClientRoaTest.java132
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/TestMockUp.java61
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/VnfResourceRoaTest.java59
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/VnfRoaTest.java215
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/exceptionmapper/ExceptionMessageTest.java45
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/exceptionmapper/GenericExceptionMapperTest.java43
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/exceptionmapper/ServiceExceptionMapperTest.java44
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/fullstack/JujuClientRoaTest.java163
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/fullstack/TestHelper.java72
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/deployService.json4
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/destroyService.json2
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/example.json1
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/setCharmUrl.json2
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/test.xml41
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/test.yaml10
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/webapp/webtest.xml15
64 files changed, 6417 insertions, 0 deletions
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/AsyncCallbackTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/AsyncCallbackTest.java
new file mode 100644
index 0000000..ea01d2b
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/AsyncCallbackTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.common;
+
+import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.roa.util.restclient.RestfulResponse;
+import org.openo.nfvo.jujuvnfmadapter.service.rest.fullstack.JujuClientRoaTest;
+
+public class AsyncCallbackTest {
+ Logger logger = Logger.getLogger(JujuClientRoaTest.class);
+
+ AsyncCallback Async;
+ RestfulResponse response = new RestfulResponse();
+
+ @Before
+ public void setUp() {
+ Async = new AsyncCallback();
+
+ }
+
+ @Test
+ public void testhandleExcepion() {
+
+ logger.warn("function=callback, msg=status={}, content={}.");
+ Async.callback(response);
+ Async.handleExcepion(null);
+
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/CryptUtilTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/CryptUtilTest.java
new file mode 100644
index 0000000..28350b4
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/CryptUtilTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.common;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import org.junit.Test;
+
+public class CryptUtilTest {
+
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = CryptUtil.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+ @Test
+ public void testdeCryptenCrypt(){
+ String pwd ="admin";
+ String c=CryptUtil.deCrypt(pwd);
+ String c1=CryptUtil.enCrypt(pwd);
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/DownloadCsarManagerTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/DownloadCsarManagerTest.java
new file mode 100644
index 0000000..d4eee79
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/DownloadCsarManagerTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 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.openo.nfvo.jujuvnfmadapter.common;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import org.junit.Test;
+
+public class DownloadCsarManagerTest {
+ DownloadCsarManager mgr;
+ @Test
+ public void test() {
+ String url="";
+ String filepath="";
+ mgr.download(url);
+ mgr.download(url, filepath);
+ mgr.getRandomFileName();
+ }
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = DownloadCsarManager.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/EntityUtilsTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/EntityUtilsTest.java
new file mode 100644
index 0000000..0fed60d
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/EntityUtilsTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.common;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.common.EntityUtils.ExeRes;
+
+import net.sf.json.JSONObject;
+
+public class EntityUtilsTest {
+
+ @Test
+ public void formatCommandTest(){
+ List<String> command = new ArrayList<>();
+ command.add("test");
+ String result = EntityUtils.formatCommand(command);
+ assertTrue(result.contains("test"));
+ }
+ @Test
+ public void formatCommandTestNull(){
+ List<String> command = null;
+ String result = EntityUtils.formatCommand(command);
+ assertTrue(result.equals(""));
+ }
+ @Test
+ public void executeTest(){
+ ExeRes res = EntityUtils.execute("test", "test","test2");
+ assertNotNull(res);
+ }
+ @Test(expected = Exception.class)
+ public void toEntity() throws Exception{
+ JSONObject jsonObject = new JSONObject();
+ HashMap map = EntityUtils.toEntity(jsonObject, HashMap.class);
+ }
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = EntityUtils.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/FileUtil.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/FileUtil.java
new file mode 100644
index 0000000..6e03e32
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/FileUtil.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.common;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+public class FileUtil {
+
+ public static String ReadFile(String path) {
+ File file = new File(path);
+ BufferedReader reader = null;
+ String laststr = "";
+ try {
+ reader = new BufferedReader(new FileReader(file));
+ String tempString = null;
+ while((tempString = reader.readLine()) != null) {
+ laststr = laststr + tempString;
+ }
+ reader.close();
+ } catch(IOException e) {
+ e.printStackTrace();
+ } finally {
+ if(reader != null) {
+ try {
+ reader.close();
+ } catch(IOException e1) {
+ }
+ }
+ }
+ return laststr;
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/FileUtilsTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/FileUtilsTest.java
new file mode 100644
index 0000000..d41824c
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/FileUtilsTest.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.common;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class FileUtilsTest {
+
+ FileUtils fileUtils;
+ @Before
+ public void setUp(){
+ fileUtils.getAppAbsoluteUrl();
+ }
+
+ @Test
+ public void testWriteFile() throws Exception {
+ ClassLoader classLoader = getClass().getClassLoader();
+ File file = new File(classLoader.getResource("").getFile());
+ String filePath = "";
+ byte[] bytes = new byte[] {40,50};
+ int b = fileUtils.writeFile(bytes, filePath);
+ assertNotNull(b);
+ }
+ @Test
+ @Ignore
+ public void testReadFile() throws Exception {
+ ClassLoader classLoader = getClass().getClassLoader();
+ File f = new File(classLoader.getResource("").getFile());
+ System.out.println(f.isAbsolute());
+ String charsetName = "UTF-8";
+ byte[] b = fileUtils.readFile(f, charsetName);
+ assertNotNull(b);
+ }
+ @Test
+ public void testListFiles() throws Exception {
+ String file = ".";
+ File f = new File(file);
+ List<File> files = fileUtils.listFiles(f);
+ assertNotNull(files);
+
+ }
+ @Test
+ public void testMkDirs() throws Exception {
+ File resourcesDirectory = new File("src/test/resources");
+ String path = resourcesDirectory.getAbsolutePath()+"/TestDir";
+ resourcesDirectory.getAbsolutePath();
+ fileUtils.mkDirs(path);
+ }
+ @Test
+ public void testDelFiles() throws Exception {
+ File resourcesDirectory = new File("src/test/resources/TestDir/Test.txt");
+ assertTrue(fileUtils.delFiles(resourcesDirectory.getAbsolutePath()));
+ }
+ @Test
+ public void testgetFiles() throws Exception {
+ File resourcesDirectory = new File("src/test/resources");
+ List<File> files = fileUtils.getFiles(resourcesDirectory.getAbsolutePath());
+ assertNotNull(files);
+ }
+ @Test
+ public void testCopy() throws Exception {
+ File oldfile = new File("");
+ File newfile = new File("");
+ fileUtils.copy(oldfile.getAbsolutePath(), newfile.getAbsolutePath(), true);
+ }
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = FileUtils.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/JujuConfigUtilTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/JujuConfigUtilTest.java
new file mode 100644
index 0000000..1175fe8
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/JujuConfigUtilTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.common;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import org.junit.Test;
+
+public class JujuConfigUtilTest {
+
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = JujuConfigUtil.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/LocalComandUtilsTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/LocalComandUtilsTest.java
new file mode 100644
index 0000000..61b84d5
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/LocalComandUtilsTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.common;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.common.LocalComandUtils.ExeRes;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+public class LocalComandUtilsTest {
+
+ @Test
+ public void testformatCommand(){
+ new MockUp<LocalComandUtils>(){
+ @Mock
+ public String formatCommand(List<String> command){
+ return null;
+ }
+ };
+ List<String> command =new ArrayList<String> ();
+ command.add("test1");
+ command.add("test2");
+ String s=LocalComandUtils.formatCommand(command);
+
+
+ }
+
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = LocalComandUtils.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/ResourceUtilTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/ResourceUtilTest.java
new file mode 100644
index 0000000..ce6e755
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/ResourceUtilTest.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.common;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import org.junit.Test;
+
+
+public class ResourceUtilTest {
+
+ @Test
+ public void testformatCommand(){
+ String key="key";
+ String r=ResourceUtil.getMessage(key);
+ }
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = ResourceUtil.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/SpringContextHolderTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/SpringContextHolderTest.java
new file mode 100644
index 0000000..34c8c72
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/SpringContextHolderTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.common;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+
+
+public class SpringContextHolderTest {
+
+ SpringContextHolder contextholder;
+ @Before
+ public void setUp() {
+ contextholder = new SpringContextHolder();
+ }
+ @Autowired
+ ApplicationContext context;
+ @Test
+ public void test() {
+ SpringContextHolder ctx=new SpringContextHolder();
+ ctx.setApplicationContext(context);
+ contextholder.cleanApplicationContext();
+
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/StringUtilTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/StringUtilTest.java
new file mode 100644
index 0000000..ea95a8a
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/StringUtilTest.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.common;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import net.sf.json.JSONArray;
+
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.common.StringUtil;
+
+public class StringUtilTest {
+
+ @Test
+ public void testIsValidString() {
+ boolean result = StringUtil.isValidString("abc");
+ assertTrue(result);
+ }
+
+ @Test
+ public void testIsValidString1() {
+ boolean result = StringUtil.isValidString(" abc ");
+ assertTrue(result);
+ }
+
+ @Test
+ public void testIsValidString2() {
+ boolean result = StringUtil.isValidString(" ");
+ assertFalse(result);
+ }
+
+ @Test
+ public void testIsValidString3() {
+ boolean result = StringUtil.isValidString("");
+ assertFalse(result);
+ }
+
+ @Test
+ public void testIsValidString4() {
+ boolean result = StringUtil.isValidString(null);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testIsValidUrl() {
+ boolean result = StringUtil.isValidUrl("https://127.0.0.1:31943");
+ assertTrue(result);
+ }
+
+ @Test
+ public void testIsValidUrl1() {
+ boolean result = StringUtil.isValidUrl("http://255.250.255.1:31943");
+ assertTrue(result);
+ }
+
+ @Test
+ public void testIsValidUrl2() {
+ boolean result = StringUtil.isValidUrl("http:");
+ assertFalse(result);
+ }
+
+ @Test
+ public void testIsValidUrl3() {
+ boolean result = StringUtil.isValidUrl("http://255.250");
+ assertFalse(result);
+ }
+
+ @Test
+ public void testIsValidUrl4() {
+ boolean result = StringUtil.isValidUrl("");
+ assertFalse(result);
+ }
+
+ @Test
+ public void testIsValidAnyString() {
+ boolean result = StringUtil.isValidAnyString("abc", "aaa", "bbb");
+ assertTrue(result);
+ }
+
+ @Test
+ public void testIsValidAnyString1() {
+ boolean result = StringUtil.isValidAnyString("abc", "", "bbb");
+ assertFalse(result);
+ }
+
+ @Test
+ public void testTransSitesToArray() {
+ String sites = "Beijing&Shanghai";
+ JSONArray result = StringUtil.transSitesToArray(sites);
+
+ JSONArray siteArray = new JSONArray();
+ siteArray.add("Beijing");
+ siteArray.add("Shanghai");
+ assertEquals(siteArray, result);
+ }
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = StringUtil.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/TestPojo.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/TestPojo.java
new file mode 100644
index 0000000..04c3bcc
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/TestPojo.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.common;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestPojo {
+ String name;
+ String id;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Test
+ public void test(){
+ assertTrue(true);
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/UnCompressUtilTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/UnCompressUtilTest.java
new file mode 100644
index 0000000..c821cbf
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/UnCompressUtilTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.common;
+
+import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class UnCompressUtilTest {
+
+ UnCompressUtil util;
+
+ FileInputStream fis;
+
+ @Before
+ public void setUp(){
+ util = new UnCompressUtil();
+
+ }
+
+ @Test
+
+ public void unCompressGzipTest() {
+ String zipfileName = "";
+ String outputDirectory = "";
+ List<String> fileNames = new ArrayList<String>();
+ //fileNames.add("test1");
+ util.unCompressGzip(zipfileName, outputDirectory, fileNames);
+ }
+
+ @Test
+
+ public void unCompressZipTest() {
+ String zipfileName = "";
+ String outputDirectory = "";
+ List<String> fileNames = new ArrayList<String>();
+ util.unCompressZip(zipfileName, outputDirectory, fileNames);
+ }
+
+
+ @Test
+
+ public void unCompressTarXZTest() {
+ String zipfileName = "";
+ String outputDirectory = "";
+ List<String> fileNames = new ArrayList<String>();
+ util.unCompressTarXZ(zipfileName, outputDirectory, fileNames);
+ }
+
+ @Test
+
+ public void unCompressTest() {
+ String zipfileName = "";
+ String outputDirectory = "src//test//resources";
+ List<String> fileNames = new ArrayList<String>();
+ util.unCompress(zipfileName, outputDirectory, fileNames);
+ }
+
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/VNFJsonUtilTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/VNFJsonUtilTest.java
new file mode 100644
index 0000000..38aa3b9
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/VNFJsonUtilTest.java
@@ -0,0 +1,250 @@
+/*
+ * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.common;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import net.sf.json.JSONObject;
+import net.sf.json.JsonConfig;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.common.VNFJsonUtil;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.codehaus.jackson.map.type.TypeFactory;
+import org.codehaus.jackson.type.TypeReference;
+public class VNFJsonUtilTest {
+
+ @Test
+ public void testGetJsonFieldStr() {
+ JSONObject VNFJsonObj = new JSONObject();
+ VNFJsonObj.put("name", "testName");
+ String result = VNFJsonUtil.getJsonFieldStr(VNFJsonObj, "name");
+ assertEquals("testName", result);
+ }
+
+ @Test
+ public void testGetJsonFieldStrByNull() {
+ String result = VNFJsonUtil.getJsonFieldStr(null, "name");
+ assertEquals("", result);
+ }
+
+ @Test
+ public void testGetJsonFieldStrByFieldNameNull() {
+ JSONObject VNFJsonObj = new JSONObject();
+ VNFJsonObj.put("names", "testName");
+ String result = VNFJsonUtil.getJsonFieldStr(VNFJsonObj, "name");
+ assertEquals("", result);
+ }
+
+ @Test
+ public void testGetJsonFieldStrByNameNull() {
+ JSONObject VNFJsonObj = new JSONObject();
+ VNFJsonObj.put("name", "null");
+ String result = VNFJsonUtil.getJsonFieldStr(VNFJsonObj, "name");
+ assertEquals("", result);
+ }
+
+ @Test
+ public void testGetJsonFieldInt() {
+ JSONObject VNFJsonObj = new JSONObject();
+ VNFJsonObj.put("name", 5);
+ Integer result = VNFJsonUtil.getJsonFieldInt(VNFJsonObj, "name");
+ assertEquals((Integer)5, result);
+ }
+
+ @Test
+ public void testGetJsonFieldIntByNull() {
+ Integer result = VNFJsonUtil.getJsonFieldInt(null, "name");
+ assertEquals((Integer)0, result);
+ }
+
+ @Test
+ public void testGetJsonFieldIntByNameNull() {
+ JSONObject VNFJsonObj = new JSONObject();
+ VNFJsonObj.put("name", 5);
+ Integer result = VNFJsonUtil.getJsonFieldInt(VNFJsonObj, "names");
+ assertEquals((Integer)0, result);
+ }
+
+ @Test
+ public void testGetJsonFieldLong() {
+ JSONObject VNFJsonObj = new JSONObject();
+ VNFJsonObj.put("name", 5L);
+ Long result = VNFJsonUtil.getJsonFieldLong(VNFJsonObj, "name");
+ assertEquals((Long)5L, result);
+ }
+
+ @Test
+ public void testGetJsonFieldLongByNull() {
+ Long result = VNFJsonUtil.getJsonFieldLong(null, "name");
+ assertEquals((Long)0L, result);
+ }
+
+ @Test
+ public void testGetJsonFieldLongByNameNull() {
+ JSONObject VNFJsonObj = new JSONObject();
+ VNFJsonObj.put("name", 5L);
+ Long result = VNFJsonUtil.getJsonFieldLong(VNFJsonObj, "names");
+ assertEquals((Long)0L, result);
+ }
+
+ @Test
+ public void testParseErrorInfo() {
+ String errorInfo = "{\"error\":{\"message\":\"errorMessage\"}}";
+ String result = VNFJsonUtil.parseErrorInfo(errorInfo);
+ assertEquals("errorMessage", result);
+ }
+
+ @Test
+ public void testParseErrorInfoByNull() {
+ String result = VNFJsonUtil.parseErrorInfo(null);
+ assertEquals("System Error!", result);
+ }
+
+ @Test
+ public void testParseErrorInfoByEmpty() {
+ String errorInfo = "";
+ String result = VNFJsonUtil.parseErrorInfo(errorInfo);
+ assertEquals("System Error!", result);
+ }
+
+ @Test
+ public void testParseErrorInfoByNoError() {
+ String errorInfo = "{\"errors\":{\"message\":\"errorMessage\"}}";
+ String result = VNFJsonUtil.parseErrorInfo(errorInfo);
+ assertEquals("System Error!", result);
+ }
+
+ @Test
+ public void testParseErrorInfoByNoMessage() {
+ String errorInfo = "{\"error\":{\"messages\":\"errorMessage\"}}";
+ String result = VNFJsonUtil.parseErrorInfo(errorInfo);
+ assertEquals("System Error!", result);
+ }
+
+ @Test
+ public void testObjectToJsonStr() {
+ String data = "{\"vnf1\":{\"id\":\"id\"}}";
+ String result = VNFJsonUtil.objectToJsonStr(data);
+ assertEquals(data, result);
+ }
+
+ @Test
+ public void testObjectToJson() {
+ String data = "{\"vnf1\":{\"id\":\"id\"}}";
+ JSONObject result = VNFJsonUtil.objectToJson(data);
+ assertEquals(JSONObject.fromObject(data), result);
+ }
+ @Test
+ public void marshalTest() throws IOException{
+ net.sf.json.JSON json = new JSONObject();
+ String res = VNFJsonUtil.marshal(json);
+ assertTrue(res.equals("{}"));
+ }
+
+ @Test
+ public void marshalTestException() throws IOException{
+ String str="test";
+ String res = VNFJsonUtil.marshal(str);
+ assertTrue(res != null);
+ }
+
+ @Test
+ public void VNFJsonToListsTest(){
+ List<TestPojo> pojoList = VNFJsonUtil.vnfJsonToLists("[{\"name\":\"test\",\"id\":\"123\"}]",TestPojo.class);
+ assertTrue(pojoList.size()==1);
+ }
+
+ @Test
+ public void VNFJsonToListTest(){
+ List<TestPojo> pojoList = VNFJsonUtil.vnfJsonToList("[{\"name\":\"test\",\"id\":\"123\"}]", TestPojo.class, "test");
+ assertTrue(pojoList.size()==1);
+ }
+
+ @Test
+ public void VNFJsonToObjectsTest(){
+ TestPojo pojo = VNFJsonUtil.vnfJsonToObjects("{\"name\":\"test\",\"id\":\"123\"}", TestPojo.class);
+ assertTrue("test".equals(pojo.getName()) && "123".equals(pojo.getId()));
+ }
+
+ @Test(expected = Exception.class)
+ public void VNFJsonToObjectsTestException(){
+ JsonConfig VNFJsonConfig = new JsonConfig();
+ TestPojo pojo = VNFJsonUtil.vnfJsonToObjects("{\"id\":\"123\",\"name\":\"test\"}", VNFJsonConfig);
+ }
+
+ @Test
+ public void objectToJsonTest(){
+ JsonConfig VNFJsonConfig = new JsonConfig();
+ TestPojo pojo = new TestPojo();
+ pojo.setName("test");
+ pojo.setId("123");
+ String res = VNFJsonUtil.objectToJson(pojo, VNFJsonConfig);
+ assertTrue("{\"id\":\"123\",\"name\":\"test\"}".equals(res));
+ }
+
+ @Test
+ public void objectToJsonTest2(){
+ TestPojo pojo = new TestPojo();
+ pojo.setName("test");
+ pojo.setId("123");
+ String res = VNFJsonUtil.objectToJson(pojo, "");
+ assertTrue("{\"id\":\"123\",\"name\":\"test\"}".equals(res));
+ }
+
+ @Test
+ public void listToJsonTest(){
+ List<TestPojo> pojoList = new ArrayList<TestPojo>();
+ TestPojo pojo = new TestPojo();
+ pojo.setName("test");
+ pojo.setId("123");
+ pojoList.add(pojo);
+ String res = VNFJsonUtil.listToJson(pojoList);
+ assertTrue("[{\"id\":\"123\",\"name\":\"test\"}]".equals(res));
+ }
+
+ @Test
+ public void listToJsonTest2(){
+ List<TestPojo> pojoList = new ArrayList<TestPojo>();
+ TestPojo pojo = new TestPojo();
+ pojo.setName("test");
+ pojo.setId("123");
+ pojoList.add(pojo);
+ String res = VNFJsonUtil.listToJson(pojoList,"");
+ assertTrue("[{\"id\":\"123\",\"name\":\"test\"}]".equals(res));
+ }
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = VNFJsonUtil.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/VnfmUtilTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/VnfmUtilTest.java
new file mode 100644
index 0000000..414218b
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/VnfmUtilTest.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.common;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.openo.baseservice.roa.util.restclient.RestfulResponse;
+import org.openo.nfvo.jujuvnfmadapter.common.servicetoken.VnfmRestfulUtil;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+public class VnfmUtilTest {
+
+ @Test
+ public void getVnfmByIdTestNull(){
+ JSONObject resp = VnfmUtil.getVnfmById("vnfmId");
+ assertNull(resp);
+ }
+ @Test
+ public void getVnfmByIdTest(){
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRemoteResponse(String url, String methodType, String params) {
+ RestfulResponse resp = new RestfulResponse();
+ resp.setStatus(200);
+ JSONObject json = new JSONObject();
+ json.put("id", "1234");
+ resp.setResponseJson(json.toString());
+ return resp;
+ }
+ };
+ JSONObject resp = VnfmUtil.getVnfmById("vnfmId");
+ assertNotNull(resp);
+ }
+ @Test
+ public void getVnfmByIdTest2(){
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRemoteResponse(String url, String methodType, String params) {
+ RestfulResponse resp = new RestfulResponse();
+ resp.setStatus(500);
+ return resp;
+ }
+ };
+ JSONObject resp = VnfmUtil.getVnfmById("vnfmId");
+ assertNull(resp);
+ }
+ @Test
+ public void getVnfmIdByIpNullResp(){
+ String resp = VnfmUtil.getVnfmIdByIp("1.1.1.1");
+ assertEquals(resp,"");
+ }
+ @Test
+ public void getVnfmIdByIpInternalError(){
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRemoteResponse(String url, String methodType, String params) {
+ RestfulResponse resp = new RestfulResponse();
+ resp.setStatus(500);
+ return resp;
+ }
+ };
+ String resp = VnfmUtil.getVnfmIdByIp("1.1.1.1");
+ assertEquals(resp,"");
+ }
+ @Test
+ public void getVnfmIdByIp(){
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRemoteResponse(String url, String methodType, String params) {
+ RestfulResponse resp = new RestfulResponse();
+ JSONArray jsonArray = new JSONArray();
+ JSONObject jsonobj = new JSONObject();
+ jsonobj.put("url", "1.1.1.1");
+ jsonobj.put("vnfmId", "1111");
+ jsonArray.add(jsonobj);
+ resp.setResponseJson(jsonArray.toString());
+ resp.setStatus(200);
+ return resp;
+ }
+ };
+ String resp = VnfmUtil.getVnfmIdByIp("1.1.1.1");
+ assertEquals(resp,"1111");
+ }
+
+ @Test
+ public void getVnfmIdByIpInvalidIP(){
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRemoteResponse(String url, String methodType, String params) {
+ RestfulResponse resp = new RestfulResponse();
+ JSONArray jsonArray = new JSONArray();
+ JSONObject jsonobj = new JSONObject();
+ jsonobj.put("url", "1.1.1.1");
+ jsonobj.put("vnfmId", "1111");
+ jsonArray.add(jsonobj);
+ resp.setResponseJson(jsonArray.toString());
+ resp.setStatus(200);
+ return resp;
+ }
+ };
+ String resp = VnfmUtil.getVnfmIdByIp("1.1.1.2");
+ assertEquals(resp,"");
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/YamlUtilTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/YamlUtilTest.java
new file mode 100644
index 0000000..193961a
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/YamlUtilTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 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.openo.nfvo.jujuvnfmadapter.common;
+
+import java.io.File;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.yaml.snakeyaml.Yaml;
+
+import net.sf.json.JSON;
+
+public class YamlUtilTest {
+ YamlUtil yaml;
+
+ @Before
+ public void setUp() {
+ yaml = new YamlUtil();
+
+ }
+
+ @Test
+ public void test() throws ServiceException {
+ String yamlName = "src/test/resources/test.yaml";
+
+ JSON json=yaml.yamlToJson(yamlName);
+
+ String S=yaml.loadYaml(yamlName);
+ Yaml yaml = new Yaml();
+ File file =new File(yamlName);
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/HttpRestHelpTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/HttpRestHelpTest.java
new file mode 100644
index 0000000..93d715b
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/HttpRestHelpTest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.common.servicetoken;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import org.junit.Test;
+import org.openo.baseservice.roa.util.restclient.Restful;
+import org.openo.nfvo.jujuvnfmadapter.common.servicetoken.HttpRestHelp;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 10, 2016
+ */
+public class HttpRestHelpTest {
+
+ @Test
+ public void testGetRestInstance() {
+ Restful rest = HttpRestHelp.getRestInstance(null, null, false);
+ assertNotNull(rest);
+ }
+
+ @Test
+ public void testGetRestInstance1() {
+ HttpRestHelp.getRestInstance(null, null, false);
+ Restful rest = HttpRestHelp.getRestInstance(null, null, false);
+ assertNotNull(rest);
+ }
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = HttpRestHelp.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/HttpRestfulHelpTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/HttpRestfulHelpTest.java
new file mode 100644
index 0000000..4167c7b
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/HttpRestfulHelpTest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.common.servicetoken;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import org.junit.Test;
+import org.openo.baseservice.roa.util.restclient.Restful;
+import org.openo.nfvo.jujuvnfmadapter.common.servicetoken.HttpRestfulHelp;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 10, 2016
+ */
+public class HttpRestfulHelpTest {
+
+ @Test
+ public void testGetRestInstance() {
+ Restful rest = HttpRestfulHelp.getRestInstance(null, null);
+ assertNotNull(rest);
+ }
+
+ @Test
+ public void testGetRestInstance1() {
+ HttpRestfulHelp.getRestInstance(null, null);
+ Restful rest = HttpRestfulHelp.getRestInstance(null, null);
+ assertNotNull(rest);
+ }
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = HttpRestfulHelp.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/JujuVnfmRestfulUtilTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/JujuVnfmRestfulUtilTest.java
new file mode 100644
index 0000000..0c34643
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/JujuVnfmRestfulUtilTest.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.common.servicetoken;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.baseservice.roa.util.restclient.RestfulParametes;
+import org.openo.baseservice.roa.util.restclient.RestfulResponse;
+import org.openo.nfvo.jujuvnfmadapter.common.servicetoken.VNFRestfulUtil;
+import org.openo.nfvo.jujuvnfmadapter.service.constant.Constant;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 10, 2016
+ */
+public class JujuVnfmRestfulUtilTest {
+
+
+ @Test
+ public void testGetRemoteResponseByVnfmInfoNull() {
+ RestfulResponse result = JujuVnfmRestfulUtil.getRemoteResponse(new HashMap(), null);
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testGetRemoteResponseByPost() {
+ Map testMap = new HashMap();
+ testMap.put("url", "/openoapi/extsys/v1/vnfms/11111");
+ testMap.put("methodType","post");
+ RestfulResponse result = JujuVnfmRestfulUtil.getRemoteResponse(testMap, "");
+
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testGetRemoteResponseByVnfmInfo() {
+ Map testMap = new HashMap();
+ testMap.put("url", "/openoapi/extsys/v1/vnfms/11111");
+ testMap.put("methodType","get");
+ RestfulResponse result = JujuVnfmRestfulUtil.getRemoteResponse(testMap, "");
+
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testGetRemoteResponseByVnfmInfoPut() {
+ Map testMap = new HashMap();
+ testMap.put("url", "/openoapi/extsys/v1/vnfms/11111");
+ testMap.put("methodType","put");
+ RestfulResponse result = JujuVnfmRestfulUtil.getRemoteResponse(testMap, "");
+
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testGetRemoteResponseByVnfmInfoDelete() {
+ Map testMap = new HashMap();
+ testMap.put("url", "/openoapi/extsys/v1/vnfms/11111");
+ testMap.put("methodType","delete");
+ RestfulResponse result = JujuVnfmRestfulUtil.getRemoteResponse(testMap, "");
+
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void getVimResponseContentGetInvalid(){
+ RestfulParametes restParametes = new RestfulParametes();
+ Map<String, Object> result = JujuVnfmRestfulUtil.getVimResponseContent("http://127.0.0.1:8080", restParametes, null, "put");
+ assertTrue(result.isEmpty());
+ }
+ @Test
+ public void getVimResponseContentAddInvalid(){
+ RestfulParametes restParametes = new RestfulParametes();
+ Map<String, Object> result = JujuVnfmRestfulUtil.getVimResponseContent("http://127.0.0.1:8080", restParametes, null, "add");
+ assertTrue(result.isEmpty());
+ }
+
+ @Test
+ public void getVimResponseContentPutInvalid(){
+ RestfulParametes restParametes = new RestfulParametes();
+ Map<String, Object> result = JujuVnfmRestfulUtil.getVimResponseContent("http://127.0.0.1:8080", restParametes, null, "put");
+ assertTrue(result.isEmpty());
+ }
+ @Test
+ public void getVimResponseContentDeleteInvalid(){
+ RestfulParametes restParametes = new RestfulParametes();
+ Map<String, Object> result = JujuVnfmRestfulUtil.getVimResponseContent("http://127.0.0.1:8080", restParametes, null, "delete");
+ assertTrue(result.isEmpty());
+ }
+
+ @Test
+ public void getVimResponseContentPatchInvalid(){
+ RestfulParametes restParametes = new RestfulParametes();
+ Map<String, Object> result = JujuVnfmRestfulUtil.getVimResponseContent("http://127.0.0.1:8080", restParametes, null, "patch");
+ assertTrue(result.isEmpty());
+ }
+
+ @Test
+ public void testGetResultToVnfmByVnfmInfoErrorMsg() {
+ JSONObject vnfmInfo = new JSONObject();
+ vnfmInfo.put("retCode", Constant.REST_FAIL);
+ vnfmInfo.put("msg", "ErrorMsg");
+ JSONObject result = VNFRestfulUtil.getResultToVnfm(vnfmInfo, "vnfmId");
+
+ JSONObject retJson = new JSONObject();
+ retJson.put("retCode", Constant.REST_FAIL);
+ retJson.put("data", "ErrorMsg");
+ assertEquals(retJson, result);
+ }
+
+ @Test
+ public void testGetResultToVnfmByVnfmInfoError() {
+ JSONObject vnfmInfo = new JSONObject();
+ vnfmInfo.put("retCode", Constant.REST_FAIL);
+ JSONObject result = VNFRestfulUtil.getResultToVnfm(vnfmInfo, "vnfmId");
+
+ JSONObject retJson = new JSONObject();
+ retJson.put("retCode", Constant.REST_FAIL);
+ assertEquals(retJson, result);
+ }
+
+ @Test
+ public void vimRestfulResponseTestGetInvalid(){
+ RestfulParametes restParametes = new RestfulParametes();
+ RestfulResponse resp = JujuVnfmRestfulUtil.vimRestfulResponse("http://127.0.0.1:8080", restParametes, null, "get");
+ assertTrue(resp == null);
+ }
+ @Test
+ public void vimRestfulResponseTestAddInvalid(){
+ RestfulParametes restParametes = new RestfulParametes();
+ RestfulResponse resp = JujuVnfmRestfulUtil.vimRestfulResponse("http://127.0.0.1:8080", restParametes, null, "add");
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void vimRestfulResponseTestPutInvalid(){
+ RestfulParametes restParametes = new RestfulParametes();
+ RestfulResponse resp = JujuVnfmRestfulUtil.vimRestfulResponse("http://127.0.0.1:8080", restParametes, null, "put");
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void vimRestfulResponseTestDeleteInvalid(){
+ RestfulParametes restParametes = new RestfulParametes();
+ RestfulResponse resp = JujuVnfmRestfulUtil.vimRestfulResponse("http://127.0.0.1:8080", restParametes, null, "delete");
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void vimRestfulResponseTestPatchInvalid(){
+ RestfulParametes restParametes = new RestfulParametes();
+ RestfulResponse resp = JujuVnfmRestfulUtil.vimRestfulResponse("http://127.0.0.1:8080", restParametes, null, "patch");
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void getRemoteResponseTestGetInvalid(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "http://localhost:8080");
+ paramsMap.put("methodType","get");
+ RestfulResponse resp = JujuVnfmRestfulUtil.getRemoteResponse(paramsMap, null, "test", false);
+ assertNull(resp);
+
+ }
+
+ @Test
+ public void getRemoteResponseTestGetHttpsInvalid(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "http://localhost:8080");
+ paramsMap.put("methodType","get");
+ RestfulResponse resp = JujuVnfmRestfulUtil.getRemoteResponse(paramsMap, null, "test", true);
+ assertNull(resp);
+
+ }
+
+ @Test
+ public void getRemoteResponseTestPostInvalid(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "http://localhost:8080");
+ paramsMap.put("methodType","post");
+ RestfulResponse resp = JujuVnfmRestfulUtil.getRemoteResponse(paramsMap, null, "test", false);
+ assertNull(resp);
+
+ }
+
+ @Test
+ public void getRemoteResponseTestPutInvalid(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "http://localhost:8080");
+ paramsMap.put("methodType","put");
+ RestfulResponse resp = JujuVnfmRestfulUtil.getRemoteResponse(paramsMap, null, "test", false);
+ assertNull(resp);
+
+ }
+
+ @Test
+ public void getRemoteResponseTestDeleteInvalid(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "http://localhost:8080");
+ paramsMap.put("methodType","delete");
+ RestfulResponse resp = JujuVnfmRestfulUtil.getRemoteResponse(paramsMap, null, "test", false);
+ assertNull(resp);
+
+ }
+ @Test
+ public void generateParametesMapTest(){
+ Map<String, String> paramsMap = JujuVnfmRestfulUtil.generateParametesMap("http://localhost:8080", "get", "openoapi/test", "test");
+ assertTrue("http://localhost:8080".equals(paramsMap.get("url")) && "get".equals(paramsMap.get("methodType"))
+ && "openoapi/test".equals(paramsMap.get("path")) && "test".equals(paramsMap.get("authMode")));
+ }
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = JujuVnfmRestfulUtil.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/VNFAuthConfigInfoTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/VNFAuthConfigInfoTest.java
new file mode 100644
index 0000000..23ed850
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/VNFAuthConfigInfoTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.common.servicetoken;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.common.servicetoken.VNFAuthConfigInfo;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 10, 2016
+ */
+public class VNFAuthConfigInfoTest {
+
+ @Test
+ public void testGetDomain() {
+ VNFAuthConfigInfo authConfig = VNFAuthConfigInfo.getInstance();
+ authConfig.setDomain("vnfDomain");
+ assertEquals("vnfDomain", authConfig.getDomain());
+ }
+
+ @Test
+ public void testGetResourceDomain() {
+ VNFAuthConfigInfo authConfig = VNFAuthConfigInfo.getInstance();
+ authConfig.setResourceDomain("vnfResourceDomain");
+ assertEquals("vnfResourceDomain", authConfig.getResourceDomain());
+ }
+
+ @Test
+ public void testGetDefaultDomain() {
+ VNFAuthConfigInfo authConfig = VNFAuthConfigInfo.getInstance();
+ authConfig.setDefaultDomain("defaultDomain");
+ assertEquals("defaultDomain", authConfig.getDefaultDomain());
+ }
+
+ @Test
+ public void testGetUserName() {
+ VNFAuthConfigInfo authConfig = VNFAuthConfigInfo.getInstance();
+ authConfig.setUserName("vnfuserName");
+ assertEquals("vnfuserName", authConfig.getUserName());
+ }
+
+ @Test
+ public void testGetEncryptedPW() {
+ VNFAuthConfigInfo authConfig = VNFAuthConfigInfo.getInstance();
+ authConfig.setEncryptedPW("vnfencryptedPW");
+ assertEquals("vnfencryptedPW", authConfig.getEncryptedPW());
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/VNFRestfulUtilTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/VNFRestfulUtilTest.java
new file mode 100644
index 0000000..37c6c0b
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/VNFRestfulUtilTest.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.common.servicetoken;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.openo.baseservice.roa.util.restclient.RestfulResponse;
+import org.openo.nfvo.jujuvnfmadapter.service.constant.Constant;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 10, 2016
+ */
+public class VNFRestfulUtilTest {
+
+ @Test
+ public void testGetRestResByDefaultByNull() {
+ RestfulResponse result = VNFRestfulUtil.getRestResByDefault("path", "methodNames", new JSONObject());
+ assertNull(result);
+ }
+
+ @Test
+ public void testGetRestResByDefaultByGet() {
+ RestfulResponse result = VNFRestfulUtil.getRestResByDefault("path", "get", new JSONObject());
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetRestResByDefaultByPut() {
+ RestfulResponse result = VNFRestfulUtil.getRestResByDefault("path", "put", new JSONObject());
+ assertNotNull(result);
+ }
+
+ /*@Test
+ public void testSendReqToApp() {
+ new MockUp<VNFRestfulUtil>() {
+
+ @Mock
+ public RestfulResponse getRestResByDefault(String path, String methodNames, JSONObject bodyParam) {
+ RestfulResponse restfulResponse = new RestfulResponse();
+ restfulResponse.setStatus(Constant.HTTP_OK);
+ String responseString = "{\"retCode\":1,\"data\":\"success\"}";
+ restfulResponse.setResponseJson(responseString);
+ return restfulResponse;
+ }
+ };
+ JSONObject result = VNFRestfulUtil.sendReqToApp("path", "put", new JSONObject());
+ assertEquals(Constant.REST_SUCCESS, result.get("retCode"));
+ }*/
+
+ /*@Test(expected = ExceptionInInitializerError.class)
+ public void testSendReqToAppByErrorMsg() {
+ new MockUp<VNFRestfulUtil>() {
+
+ @Mock
+ public RestfulResponse getRestResByDefault(String path, String methodNames, JSONObject bodyParam) {
+ RestfulResponse restfulResponse = new RestfulResponse();
+ restfulResponse.setStatus(Constant.HTTP_OK);
+ String responseString = "{\"retCode\":-1,\"data\":\"fail\",\"msg\":\"fail\"}";
+ restfulResponse.setResponseJson(responseString);
+ return restfulResponse;
+ }
+ };
+ JSONObject result = VNFRestfulUtil.sendReqToApp("path", "put", new JSONObject());
+ assertEquals(Constant.REST_FAIL, result.get("retCode"));
+ }*/
+
+ /*@Test
+ public void testSendReqToAppByError() {
+ new MockUp<VNFRestfulUtil>() {
+
+ @Mock
+ public RestfulResponse getRestResByDefault(String path, String methodNames, JSONObject bodyParam) {
+ RestfulResponse restfulResponse = new RestfulResponse();
+ restfulResponse.setStatus(Constant.HTTP_OK);
+ String responseString = "{\"retCode\":-1,\"data\":\"fail\"}";
+ restfulResponse.setResponseJson(responseString);
+ return restfulResponse;
+ }
+ };
+ JSONObject result = VNFRestfulUtil.sendReqToApp("path", "put", new JSONObject());
+ assertEquals(Constant.REST_FAIL, result.get("retCode"));
+ }*/
+
+ @Test
+ public void testSendReqToAppByFail() {
+ JSONObject result = VNFRestfulUtil.sendReqToApp("path", "put", new JSONObject());
+ assertEquals(Constant.REST_FAIL, result.get("retCode"));
+ }
+
+ @Test
+ public void testSendReqToAppByVnfmInfoPut() {
+ JSONObject paraJson = new JSONObject();
+ JSONObject vnfmObj = new JSONObject();
+ vnfmObj.put("id", "id");
+ paraJson.put("vnfmInfo", vnfmObj);
+ JSONObject result = VNFRestfulUtil.sendReqToApp("path", "put", paraJson);
+ assertEquals(Constant.REST_FAIL, result.get("retCode"));
+ }
+
+ @Test
+ public void testGenerateParamsMap() {
+ Map<String, String> result = VNFRestfulUtil.generateParamsMap("url", "methodType", "path");
+ Map<String, String> paramsMap = new HashMap<String, String>(6);
+ paramsMap.put("url", "url");
+ paramsMap.put("methodType", "methodType");
+ paramsMap.put("path", "path");
+ paramsMap.put("authMode", "Certificate");
+ assertEquals(paramsMap, result);
+ }
+
+ @Test
+ public void testGenerateParamsMap2() {
+ Map<String, String> result = VNFRestfulUtil.generateParamsMap("url", "methodType", "path", "authMode");
+ Map<String, String> paramsMap = new HashMap<String, String>(6);
+ paramsMap.put("url", "url");
+ paramsMap.put("methodType", "methodType");
+ paramsMap.put("path", "path");
+ paramsMap.put("authMode", "authMode");
+ assertEquals(paramsMap, result);
+ }
+
+ @Test
+ public void testGetResultToVnfmByVnfmInfoNull() {
+ JSONObject result = VNFRestfulUtil.getResultToVnfm(null, null);
+
+ JSONObject retJson = new JSONObject();
+ retJson.put("retCode", Constant.REST_FAIL);
+ retJson.put("data", "get null result");
+ assertEquals(retJson, result);
+ }
+
+ @Test
+ public void testGetResultToVnfmByVnfmInfoErrorMsg() {
+ JSONObject vnfmInfo = new JSONObject();
+ vnfmInfo.put("retCode", Constant.REST_FAIL);
+ vnfmInfo.put("msg", "ErrorMsg");
+ JSONObject result = VNFRestfulUtil.getResultToVnfm(vnfmInfo, "vnfmId");
+
+ JSONObject retJson = new JSONObject();
+ retJson.put("retCode", Constant.REST_FAIL);
+ retJson.put("data", "ErrorMsg");
+ assertEquals(retJson, result);
+ }
+
+ @Test
+ public void testGetResultToVnfmByVnfmInfoError() {
+ JSONObject vnfmInfo = new JSONObject();
+ vnfmInfo.put("retCode", Constant.REST_FAIL);
+ JSONObject result = VNFRestfulUtil.getResultToVnfm(vnfmInfo, "vnfmId");
+
+ JSONObject retJson = new JSONObject();
+ retJson.put("retCode", Constant.REST_FAIL);
+ assertEquals(retJson, result);
+ }
+ @Test
+ public void getRemoteResponseTestInvalidGet(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "http://localhost:8080");
+ paramsMap.put("url", "/openoapi/test");
+ paramsMap.put("methodType","get");
+ paramsMap.put("authMode","test");
+ RestfulResponse resp = VNFRestfulUtil.getRemoteResponse(paramsMap, null, "test123", true);
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void getRemoteResponseTestInvalidPut(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "http://localhost:8080");
+ paramsMap.put("url", "/openoapi/test");
+ paramsMap.put("methodType","put");
+ paramsMap.put("authMode","test");
+ RestfulResponse resp = VNFRestfulUtil.getRemoteResponse(paramsMap, null, "test123", true);
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void getRemoteResponseTestInvalidPost(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "http://localhost:8080");
+ paramsMap.put("url", "/openoapi/test");
+ paramsMap.put("methodType","post");
+ paramsMap.put("authMode","test");
+ RestfulResponse resp = VNFRestfulUtil.getRemoteResponse(paramsMap, null, "test123", true);
+ assertTrue(resp == null);
+ }
+ @Test
+ public void getRemoteResponseTestInvalidDelete(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "http://localhost:8080");
+ paramsMap.put("url", "/openoapi/test");
+ paramsMap.put("methodType","delete");
+ paramsMap.put("authMode","test");
+ RestfulResponse resp = VNFRestfulUtil.getRemoteResponse(paramsMap, null, "test123", true);
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void getRemoteResponseTestFalseNfvoApp(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "http://localhost:8080");
+ paramsMap.put("url", "/openoapi/test");
+ paramsMap.put("methodType","delete");
+ paramsMap.put("authMode","test");
+ RestfulResponse resp = VNFRestfulUtil.getRemoteResponse(paramsMap, null, "test123", false);
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void sentEvtByRestTest(){
+ VNFRestfulUtil.sentEvtByRest("http://localhost:8080", "get", null);
+ assertTrue(true);
+ }
+ @Test
+ public void sentEvtByRestTest2(){
+ JSONObject bodyParam = new JSONObject();
+ VNFRestfulUtil.sentEvtByRest("http://localhost:8080", "get",bodyParam);
+ assertTrue(true);
+ }
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = VNFRestfulUtil.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java
new file mode 100644
index 0000000..f0123ed
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java
@@ -0,0 +1,224 @@
+/*
+ * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.common.servicetoken;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.openo.baseservice.roa.util.restclient.RestfulResponse;
+import org.openo.nfvo.jujuvnfmadapter.service.constant.Constant;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+public class VnfmRestfulUtilTest {
+
+ @Test
+ public void testGetRestResByDefaultByNull() {
+ RestfulResponse result = VnfmRestfulUtil.getRestResByDefault("path", "methodNames", new JSONObject());
+ assertNull(result);
+ }
+ @Test
+ public void testGetRestResByDefaultByGet() {
+ RestfulResponse result = VnfmRestfulUtil.getRestResByDefault("path", "get", new JSONObject());
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetRestResByDefaultByPut() {
+ RestfulResponse result = VnfmRestfulUtil.getRestResByDefault("path", "put", new JSONObject());
+ assertNotNull(result);
+ }
+
+ ////
+ @Test
+ public void testSendReqToAppByFail() {
+ JSONObject result = VnfmRestfulUtil.sendReqToApp("path", "put", new JSONObject());
+ assertEquals(Constant.REST_FAIL, result.get("retCode"));
+ }
+
+ @Test
+ public void testSendReqToAppByVnfmInfoPut() {
+ JSONObject paraJson = new JSONObject();
+ JSONObject vnfmObj = new JSONObject();
+ vnfmObj.put("id", "id");
+ paraJson.put("vnfmInfo", vnfmObj);
+ JSONObject result = VnfmRestfulUtil.sendReqToApp("path", "put", paraJson);
+ assertEquals(Constant.REST_FAIL, result.get("retCode"));
+ }
+
+ @Test
+ public void testSendReqToAppByVnfmInfoPutNormal() {
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRestResByDefault(String path, String methodNames, JSONObject bodyParam) {
+ RestfulResponse resp = new RestfulResponse();
+ resp.setStatus(200);
+ JSONObject obj = new JSONObject();
+ obj.put("retCode", 1);
+ obj.put("data", new JSONObject());
+ resp.setResponseJson(obj.toString());
+ return resp;
+ }
+ };
+ JSONObject paraJson = new JSONObject();
+ JSONObject vnfmObj = new JSONObject();
+ vnfmObj.put("id", "id");
+ JSONObject result = VnfmRestfulUtil.sendReqToApp("path", "put", paraJson);
+ assertEquals(Constant.REST_SUCCESS, result.get("retCode"));
+ }
+ @Test
+ public void testSendReqToAppByVnfmInfoPutNormal2() {
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRestResByDefault(String path, String methodNames, JSONObject bodyParam) {
+ RestfulResponse resp = new RestfulResponse();
+ resp.setStatus(200);
+ JSONObject obj = new JSONObject();
+ obj.put("retCode", -1);
+ obj.put("data", new JSONObject());
+ resp.setResponseJson(obj.toString());
+ return resp;
+ }
+ };
+ JSONObject paraJson = new JSONObject();
+ JSONObject vnfmObj = new JSONObject();
+ vnfmObj.put("id", "id");
+ JSONObject result = VnfmRestfulUtil.sendReqToApp("path", "put", paraJson);
+ assertEquals(Constant.REST_FAIL, result.get("retCode"));
+ }
+
+ @Test
+ public void testGenerateParamsMap() {
+ Map<String, String> result = VnfmRestfulUtil.generateParamsMap("url", "methodType", "path","auth");
+ Map<String, String> paramsMap = new HashMap<String, String>(6);
+ paramsMap.put("url", "url");
+ paramsMap.put("methodType", "methodType");
+ paramsMap.put("path", "path");
+ paramsMap.put("authMode", "auth");
+ assertEquals(paramsMap, result);
+ }
+ @Test
+ public void getRemoteResponseTestInvalidGet(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "/test/abc");
+ paramsMap.put("url", "http://localhost:8080");
+ paramsMap.put("methodType","get");
+ paramsMap.put("authMode","test");
+ RestfulResponse resp = VnfmRestfulUtil.getRemoteResponse(paramsMap, null, "test123");
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void getRemoteResponseTestInvalidPut(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "/test/abc");
+ paramsMap.put("url", "http://localhost:8080");
+ paramsMap.put("methodType","put");
+ paramsMap.put("authMode","test");
+ RestfulResponse resp = VnfmRestfulUtil.getRemoteResponse(paramsMap, null, "test123");
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void getRemoteResponseTestInvalidPost(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "/openoapi/test");
+ paramsMap.put("url", "http://localhost:8080");
+ paramsMap.put("methodType","post");
+ paramsMap.put("authMode","test");
+ RestfulResponse resp = VnfmRestfulUtil.getRemoteResponse(paramsMap, null, "test123");
+ assertTrue(resp == null);
+ }
+ @Test
+ public void getRemoteResponseTestInvalidDelete(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "/openoapi/test");
+ paramsMap.put("url", "http://localhost:8080");
+ paramsMap.put("methodType","delete");
+ paramsMap.put("authMode","test");
+ RestfulResponse resp = VnfmRestfulUtil.getRemoteResponse(paramsMap, null, "test123");
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void getRemoteResponse2TestInvalidGet(){
+ String url = "http://localhost:8080";
+ RestfulResponse resp = VnfmRestfulUtil.getRemoteResponse(url, "get", "test123");
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void getRemoteResponse2TestInvalidPut(){
+ String url = "http://localhost:8080";
+ RestfulResponse resp = VnfmRestfulUtil.getRemoteResponse(url, "put", "test123");
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void getRemoteResponse2TestInvalidPost(){
+ String url = "http://localhost:8080";
+ RestfulResponse resp = VnfmRestfulUtil.getRemoteResponse(url, "post", "test123");
+ assertTrue(resp == null);
+ }
+ @Test
+ public void getRemoteResponse2TestInvalidDelete(){
+
+ String url = "http://localhost:8080";
+
+ RestfulResponse resp = VnfmRestfulUtil.getRemoteResponse(url, "delete", "test123");
+ assertTrue(resp == null);
+ }
+
+ @Test
+ public void getRemoteResponseTestFalseNfvoApp(){
+ Map<String,String> paramsMap = new HashMap<>();
+ paramsMap.put("path", "/openoapi/test");
+ paramsMap.put("url", "http://localhost:8080");
+ paramsMap.put("methodType","delete");
+ paramsMap.put("authMode","test");
+ RestfulResponse resp = VnfmRestfulUtil.getRemoteResponse(paramsMap, null, "test123");
+ assertTrue(resp == null);
+ }
+
+ /* @Test
+ public void sentEvtByRestTest(){
+ VnfmRestfulUtil.sentEvtByRest("http://localhost:8080", "get", null);
+ assertTrue(true);
+ }
+ @Test
+ public void sentEvtByRestTest2(){
+ JSONObject bodyParam = new JSONObject();
+ VnfmRestfulUtil.sentEvtByRest("http://localhost:8080", "get",bodyParam);
+ assertTrue(true);
+ }*/
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = VnfmRestfulUtil.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/module/AccessTokensTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/module/AccessTokensTest.java
new file mode 100644
index 0000000..f033984
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/module/AccessTokensTest.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.common.servicetoken.module;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import net.sf.json.JSONObject;
+
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.common.servicetoken.module.AccessTokens;
+
+public class AccessTokensTest {
+
+ @Test
+ public void testVimAccessTokens() {
+ AccessTokens accessTokens = new AccessTokens("accessToken", 123);
+ assertEquals("accessToken", accessTokens.getAccessToken());
+ assertEquals(123, accessTokens.getExpire());
+ }
+
+ @Test
+ public void testAccessTokens1() {
+ AccessTokens accessTokens = new AccessTokens("accessToken", null, null);
+ assertEquals("accessToken", accessTokens.getAccessToken());
+ assertEquals(0, accessTokens.getExpire());
+ assertEquals(0, accessTokens.getCreateTime());
+ }
+
+ @Test
+ public void testAccessTokens2() {
+ Integer vimExpire = (Integer)123;
+ Long createTime = (Long)1L;
+ AccessTokens accessTokens = new AccessTokens("accessToken", vimExpire, createTime);
+ assertEquals("accessToken", accessTokens.getAccessToken());
+ assertEquals(123, accessTokens.getExpire());
+ assertEquals(1L, accessTokens.getCreateTime());
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testVimAccessTokens3() {
+ AccessTokens accessTokens = new AccessTokens();
+ }
+
+ @Test
+ public void testSetVimAccessToken() {
+ AccessTokens accessTokens = new AccessTokens("accessToken", 123);
+ accessTokens.setAccessToken("anotherToken");
+ assertEquals("anotherToken", accessTokens.getAccessToken());
+ }
+
+ @Test
+ public void testValidExpire() {
+ AccessTokens accessTokens = new AccessTokens("accessToken", 0);
+ assertTrue(accessTokens.valid());
+ }
+
+ @Test
+ public void testValidExpire1() {
+ AccessTokens accessTokens = new AccessTokens("accessToken", 123);
+ assertTrue(accessTokens.valid());
+ }
+
+ @Test
+ public void testValidExpire2() {
+ AccessTokens accessTokens = new AccessTokens("accessToken", 123, 1L);
+ assertFalse(accessTokens.valid());
+ }
+
+ @Test
+ public void testToString() {
+ AccessTokens accessTokens = new AccessTokens("accessToken", 123, 1L);
+ assertEquals("{accessToken','expire': '123','createTime': '1'}", accessTokens.toString());
+ }
+
+ @Test
+ public void testToEntity() {
+ String data = "{'accessToken': 'accessToken','expire': '123','createTime': '1'}";
+ JSONObject jsonObject = JSONObject.fromObject(data);
+ AccessTokens accessTokens = new AccessTokens("accessToken", 123, 1L);
+ assertEquals(accessTokens.toString(), AccessTokens.toEntity(jsonObject).toString());
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/module/ServiceTokenHelpTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/module/ServiceTokenHelpTest.java
new file mode 100644
index 0000000..afb0f91
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/common/servicetoken/module/ServiceTokenHelpTest.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.common.servicetoken.module;
+
+import org.junit.Test;
+
+public class ServiceTokenHelpTest {
+
+ @Test
+ public void testCreateServiceToken() {
+
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/activator/ROAJujuServicePostProcessorTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/activator/ROAJujuServicePostProcessorTest.java
new file mode 100644
index 0000000..ad379ae
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/activator/ROAJujuServicePostProcessorTest.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.activator;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ROAJujuServicePostProcessorTest {
+ ROAJujuServicePostProcessor postprocessor=new ROAJujuServicePostProcessor();
+
+ @Test
+ public void test() {
+ Object bean ="IJujuAdapterMgrService";
+ String name="";
+ postprocessor.postProcessAfterInitialization(bean, name);
+ postprocessor.postProcessBeforeDestruction(bean, name);
+ postprocessor.postProcessBeforeInitialization(bean, name);
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/AdapterResourceManagerTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/AdapterResourceManagerTest.java
new file mode 100644
index 0000000..d4e6eba
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/AdapterResourceManagerTest.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.service.adapter.impl;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.baseservice.roa.util.restclient.HttpRest;
+import org.openo.baseservice.roa.util.restclient.RestfulParametes;
+import org.openo.baseservice.roa.util.restclient.RestfulResponse;
+import org.openo.nfvo.jujuvnfmadapter.service.constant.Constant;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+public class AdapterResourceManagerTest {
+
+ private AdapterResourceManager adapterResManager;
+
+ private JSONObject jsonObj;
+
+ /*
+ * @Test public void testGetJujuVnfmInfo() throws Exception { Map paramsMap
+ * = new HashMap(); JSONObject resultObj = new JSONObject();
+ * resultObj.put("reason", "RestfulResponse is null.");
+ * resultObj.put("retCode", Constant.ERROR_STATUS_CODE);
+ *
+ * paramsMap.put("url", "/openoapi/extsys/v1/vnfms/11111");
+ * paramsMap.put("methodType","get");
+ *
+ * new MockUp<JujuVnfmRestfulUtil>(){
+ *
+ * @Mock public RestfulResponse getRemoteResponse(Map paramsMap,String str)
+ * { return null; } }; adapterResManager = new AdapterResourceManager();
+ * jsonObj = adapterResManager.getJujuVnfmInfo(paramsMap);
+ * assertEquals(resultObj,jsonObj); }
+ */
+
+ /*
+ * @Test public void testGetVnfdInfo() throws Exception { Map paramsMap =
+ * new HashMap(); JSONObject resultObj = new JSONObject();
+ * resultObj.put("reason", "RestfulResponse is null.");
+ * resultObj.put("retCode", Constant.ERROR_STATUS_CODE);
+ *
+ * paramsMap.put("url", "/openoapi/extsys/v1/vnfms/11111");
+ * paramsMap.put("methodType","get");
+ *
+ * new MockUp<JujuVnfmRestfulUtil>(){
+ *
+ * @Mock public RestfulResponse getRemoteResponse(Map paramsMap,String str)
+ * { return null; } }; adapterResManager = new AdapterResourceManager();
+ * jsonObj = adapterResManager.getJujuVnfmInfo(paramsMap);
+ * assertEquals(resultObj,jsonObj); }
+ */
+
+ @Test
+ public void getJujuVnfmInfoTest() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse get(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(200);
+ return rsp;
+ }
+ };
+ new MockUp<JSONObject>() {
+ @Mock
+ public JSONObject fromObject(Object object) {
+ JSONObject json = new JSONObject();
+ return json;
+ }
+ };
+ Map<String, String> paramsMap = new HashMap<>();
+ JSONObject resultObj = new JSONObject();
+ resultObj.put("reason", "RestfulResponse is null.");
+ resultObj.put("retCode", Constant.ERROR_STATUS_CODE);
+
+ paramsMap.put("url", "/openoapi/extsys/v1/vnfms/11111");
+ paramsMap.put("methodType", "get");
+ adapterResManager = new AdapterResourceManager();
+ jsonObj = adapterResManager.getJujuVnfmInfo(paramsMap);
+ assertTrue(jsonObj != null);
+ }
+
+ @Test
+ public void getJujuVnfmInfoTest1() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse get(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(504);
+ return rsp;
+ }
+ };
+ new MockUp<JSONObject>() {
+ @Mock
+ public JSONObject fromObject(Object object) {
+ JSONObject json = new JSONObject();
+ return json;
+ }
+ };
+ Map<String, String> paramsMap = new HashMap<>();
+ JSONObject resultObj = new JSONObject();
+ resultObj.put("reason", "RestfulResponse is null.");
+ resultObj.put("retCode", Constant.ERROR_STATUS_CODE);
+
+ paramsMap.put("url", "/openoapi/extsys/v1/vnfms/11111");
+ paramsMap.put("methodType", "get");
+ adapterResManager = new AdapterResourceManager();
+ jsonObj = adapterResManager.getJujuVnfmInfo(paramsMap);
+ assertTrue(jsonObj != null);
+ }
+
+ @Test
+ public void getJujuVnfmInfoTestFalse() {
+ Map<String, String> paramsMap = new HashMap<>();
+ JSONObject resultObj = new JSONObject();
+ resultObj.put("reason", "RestfulResponse is null.");
+ resultObj.put("retCode", Constant.ERROR_STATUS_CODE);
+
+ paramsMap.put("url", "/openoapi/extsys/v1/vnfms/11111");
+ paramsMap.put("methodType", "get");
+ adapterResManager = new AdapterResourceManager();
+ jsonObj = adapterResManager.getJujuVnfmInfo(null);
+ assertTrue(jsonObj.get("reason").equals("RestfulResponse is null."));
+ }
+
+ @Test
+ public void getVnfdInfoTest() {
+ Map<String, String> paramsMap = new HashMap<>();
+ JSONObject resultObj = new JSONObject();
+ resultObj.put("reason", "RestfulResponse is null.");
+ resultObj.put("retCode", Constant.ERROR_STATUS_CODE);
+
+ paramsMap.put("url", "/openoapi/extsys/v1/vnfms/11111");
+ paramsMap.put("methodType", "get");
+ adapterResManager = new AdapterResourceManager();
+// jsonObj = adapterResManager.getVnfdInfo("1111");
+// assertTrue(jsonObj.get("reason").equals("RestfulResponse is null."));
+ }
+
+ @Test
+ public void getVnfdInfoTest1() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse get(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(200);
+ return rsp;
+ }
+ };
+ new MockUp<JSONObject>() {
+ @Mock
+ public JSONObject fromObject(Object object) {
+ JSONObject json = new JSONObject();
+ return json;
+ }
+ };
+ Map<String, String> paramsMap = new HashMap<>();
+ JSONObject resultObj = new JSONObject();
+ resultObj.put("reason", "RestfulResponse is null.");
+ resultObj.put("retCode", Constant.ERROR_STATUS_CODE);
+
+ paramsMap.put("url", "/openoapi/extsys/v1/vnfms/11111");
+ paramsMap.put("methodType", "get");
+ adapterResManager = new AdapterResourceManager();
+// jsonObj = adapterResManager.getVnfdInfo("1111");
+// assertTrue(jsonObj != null);
+ }
+
+ @Test
+ public void getVnfdInfoTest2() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse get(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(504);
+ return rsp;
+ }
+ };
+
+ Map<String, String> paramsMap = new HashMap<>();
+ JSONObject resultObj = new JSONObject();
+ resultObj.put("reason", "RestfulResponse is null.");
+ resultObj.put("retCode", Constant.ERROR_STATUS_CODE);
+
+ paramsMap.put("url", "/openoapi/extsys/v1/vnfms/11111");
+ paramsMap.put("methodType", "get");
+ adapterResManager = new AdapterResourceManager();
+// jsonObj = adapterResManager.getVnfdInfo("1111");
+// assertTrue(jsonObj != null);
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/JujuAdapter2MSBManagerTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/JujuAdapter2MSBManagerTest.java
new file mode 100644
index 0000000..5814a18
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/JujuAdapter2MSBManagerTest.java
@@ -0,0 +1,267 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.service.adapter.impl;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.baseservice.roa.util.restclient.HttpRest;
+import org.openo.baseservice.roa.util.restclient.RestfulParametes;
+import org.openo.baseservice.roa.util.restclient.RestfulResponse;
+import org.openo.nfvo.jujuvnfmadapter.common.servicetoken.JujuVnfmRestfulUtil;
+import org.openo.nfvo.jujuvnfmadapter.service.constant.Constant;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+public class JujuAdapter2MSBManagerTest {
+
+ private JujuAdapter2MSBManager adapter2MSBManager;
+
+ private JSONObject jsonObj;
+
+ @Test
+ public void registerJujuAdapterTest() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse post(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(200);
+ return rsp;
+ }
+ };
+ Map<String, String> paramsMap = new HashMap<>();
+ JSONObject resultObj = new JSONObject();
+
+ paramsMap.put("url", "/openoapi/microservices/v1/services");
+ paramsMap.put("methodType", "post");
+
+ JujuAdapter2MSBManager mgr = new JujuAdapter2MSBManager();
+ JSONObject resp = mgr.registerJujuAdapter(paramsMap, resultObj);
+ assertTrue(resp != null);
+ }
+
+ @Test
+ public void registerJujuAdapterTest2() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse post(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(500);
+ return rsp;
+ }
+ };
+ Map<String, String> paramsMap = new HashMap<>();
+ JSONObject resultObj = new JSONObject();
+
+ paramsMap.put("url", "/openoapi/microservices/v1/services");
+ paramsMap.put("methodType", "post");
+
+ JujuAdapter2MSBManager mgr = new JujuAdapter2MSBManager();
+ JSONObject resp = mgr.registerJujuAdapter(paramsMap, resultObj);
+ assertTrue(resp != null);
+ }
+
+ @Test
+ public void registerJujuAdapterTest3() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse post(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(415);
+ return rsp;
+ }
+ };
+ Map<String, String> paramsMap = new HashMap<>();
+ JSONObject resultObj = new JSONObject();
+
+ paramsMap.put("url", "/openoapi/microservices/v1/services");
+ paramsMap.put("methodType", "post");
+
+ JujuAdapter2MSBManager mgr = new JujuAdapter2MSBManager();
+ JSONObject resp = mgr.registerJujuAdapter(paramsMap, resultObj);
+ assertTrue(resp != null);
+ }
+
+ @Test
+ public void registerJujuAdapterTest4() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse post(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(201);
+ return rsp;
+ }
+ };
+ new MockUp<JSONObject>() {
+ @Mock
+ public JSONObject fromObject(Object object) {
+ JSONObject json = new JSONObject();
+ return json;
+ }
+ };
+ Map<String, String> paramsMap = new HashMap<>();
+ JSONObject resultObj = new JSONObject();
+
+ paramsMap.put("url", "/openoapi/microservices/v1/services");
+ paramsMap.put("methodType", "post");
+
+ JujuAdapter2MSBManager mgr = new JujuAdapter2MSBManager();
+ JSONObject resp = mgr.registerJujuAdapter(paramsMap, resultObj);
+ assertTrue(resp != null);
+ }
+
+ @Test
+ public void registerJujuAdapterTest1() {
+ Map<String, String> paramsMap = new HashMap<>();
+ JSONObject resultObj = new JSONObject();
+
+ paramsMap.put("url", "/openoapi/microservices/v1/services");
+ paramsMap.put("methodType", "post");
+
+ JujuAdapter2MSBManager mgr = new JujuAdapter2MSBManager();
+ JSONObject resp = mgr.registerJujuAdapter(null, resultObj);
+ assertTrue(resp.get("reason").equals("RestfulResponse is null."));
+ }
+
+ @Test
+ public void unregisterJujuAdapterTest() {
+ Map<String, String> paramsMap = new HashMap<>();
+
+ paramsMap.put("url", "/openoapi/microservices/v1/services");
+ paramsMap.put("methodType", "post");
+
+ JujuAdapter2MSBManager mgr = new JujuAdapter2MSBManager();
+ JSONObject resp = mgr.unregisterJujuAdapter(paramsMap);
+ assertTrue(resp.get("reason").equals("RestfulResponse is null."));
+ }
+
+ @Test
+ public void unregisterJujuAdapterTest1() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse post(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(204);
+ return rsp;
+ }
+ };
+ new MockUp<JSONObject>() {
+ @Mock
+ public JSONObject fromObject(Object object) {
+ JSONObject json = new JSONObject();
+ return json;
+ }
+ };
+ Map<String, String> paramsMap = new HashMap<>();
+
+ paramsMap.put("url", "/openoapi/microservices/v1/services");
+ paramsMap.put("methodType", "post");
+
+ JujuAdapter2MSBManager mgr = new JujuAdapter2MSBManager();
+ JSONObject resp = mgr.unregisterJujuAdapter(paramsMap);
+ assertTrue(resp != null);
+ }
+
+ @Test
+ public void unregisterJujuAdapterTest2() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse post(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(404);
+ return rsp;
+ }
+ };
+ Map<String, String> paramsMap = new HashMap<>();
+
+ paramsMap.put("url", "/openoapi/microservices/v1/services");
+ paramsMap.put("methodType", "post");
+
+ JujuAdapter2MSBManager mgr = new JujuAdapter2MSBManager();
+ JSONObject resp = mgr.unregisterJujuAdapter(paramsMap);
+ assertTrue(resp != null);
+ }
+
+ @Test
+ public void unregisterJujuAdapterTest3() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse post(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(415);
+ return rsp;
+ }
+ };
+ Map<String, String> paramsMap = new HashMap<>();
+
+ paramsMap.put("url", "/openoapi/microservices/v1/services");
+ paramsMap.put("methodType", "post");
+
+ JujuAdapter2MSBManager mgr = new JujuAdapter2MSBManager();
+ JSONObject resp = mgr.unregisterJujuAdapter(paramsMap);
+ assertTrue(resp != null);
+ }
+
+ @Test
+ public void unregisterJujuAdapterTest4() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse post(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(500);
+ return rsp;
+ }
+ };
+ Map<String, String> paramsMap = new HashMap<>();
+
+ paramsMap.put("url", "/openoapi/microservices/v1/services");
+ paramsMap.put("methodType", "post");
+
+ JujuAdapter2MSBManager mgr = new JujuAdapter2MSBManager();
+ JSONObject resp = mgr.unregisterJujuAdapter(paramsMap);
+ assertTrue(resp != null);
+ }
+
+ @Test
+ public void unregisterJujuAdapterTest5() {
+ new MockUp<HttpRest>() {
+ @Mock
+ RestfulResponse post(String arg0, RestfulParametes arg1) throws ServiceException {
+ RestfulResponse rsp = new RestfulResponse();
+ rsp.setStatus(200);
+ return rsp;
+ }
+ };
+ Map<String, String> paramsMap = new HashMap<>();
+
+ paramsMap.put("url", "/openoapi/microservices/v1/services");
+ paramsMap.put("methodType", "post");
+
+ JujuAdapter2MSBManager mgr = new JujuAdapter2MSBManager();
+ JSONObject resp = mgr.unregisterJujuAdapter(paramsMap);
+ assertTrue(resp != null);
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/JujuClientManagerTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/JujuClientManagerTest.java
new file mode 100644
index 0000000..8fc108c
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/JujuClientManagerTest.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.service.adapter.impl;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+public class JujuClientManagerTest {
+
+ @Test
+ public void testdeploy() {
+ JujuClientManager jujuClientManager = new JujuClientManager();
+ JSONObject json = jujuClientManager.deploy("charmPath", "appName");
+ assertTrue(json != null);
+ }
+
+ @Test
+ public void testdeploy3() {
+ new MockUp<ProcessBuilder>() {
+ @Mock
+ public Process start() throws IOException {
+ Process process = new ProcessMockImpl();
+ return process;
+ }
+ };
+ JujuClientManager jujuClientManager = new JujuClientManager();
+ JSONObject json = jujuClientManager.deploy("charmPath","appName");
+ assertTrue(json != null);
+ }
+
+ @Test
+ public void testdeploy1() {
+
+ JujuClientManager jujuClientManager = new JujuClientManager();
+ JSONObject json = jujuClientManager.deploy("charmPath", null);
+ assertTrue(json != null);
+ }
+
+ @Test
+ public void testdeploy2() {
+
+ JujuClientManager jujuClientManager = new JujuClientManager();
+ JSONObject json = jujuClientManager.deploy(null, null);
+ assertTrue(json != null);
+ }
+
+ @Test
+@Ignore
+ public void testdestroy() {
+
+ JujuClientManager jujuClientManager = new JujuClientManager();
+ JSONObject json = jujuClientManager.destroy("appName");
+ assertTrue(json != null);
+ }
+
+ @Test
+ public void testdestroy1() {
+ new MockUp<ProcessBuilder>() {
+ @Mock
+ public Process start() throws IOException {
+ Process process = new ProcessMockImpl();
+ return process;
+ }
+ };
+ JujuClientManager jujuClientManager = new JujuClientManager();
+ JSONObject json = jujuClientManager.destroy("appName");
+ assertTrue(json != null);
+ }
+
+ @Test
+ public void testgetStatus() {
+
+ JujuClientManager jujuClientManager = new JujuClientManager();
+ JSONObject json = jujuClientManager.getStatus("appName");
+ assertTrue(json != null);
+ }
+
+ @Test
+ public void testgetStatus1() {
+
+ JujuClientManager jujuClientManager = new JujuClientManager();
+ JSONObject json = jujuClientManager.getStatus("");
+ assertTrue(json != null);
+ }
+
+ @Test
+ public void testgetStatus2() {
+ new MockUp<ProcessBuilder>() {
+ @Mock
+ public Process start() throws IOException {
+ Process process = new ProcessMockImpl();
+ return process;
+ }
+ };
+
+ JujuClientManager jujuClientManager = new JujuClientManager();
+ JSONObject json = jujuClientManager.getStatus("");
+ assertTrue(json != null);
+ }
+ @Test
+ public void testParseYaml(){
+ JujuClientManager jujuClientManager = new JujuClientManager();
+ jujuClientManager.parseYaml("abc/efg", "mediawiki.yaml", "addResource");
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/ProcessMockImpl.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/ProcessMockImpl.java
new file mode 100644
index 0000000..da75931
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/adapter/impl/ProcessMockImpl.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.service.adapter.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+
+public class ProcessMockImpl extends Process {
+
+ @Override
+ public OutputStream getOutputStream() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getInputStream() {
+ // TODO Auto-generated method stub
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos;
+ /*try {
+ oos = new ObjectOutputStream(baos);
+ oos.writeObject(new Object());
+ oos.flush();
+ oos.close();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }*/
+
+ InputStream is = new ByteArrayInputStream(baos.toByteArray());
+ return is;
+ }
+
+ @Override
+ public InputStream getErrorStream() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int waitFor() throws InterruptedException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int exitValue() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void destroy() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrServiceTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrServiceTest.java
new file mode 100644
index 0000000..e2ef790
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrServiceTest.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.api.internalsvc.impl;
+
+import org.junit.Test;
+
+public class JujuAdapterMgrServiceTest {
+
+ @Test
+ public void registerTest(){
+ JujuAdapterMgrService service = new JujuAdapterMgrService();
+ service.register();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/constant/ConstantTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/constant/ConstantTest.java
new file mode 100644
index 0000000..dff3c2b
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/constant/ConstantTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.constant;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.service.constant.Constant.AuthenticationMode;
+
+public class ConstantTest {
+
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = Constant.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+ @Test
+ public void testPrivateConstructor1() throws Exception {
+ Constructor constructor = Constant.AuthenticationMode.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/constant/ParamConstantsTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/constant/ParamConstantsTest.java
new file mode 100644
index 0000000..2ef3dea
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/constant/ParamConstantsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.constant;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import org.junit.Test;
+
+public class ParamConstantsTest {
+
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = ParamConstants.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/constant/UrlConstantTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/constant/UrlConstantTest.java
new file mode 100644
index 0000000..4e6b1ac
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/constant/UrlConstantTest.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.constant;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import org.junit.Test;
+
+public class UrlConstantTest {
+
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ Constructor constructor = UrlConstant.class.getDeclaredConstructor();
+ assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuDriverTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuDriverTest.java
new file mode 100644
index 0000000..cfef8bf
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuDriverTest.java
@@ -0,0 +1,309 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.service.entity;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.common.CryptUtil;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuDriver;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.VnfmOpResult;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+public class JujuDriverTest {
+
+ @Test
+ public void testGetServiceName() {
+ JujuDriver jujudriver = new JujuDriver();
+ String result = jujudriver.getServiceName();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetServiceName() {
+ JujuDriver jujudriver = new JujuDriver();
+ jujudriver.setServiceName("testServiceName");
+ String result = jujudriver.getServiceName();
+ assertEquals("testServiceName", result);
+ }
+
+ @Test
+ public void testGetProtocol() {
+ JujuDriver jujudriver = new JujuDriver();
+ String result = jujudriver.getProtocol();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetProtocol() {
+ JujuDriver jujudriver = new JujuDriver();
+ jujudriver.setProtocol("protocol");
+ String result = jujudriver.getProtocol();
+ assertEquals("protocol", result);
+ }
+
+ @Test
+ public void testGetVisualRange() {
+ JujuDriver jujudriver = new JujuDriver();
+ String result = jujudriver.getVisualRange();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetVisualRange() {
+ JujuDriver jujudriver = new JujuDriver();
+ jujudriver.setVisualRange("getVisualRange");
+ String result = jujudriver.getVisualRange();
+ assertEquals("getVisualRange", result);
+ }
+
+ @Test
+ public void testGetVersion() {
+ JujuDriver jujudriver = new JujuDriver();
+ String result = jujudriver.getVersion();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetVersion() {
+ JujuDriver jujudriver = new JujuDriver();
+ jujudriver.setVersion("testVersion");
+ String result = jujudriver.getVersion();
+ assertEquals("testVersion", result);
+ }
+
+ @Test
+ public void testGetUrl() {
+ JujuDriver jujudriver = new JujuDriver();
+ String result = jujudriver.getUrl();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetUrl() {
+ JujuDriver jujudriver = new JujuDriver();
+ jujudriver.setUrl("testUrl");
+ String result = jujudriver.getUrl();
+ assertEquals("testUrl", result);
+ }
+
+ @Test
+ public void testGetIP() {
+ JujuDriver jujudriver = new JujuDriver();
+ String result = jujudriver.getIP();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetIP() {
+ JujuDriver jujudriver = new JujuDriver();
+ jujudriver.setIP("testIP");
+ String result = jujudriver.getIP();
+ assertEquals("testIP", result);
+ }
+
+
+ @Test
+ public void testGetPort() {
+ JujuDriver jujudriver = new JujuDriver();
+ String result = jujudriver.getPort();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetPort() {
+ JujuDriver jujudriver = new JujuDriver();
+ jujudriver.setPort("testPort");
+ String result = jujudriver.getPort();
+ assertEquals("testPort", result);
+ }
+
+ @Test
+ public void testGetTtl() {
+ JujuDriver jujudriver = new JujuDriver();
+ String result = jujudriver.getTtl();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetTtl() {
+ JujuDriver jujudriver = new JujuDriver();
+ jujudriver.setTtl("testTtl");
+ String result = jujudriver.getTtl();
+ assertEquals("testTtl", result);
+ }
+
+ @Test
+ public void testGetStatus() {
+ JujuDriver jujudriver = new JujuDriver();
+ String result = jujudriver.getStatus();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetStatus() {
+ JujuDriver jujudriver = new JujuDriver();
+ jujudriver.setStatus("testStatus");
+ String result = jujudriver.getStatus();
+ assertEquals("testStatus", result);
+ }
+
+
+ @Test
+ public void testToString() {
+ JujuDriver jujudriver = new JujuDriver();
+ String result = jujudriver.toString();
+ assertEquals(
+ "JujuDriver[serviceName=<null>,protocol=<null>,version=<null>,visualRange=<null>,url=<null>,nodes=<null>,ip=<null>,port=<null>,ttl=<null>,status=<null>]",
+ result);
+ }
+
+ @Test
+ public void testToString1() {
+ JujuDriver jujudriver = new JujuDriver();
+ jujudriver.setServiceName("serviceName");
+ jujudriver.setProtocol("protocol");
+ jujudriver.setVersion("version");
+ jujudriver.setVisualRange("visualRange");
+ jujudriver.setUrl("testUrl");
+ jujudriver.setIP("testIP");
+ jujudriver.setPort("testPort");
+ jujudriver.setTtl("testTtl");
+ jujudriver.setStatus("testStatus");
+ String result = jujudriver.toString();
+ assertEquals(
+ "JujuDriver[serviceName=serviceName,protocol=protocol,version=version,visualRange=visualRange,url=testUrl,nodes=<null>,ip=testIP,port=testPort,ttl=testTtl,status=testStatus]",
+ result);
+ }
+
+ @Test
+ public void testHashCode() {
+ JujuDriver jujudriver = new JujuDriver();
+ int result = jujudriver.hashCode();
+ assertEquals(31, result);
+ }
+
+ @Test
+ public void testHashCode1() {
+ JujuDriver jujudriver = new JujuDriver();
+ jujudriver.setServiceName("serviceName");
+ int result = jujudriver.hashCode();
+ assertEquals(-1928572161, result);
+ }
+
+ @Test
+ public void testEquals() {
+ boolean result = new JujuDriver().equals(new JujuDriver());
+ assertTrue(result);
+ }
+
+ @Test
+ public void testEquals1() {
+ boolean result = new JujuDriver().equals("");
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals2() {
+ JujuVnfd obj = new JujuVnfd();
+ boolean result = new JujuDriver().equals(obj);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals3() {
+ JujuDriver obj = new JujuDriver();
+ obj.setServiceName("serviceName");
+ boolean result = new JujuDriver().equals(obj);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals4() {
+ JujuDriver obj = new JujuDriver();
+ boolean result = obj.equals(obj);
+ assertTrue(result);
+ }
+
+ @Test
+ public void testEquals5() {
+ boolean result = new JujuDriver().equals(null);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals6() {
+ JujuDriver jujudriver = new JujuDriver();
+ JujuDriver jujudriver2 = new JujuDriver();
+ jujudriver.setPort("");
+ jujudriver2.setPort("");
+ boolean result = jujudriver.equals(jujudriver2);
+ assertTrue(result);
+ }
+
+ @Test
+ public void testEquals7() {
+ JujuDriver jujudriver = new JujuDriver();
+ JujuDriver jujudriver2 = new JujuDriver();
+ jujudriver.setServiceName("serviceName");
+ jujudriver2.setServiceName("serName");
+ boolean result = jujudriver.equals(jujudriver2);
+ assertFalse(result);
+ }
+ @Test
+ public void JujuDriverConsTest(){
+ JSONObject jujuJsonObject = new JSONObject();
+ JSONArray array= new JSONArray();
+ array.add("1.1.1.1");
+ array.add("8080");
+ array.add("ttl");
+ jujuJsonObject.put("serviceName", "test123");
+ jujuJsonObject.put("protocol", "http");
+ jujuJsonObject.put("version", "v1");
+ jujuJsonObject.put("visualRange", "10");
+ jujuJsonObject.put("url", "/test");
+ jujuJsonObject.put("nodes", "[]");
+ jujuJsonObject.put("notes", array);
+ jujuJsonObject.put("status", "active");
+ JujuDriver driver = new JujuDriver(jujuJsonObject);
+ assertTrue("test123".equals(driver.getServiceName()));
+ }
+ @Test
+ public void testsetNodes() {
+ JujuDriver jujudriver = new JujuDriver();
+ List<String> nodes = new ArrayList<String>();
+ nodes.add("nodes");
+ jujudriver.setNodes(nodes);
+ }
+ @Test
+ public void testgetNodes() {
+ JujuDriver jujudriver = new JujuDriver();
+ List<String> nodes = new ArrayList<String>();
+ nodes.add("nodes");
+ jujudriver.getNodes();
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfdTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfdTest.java
new file mode 100644
index 0000000..b01e6c5
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfdTest.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.service.entity;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class JujuVnfdTest {
+
+ @Test
+ public void testGetDownloadUri() {
+ JujuVnfd jujuvnfd = new JujuVnfd();
+ String result = jujuvnfd.getDownloadUri();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetDownloadUri() {
+ JujuVnfd jujuvnfd = new JujuVnfd();
+ jujuvnfd.setDownloadUri("testDownloadUri");
+ String result = jujuvnfd.getDownloadUri();
+ assertEquals("testDownloadUri", result);
+ }
+
+ @Test
+ public void testGetLocalPath() {
+ JujuVnfd jujuvnfd = new JujuVnfd();
+ String result = jujuvnfd.getLocalPath();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetProtocol() {
+ JujuVnfd jujuvnfd = new JujuVnfd();
+ jujuvnfd.setLocalPath("testLocalPath");
+ String result = jujuvnfd.getLocalPath();
+ assertEquals("testLocalPath", result);
+ }
+
+
+ @Test
+ public void testToString() {
+ JujuVnfd jujuvnfd = new JujuVnfd();
+ String result = jujuvnfd.toString();
+ assertEquals(
+ "JujuVnfd[downloadUri=<null>,localPath=<null>]",
+ result);
+ }
+
+ @Test
+ public void testToString1() {
+ JujuVnfd jujuvnfd = new JujuVnfd();
+ jujuvnfd.setDownloadUri("testDownloadUri");
+ jujuvnfd.setLocalPath("testLocalPath");
+ String result = jujuvnfd.toString();
+ assertEquals(
+ "JujuVnfd[downloadUri=testDownloadUri,localPath=testLocalPath]",
+ result);
+ }
+
+ @Test
+ public void testHashCode() {
+ JujuVnfd jujuvnfd = new JujuVnfd();
+ int result = jujuvnfd.hashCode();
+ assertEquals(31, result);
+ }
+
+ @Test
+ public void testHashCode1() {
+ JujuVnfd jujuvnfd = new JujuVnfd();
+ jujuvnfd.setDownloadUri("testDownloadUri");
+ int result = jujuvnfd.hashCode();
+ assertEquals(-1870623759, result);
+ }
+
+ @Test
+ public void testEquals() {
+ boolean result = new JujuVnfd().equals(new JujuVnfd());
+ assertTrue(result);
+ }
+
+ @Test
+ public void testEquals1() {
+ boolean result = new JujuVnfd().equals("");
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals2() {
+ JujuDriver obj = new JujuDriver();
+ boolean result = new JujuVnfd().equals(obj);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals3() {
+ JujuVnfd obj = new JujuVnfd();
+ obj.setDownloadUri("testDownloadUri");
+ boolean result = new JujuVnfd().equals(obj);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals4() {
+ JujuVnfd obj = new JujuVnfd();
+ boolean result = obj.equals(obj);
+ assertTrue(result);
+ }
+
+ @Test
+ public void testEquals5() {
+ boolean result = new JujuVnfd().equals(null);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals6() {
+ JujuVnfd jujuvnfd = new JujuVnfd();
+ JujuVnfd jujudriver2 = new JujuVnfd();
+ jujuvnfd.setDownloadUri("");
+ jujudriver2.setDownloadUri("");
+ boolean result = jujuvnfd.equals(jujudriver2);
+ assertTrue(result);
+ }
+
+ @Test
+ public void testEquals7() {
+ JujuVnfd jujuvnfd = new JujuVnfd();
+ JujuVnfd jujudriver2 = new JujuVnfd();
+ jujuvnfd.setDownloadUri("testDownloadUri");
+ jujudriver2.setDownloadUri("DownloadUri");
+ boolean result = jujuvnfd.equals(jujudriver2);
+ assertFalse(result);
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfmInfoExampleTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfmInfoExampleTest.java
new file mode 100644
index 0000000..bf5f464
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfmInfoExampleTest.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.service.entity;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfmInfoExample.Criteria;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfmInfoExample.Criterion;
+
+public class JujuVnfmInfoExampleTest {
+
+ JujuVnfmInfoExample jujuexample = new JujuVnfmInfoExample();
+ protected List<Criterion> criteria;
+ @Test
+ public void createCriteriaTest(){
+ Criteria criteria = jujuexample.createCriteria();
+ String condition = "";
+ String value = "";
+ String property = "";
+ String value1 = "";
+ String value2 = "";
+ Date d1 =new Date();
+ Date d2 =new Date();
+ List<String> values = new ArrayList<String>();
+ criteria.addCriterion(condition);
+ criteria.addCriterion(condition, value, property);
+ criteria.addCriterion(condition, value1, value2, property);
+ criteria.andDeleteTimeBetween(d1, d2);
+ criteria.andAppNameBetween(value1, value2);
+ criteria.andAppNameEqualTo(value);
+ criteria.andAppNameGreaterThan(value);
+ criteria.andAppNameGreaterThanOrEqualTo(value);
+ criteria.andAppNameIn(values);
+ criteria.andAppNameLessThan(value);
+ criteria.andIdLessThanOrEqualTo(value);
+ criteria.andAppNameLike(value2);
+ criteria.andAppNameNotBetween(value1, value2);
+ criteria.andAppNameNotEqualTo(value2);
+ criteria.andAppNameNotIn(values);
+ criteria.andIdNotLike(value2);
+ criteria.andCreateTimeBetween(d1, d2);
+ criteria.andCreateTimeNotBetween(d1, d2);
+ criteria.andJobIdBetween(value1, value2);
+ criteria.andJobIdNotBetween(value1, value2);
+ criteria.andModifyTimeBetween(d1, d2);
+ criteria.andJobIdEqualTo(value2);
+ criteria.andJobIdGreaterThan(value2);
+ criteria.andJobIdGreaterThanOrEqualTo(value2);
+ criteria.andJobIdIn(values);
+ criteria.andJobIdLessThan(value2);
+ criteria.andJobIdLessThanOrEqualTo(value2);
+ criteria.andJobIdLike(value2);
+ criteria.andJobIdNotBetween(value1, value2);
+ criteria.andJobIdNotEqualTo(value2);
+ criteria.andJobIdNotIn(values);
+ criteria.andJobIdNotLike(value2);
+ assertNotNull(criteria);
+ }
+ @Test
+ public void orTest(){
+ Criteria criteria = jujuexample.or();
+ assertNotNull(criteria);
+ }
+ @Test
+ public void clearTest(){
+ jujuexample.clear();
+ assertTrue(true);
+ }
+ @Test
+ public void CriteriaTest(){
+ JujuVnfmInfoExample.Criteria criteria = new JujuVnfmInfoExample.Criteria();
+ boolean isValid = criteria.isValid();
+ assertTrue(!isValid);
+ }
+
+ @Test
+ public void CriterionTest(){
+ String condition="";
+ String value="";
+ String secondValue="";
+ String typeHandler="";
+
+ Criterion c = new Criterion(condition, value, secondValue, typeHandler);
+ assertEquals(c.getCondition(), "");
+ assertEquals(c.getValue(), "");
+ assertEquals(c.getSecondValue(), "");
+ assertEquals(c.getTypeHandler(), "");
+ assertEquals(c.isSingleValue(), false);
+ assertEquals(c.isBetweenValue(), true);
+ assertEquals(c.isListValue(), false);
+
+ }
+
+ @Test
+ public void generatedCriteriaTest(){
+ JujuVnfmInfoExample.Criteria criteria = new JujuVnfmInfoExample.Criteria();
+ boolean isValid = criteria.isValid();
+
+ assertTrue(!isValid);
+ }
+
+ @Test
+ public void andIdIsNullTest(){
+ JujuVnfmInfoExample.Criteria criteria = new JujuVnfmInfoExample.Criteria();
+ Criteria c= criteria.andIdIsNull();
+ assertNotNull(c);
+ }
+ @Test
+ public void getConditionCroterionTest(){
+ JujuVnfmInfoExample.Criterion criterion = new JujuVnfmInfoExample.Criterion("test",new Object(),"typeHandler");
+ String condition = criterion.getCondition();
+ assertEquals(condition,"test");
+ }
+ @Test
+ public void testLimitStart() {
+ JujuVnfmInfoExample jujuVnfmInfoExample=new JujuVnfmInfoExample();
+ jujuVnfmInfoExample.setLimitStart(-1);
+
+ int result = jujuVnfmInfoExample.getLimitStart();
+ assertEquals(-1, result);
+ }
+ @Test
+ public void testLimitEnd() {
+ JujuVnfmInfoExample jujuVnfmInfoExample=new JujuVnfmInfoExample();
+ jujuVnfmInfoExample.setLimitEnd(-1);
+
+ int result = jujuVnfmInfoExample.getLimitEnd();
+ assertEquals(-1, result);
+ }
+ @Test
+ public void testOrderByClause() {
+ JujuVnfmInfoExample jujuVnfmInfoExample=new JujuVnfmInfoExample();
+ jujuVnfmInfoExample.setOrderByClause("order");
+
+ String result = jujuVnfmInfoExample.getOrderByClause();
+ assertEquals("order", result);
+ }
+ @Test
+ public void testsetDistinct() {
+ JujuVnfmInfoExample jujuVnfmInfoExample=new JujuVnfmInfoExample();
+ jujuVnfmInfoExample.setDistinct(true);
+
+ boolean result=jujuVnfmInfoExample.isDistinct();
+ assertEquals(true,result);
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfmInfoTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfmInfoTest.java
new file mode 100644
index 0000000..6707a3d
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfmInfoTest.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.service.entity;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import java.util.Date;
+
+public class JujuVnfmInfoTest {
+
+ @Test
+ public void testSetId() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ jujuVnfmInfo.setId("testSetId");
+ String result = jujuVnfmInfo.getId();
+ assertEquals("testSetId", result);
+ }
+
+ @Test
+ public void testGetId() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ String result = jujuVnfmInfo.getId();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetVnfmId() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ jujuVnfmInfo.setVnfmId("testSetVnfmId");
+ String result = jujuVnfmInfo.getVnfmId();
+ assertEquals("testSetVnfmId", result);
+ }
+
+ @Test
+ public void testGetVnfmId() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ String result = jujuVnfmInfo.getVnfmId();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetVnfId() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ jujuVnfmInfo.setVnfId("testSetVnfId");
+ String result = jujuVnfmInfo.getVnfId();
+ assertEquals("testSetVnfId", result);
+ }
+
+ @Test
+ public void testGetVnfId() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ String result = jujuVnfmInfo.getVnfId();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetAppName() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ jujuVnfmInfo.setAppName("testSetAppName");
+ String result = jujuVnfmInfo.getAppName();
+ assertEquals("testSetAppName", result);
+ }
+
+ @Test
+ public void testGetAppName() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ String result = jujuVnfmInfo.getAppName();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetJobId() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ jujuVnfmInfo.setJobId("testSetJobId");
+ String result = jujuVnfmInfo.getJobId();
+ assertEquals("testSetJobId", result);
+ }
+
+ @Test
+ public void testGetJobId() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ String result = jujuVnfmInfo.getJobId();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetStatus() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ jujuVnfmInfo.setStatus(0);
+ Integer result = jujuVnfmInfo.getStatus();
+ assertEquals(Integer.valueOf(0), result);
+ }
+
+ @Test
+ public void testGetStatus() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ Integer result = jujuVnfmInfo.getStatus();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetCreateTime() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ jujuVnfmInfo.setCreateTime(new Date());
+ Date result = jujuVnfmInfo.getCreateTime();
+ assertEquals(new Date(), result);
+ }
+
+ @Test
+ public void testGetCreateTime() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ Date result = jujuVnfmInfo.getCreateTime();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetModifyTime() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ jujuVnfmInfo.setModifyTime(new Date());
+ Date result = jujuVnfmInfo.getModifyTime();
+ assertEquals(new Date(), result);
+ }
+
+ @Test
+ public void testGetModifyTime() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ Date result = jujuVnfmInfo.getModifyTime();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetDeleteTime() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ jujuVnfmInfo.setDeleteTime(new Date());
+ Date result = jujuVnfmInfo.getDeleteTime();
+ assertEquals(new Date(), result);
+ }
+
+ @Test
+ public void testGetDeleteTime() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ Date result = jujuVnfmInfo.getDeleteTime();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetExtend() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ jujuVnfmInfo.setExtend("testSetExtend");
+ String result = jujuVnfmInfo.getExtend();
+ assertEquals("testSetExtend", result);
+ }
+
+ @Test
+ public void testGetExtend() {
+ JujuVnfmInfo jujuVnfmInfo = new JujuVnfmInfo();
+ String result = jujuVnfmInfo.getExtend();
+ assertNull(result);
+ }
+
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfmTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfmTest.java
new file mode 100644
index 0000000..744aeef
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/JujuVnfmTest.java
@@ -0,0 +1,347 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.service.entity;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.common.CryptUtil;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfm;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.VnfmOpResult;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+public class JujuVnfmTest {
+
+ @Test
+ public void testGetId() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.getId();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetId() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setId("testId");
+ String result = jujuvnfm.getId();
+ assertEquals("testId", result);
+ }
+
+ @Test
+ public void testGetType() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.getType();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetType() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setType("testType");
+ String result = jujuvnfm.getType();
+ assertEquals("testType", result);
+ }
+
+ @Test
+ public void testGetName() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.getName();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetName() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setName("testName");
+ String result = jujuvnfm.getName();
+ assertEquals("testName", result);
+ }
+
+ @Test
+ public void testGetVersion() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.getVersion();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetVersion() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setVersion("testVersion");
+ String result = jujuvnfm.getVersion();
+ assertEquals("testVersion", result);
+ }
+
+ @Test
+ public void testGetUserName() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.getUserName();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetUserName() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setUserName("testUserName");
+ String result = jujuvnfm.getUserName();
+ assertEquals("testUserName", result);
+ }
+
+ @Test
+ public void testGetUrl() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.getUrl();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetUrl() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setUrl("testUrl");
+ String result = jujuvnfm.getUrl();
+ assertEquals("testUrl", result);
+ }
+
+ @Test
+ public void testGetPwd() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.getPwd();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetPwd() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setPwd("testPwd");
+ String result = jujuvnfm.getPwd();
+ assertEquals("testPwd", result);
+ }
+
+ @Test
+ public void testGetVender() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.getVendor();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetVender() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setVendor("testVendor");
+ String result = jujuvnfm.getVendor();
+ assertEquals("testVendor", result);
+ }
+
+ @Test
+ public void testGetExtraInfo() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.getExtraInfo();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetExtraInfo() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setExtraInfo("testExtraInfo");
+ String result = jujuvnfm.getExtraInfo();
+ assertEquals("testExtraInfo", result);
+ }
+
+ @Test
+ public void testGetStatus() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.getStatus();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetStatus() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setStatus("testStatus");
+ String result = jujuvnfm.getStatus();
+ assertEquals("testStatus", result);
+ }
+
+ @Test
+ public void testGetCreateAt() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.getCreateAt();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetCreateAt() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setCreateAt("testCreateAt");
+ String result = jujuvnfm.getCreateAt();
+ assertEquals("testCreateAt", result);
+ }
+
+ @Test
+ public void testGetUpdateAt() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.getUpdateAt();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetUpdateAt() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setUpdateAt("testUpdateAt");
+ String result = jujuvnfm.getUpdateAt();
+ assertEquals("testUpdateAt", result);
+ }
+
+ @Test
+ public void testToString() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ String result = jujuvnfm.toString();
+ assertEquals(
+ "JujuVnfm[id=<null>,name=<null>,type=<null>,version=<null>,userName=<null>,pwd=<null>,url=<null>,vendor=<null>,extraInfo=<null>,status=<null>,createAt=<null>,updateAt=<null>]",
+ result);
+ }
+
+ @Test
+ public void testToString1() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setId("testId");
+ jujuvnfm.setType("testType");
+ jujuvnfm.setName("testName");
+ jujuvnfm.setVersion("testVersion");
+ jujuvnfm.setUserName("testUserName");
+ jujuvnfm.setUrl("testUrl");
+ jujuvnfm.setPwd("testPwd");
+ jujuvnfm.setVendor("testVendor");
+ jujuvnfm.setExtraInfo("testExtraInfo");
+ jujuvnfm.setStatus("testStatus");
+ jujuvnfm.setCreateAt("testCreateAt");
+ jujuvnfm.setUpdateAt("testUpdateAt");
+ String result = jujuvnfm.toString();
+ assertEquals(
+ "JujuVnfm[id=testId,name=testName,type=testType,version=testVersion,userName=testUserName,pwd=testPwd,url=testUrl,vendor=testVendor,extraInfo=testExtraInfo,status=testStatus,createAt=testCreateAt,updateAt=testUpdateAt]",
+ result);
+ }
+
+ @Test
+ public void testHashCode() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ int result = jujuvnfm.hashCode();
+ assertEquals(31, result);
+ }
+
+ @Test
+ public void testHashCode1() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setId("testId");
+ int result = jujuvnfm.hashCode();
+ assertEquals(-877170324, result);
+ }
+
+ @Test
+ public void testEquals() {
+ boolean result = new JujuVnfm().equals(new JujuVnfm());
+ assertTrue(result);
+ }
+
+ @Test
+ public void testEquals1() {
+ boolean result = new JujuVnfm().equals("");
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals2() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ jujuvnfm.setId("testId");
+ VnfmOpResult obj = new VnfmOpResult();
+ boolean result = new JujuVnfm().equals(obj);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals3() {
+ JujuVnfm obj = new JujuVnfm();
+ obj.setId("testId");
+ boolean result = new JujuVnfm().equals(obj);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals4() {
+ JujuVnfm obj = new JujuVnfm();
+ boolean result = obj.equals(obj);
+ assertTrue(result);
+ }
+
+ @Test
+ public void testEquals5() {
+ boolean result = new JujuVnfm().equals(null);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals6() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ JujuVnfm vnfm2 = new JujuVnfm();
+ jujuvnfm.setId("");
+ vnfm2.setId("");
+ boolean result = jujuvnfm.equals(vnfm2);
+ assertTrue(result);
+ }
+
+ @Test
+ public void testEquals7() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ JujuVnfm vnfm2 = new JujuVnfm();
+ jujuvnfm.setId("vnfmId");
+ vnfm2.setId("vnfm2Id");
+ boolean result = jujuvnfm.equals(vnfm2);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testUpdateVnfm() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ JSONObject obj = new JSONObject();
+ obj.put("name", "name");
+ obj.put("userName", "userName");
+ obj.put("pwd", "pwd");
+ obj.put("extraInfo", "extraInfo");
+ jujuvnfm.updateVnfm(obj);
+ assertEquals("name", jujuvnfm.getName());
+ assertEquals("userName", jujuvnfm.getUserName());
+ }
+
+ @Test
+ public void testUpdateVnfmByEmpty() {
+ JujuVnfm jujuvnfm = new JujuVnfm();
+ JSONObject obj = new JSONObject();
+ obj.put("name", "");
+ obj.put("userName", "");
+ obj.put("pwd", "");
+ obj.put("extraInfo", "");
+ jujuvnfm.updateVnfm(obj);
+ assertNull(jujuvnfm.getName());
+ assertNull(jujuvnfm.getUserName());
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/MSBRequestEntityTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/MSBRequestEntityTest.java
new file mode 100644
index 0000000..2f3ec92
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/MSBRequestEntityTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.service.entity;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.MSBRequestEntity.Node;
+
+public class MSBRequestEntityTest {
+ MSBRequestEntity msbRequestEntity = new MSBRequestEntity();
+
+ @Test
+ public void testMSBRequestEntity() {
+ List<Node> nodes = new ArrayList<>();
+ msbRequestEntity.setNodes(nodes);
+ String protocol = "protocol";
+ msbRequestEntity.setProtocol(protocol);
+ String serviceName = "serviceName";
+ msbRequestEntity.setServiceName(serviceName);
+ String status = "status";
+ msbRequestEntity.setStatus(status);
+ String url = "url";
+ msbRequestEntity.setUrl(url);
+ String version = "version";
+ msbRequestEntity.setVersion(version);
+ String visualRange = " visualRange";
+ msbRequestEntity.setVisualRange(visualRange);
+ msbRequestEntity.toString();
+ assertEquals(msbRequestEntity.getNodes(), nodes);;
+ assertEquals(msbRequestEntity.getNodes(), nodes);
+ assertEquals(msbRequestEntity.getProtocol(), protocol);
+ assertEquals(msbRequestEntity.getServiceName(), serviceName);
+ assertEquals(msbRequestEntity.getStatus(), status);
+ assertEquals(msbRequestEntity.getUrl(), url);
+ assertEquals(msbRequestEntity.getVersion(), version);
+ assertEquals(msbRequestEntity.getVisualRange(), visualRange);
+ }
+
+ @Test
+ public void testNode() {
+ Node n = new Node();
+ String createdAt = "Test";
+ n.setCreatedAt(createdAt);
+ String ip = "192.168.4.47";
+ n.setIp(ip);
+ String expiration = "";
+ n.setExpiration(expiration);
+ String port = "80";
+ n.setPort(port);
+ String updatedAt = "";
+ n.setUpdatedAt(updatedAt);
+ String ttl = "";
+ n.setTtl(ttl);
+
+ assertEquals(n.getCreatedAt(), "Test");
+ assertEquals(n.getIp(), "192.168.4.47");
+ assertEquals(n.getExpiration(), "");
+ assertEquals(n.getPort(),"80");
+ assertEquals(n.getUpdatedAt(), "");
+ assertEquals(n.getTtl(), "");
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/VnfmOpResultTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/VnfmOpResultTest.java
new file mode 100644
index 0000000..5089682
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/VnfmOpResultTest.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.service.entity;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.VnfmOpResult;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.VnfmOpResult.TaskStatus;
+
+public class VnfmOpResultTest {
+
+ @Test
+ public void testVnfmOpResult() {
+ VnfmOpResult result = new VnfmOpResult();
+ assertEquals(TaskStatus.INIT, result.getOperateStatus());
+ assertEquals("", result.getErrorMessage());
+ }
+
+ @Test
+ public void testVnfmOpResult1() {
+ VnfmOpResult result = new VnfmOpResult(TaskStatus.SUCCESS, "success");
+ assertEquals(TaskStatus.SUCCESS, result.getOperateStatus());
+ assertEquals("success", result.getErrorMessage());
+ }
+
+ @Test
+ public void testSotOperateStatus() {
+ VnfmOpResult result = new VnfmOpResult();
+ result.setOperateStatus(TaskStatus.SUCCESS);
+ assertEquals(TaskStatus.SUCCESS, result.getOperateStatus());
+ }
+
+ @Test
+ public void testSotOperateStatusByNull() {
+ VnfmOpResult result = new VnfmOpResult();
+ result.setOperateStatus(null);
+ assertNull(result.getOperateStatus());
+ }
+
+ @Test
+ public void testSotErrorMessage() {
+ VnfmOpResult result = new VnfmOpResult();
+ result.setErrorMessage("Fail!");
+ assertEquals("Fail!", result.getErrorMessage());
+ }
+
+ @Test
+ public void testSotErrorMessageByNull() {
+ VnfmOpResult result = new VnfmOpResult();
+ result.setErrorMessage(null);
+ assertNull(result.getErrorMessage());
+ }
+
+ @Test
+ public void testAddResult() {
+ VnfmOpResult result = new VnfmOpResult();
+ result.addResult("Result");
+ List<String> arr = new ArrayList<String>();
+ arr.add("Result");
+ assertEquals(arr, result.getResult());
+ }
+
+ @Test
+ public void testAddResultByList() {
+ VnfmOpResult result = new VnfmOpResult();
+ List<String> arr = new ArrayList<String>();
+ arr.add("Result");
+ arr.add("Test");
+ result.addResult(arr);
+ assertEquals(arr, result.getResult());
+ }
+
+ @Test
+ public void testAddResultByNull() {
+ VnfmOpResult result = new VnfmOpResult();
+ List<String> arr = new ArrayList<String>();
+ arr.add(null);
+ result.addResult(null);
+ assertEquals(arr, result.getResult());
+ }
+
+ @Test
+ public void testToString() {
+ VnfmOpResult result = new VnfmOpResult();
+ assertEquals(
+ "org.openo.nfvo.jujuvnfmadapter.service.entity.VnfmOpResult@[operateStatus=INIT, errorCode=0, errorMessage=]",
+ result.toString());
+ }
+
+ @Test
+ public void testToString1() {
+ VnfmOpResult result = new VnfmOpResult(TaskStatus.SUCCESS, "success");
+ assertEquals(
+ "org.openo.nfvo.jujuvnfmadapter.service.entity.VnfmOpResult@[operateStatus=SUCCESS, errorCode=0, errorMessage=success]",
+ result.toString());
+ }
+
+ @Test
+ public void testTaskStatus() {
+ VnfmOpResult result=new VnfmOpResult();
+ assertEquals(TaskStatus.INIT, TaskStatus.valueOf("INIT"));
+ assertEquals(TaskStatus.SUCCESS, TaskStatus.valueOf("SUCCESS"));
+ assertEquals(TaskStatus.PART_SUCCESS, TaskStatus.valueOf("PART_SUCCESS"));
+ assertEquals(TaskStatus.RUNNING, TaskStatus.valueOf("RUNNING"));
+ assertEquals(TaskStatus.TIMEOUT, TaskStatus.valueOf("TIMEOUT"));
+ assertEquals(TaskStatus.FAIL, TaskStatus.valueOf("FAIL"));
+
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/VnfmTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/VnfmTest.java
new file mode 100644
index 0000000..5eaf230
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/entity/VnfmTest.java
@@ -0,0 +1,347 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.service.entity;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.common.CryptUtil;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.Vnfm;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.VnfmOpResult;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+public class VnfmTest {
+
+ @Test
+ public void testGetId() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.getId();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetId() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setId("testId");
+ String result = vnfm.getId();
+ assertEquals("testId", result);
+ }
+
+ @Test
+ public void testGetType() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.getType();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetType() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setType("testType");
+ String result = vnfm.getType();
+ assertEquals("testType", result);
+ }
+
+ @Test
+ public void testGetName() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.getName();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetName() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setName("testName");
+ String result = vnfm.getName();
+ assertEquals("testName", result);
+ }
+
+ @Test
+ public void testGetVersion() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.getVersion();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetVersion() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setVersion("testVersion");
+ String result = vnfm.getVersion();
+ assertEquals("testVersion", result);
+ }
+
+ @Test
+ public void testGetUserName() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.getUserName();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetUserName() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setUserName("testUserName");
+ String result = vnfm.getUserName();
+ assertEquals("testUserName", result);
+ }
+
+ @Test
+ public void testGetUrl() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.getUrl();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetUrl() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setUrl("testUrl");
+ String result = vnfm.getUrl();
+ assertEquals("testUrl", result);
+ }
+
+ @Test
+ public void testGetPwd() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.getPwd();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetPwd() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setPwd("testPwd");
+ String result = vnfm.getPwd();
+ assertEquals("testPwd", result);
+ }
+
+ @Test
+ public void testGetSites() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.getSites();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetSites() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setSites("testSites");
+ String result = vnfm.getSites();
+ assertEquals("testSites", result);
+ }
+
+ @Test
+ public void testGetExtraInfo() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.getExtraInfo();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetExtraInfo() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setExtraInfo("testExtraInfo");
+ String result = vnfm.getExtraInfo();
+ assertEquals("testExtraInfo", result);
+ }
+
+ @Test
+ public void testGetStatus() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.getStatus();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetStatus() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setStatus("testStatus");
+ String result = vnfm.getStatus();
+ assertEquals("testStatus", result);
+ }
+
+ @Test
+ public void testGetCreateAt() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.getCreateAt();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetCreateAt() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setCreateAt("testCreateAt");
+ String result = vnfm.getCreateAt();
+ assertEquals("testCreateAt", result);
+ }
+
+ @Test
+ public void testGetUpdateAt() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.getUpdateAt();
+ assertNull(result);
+ }
+
+ @Test
+ public void testSetUpdateAt() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setUpdateAt("testUpdateAt");
+ String result = vnfm.getUpdateAt();
+ assertEquals("testUpdateAt", result);
+ }
+
+ @Test
+ public void testToString() {
+ Vnfm vnfm = new Vnfm();
+ String result = vnfm.toString();
+ assertEquals(
+ "Vnfm[id=<null>,name=<null>,type=<null>,version=<null>,userName=<null>,pwd=<null>,url=<null>,sites=<null>,extraInfo=<null>,status=<null>,createAt=<null>,updateAt=<null>]",
+ result);
+ }
+
+ @Test
+ public void testToString1() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setId("testId");
+ vnfm.setType("testType");
+ vnfm.setName("testName");
+ vnfm.setVersion("testVersion");
+ vnfm.setUserName("testUserName");
+ vnfm.setUrl("testUrl");
+ vnfm.setPwd("testPwd");
+ vnfm.setSites("testSites");
+ vnfm.setExtraInfo("testExtraInfo");
+ vnfm.setStatus("testStatus");
+ vnfm.setCreateAt("testCreateAt");
+ vnfm.setUpdateAt("testUpdateAt");
+ String result = vnfm.toString();
+ assertEquals(
+ "Vnfm[id=testId,name=testName,type=testType,version=testVersion,userName=testUserName,pwd=testPwd,url=testUrl,sites=testSites,extraInfo=testExtraInfo,status=testStatus,createAt=testCreateAt,updateAt=testUpdateAt]",
+ result);
+ }
+
+ @Test
+ public void testHashCode() {
+ Vnfm vnfm = new Vnfm();
+ int result = vnfm.hashCode();
+ assertEquals(31, result);
+ }
+
+ @Test
+ public void testHashCode1() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setId("testId");
+ int result = vnfm.hashCode();
+ assertEquals(-877170324, result);
+ }
+
+ @Test
+ public void testEquals() {
+ boolean result = new Vnfm().equals(new Vnfm());
+ assertTrue(result);
+ }
+
+ @Test
+ public void testEquals1() {
+ boolean result = new Vnfm().equals("");
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals2() {
+ Vnfm vnfm = new Vnfm();
+ vnfm.setId("testId");
+ VnfmOpResult obj = new VnfmOpResult();
+ boolean result = new Vnfm().equals(obj);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals3() {
+ Vnfm obj = new Vnfm();
+ obj.setId("testId");
+ boolean result = new Vnfm().equals(obj);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals4() {
+ Vnfm obj = new Vnfm();
+ boolean result = obj.equals(obj);
+ assertTrue(result);
+ }
+
+ @Test
+ public void testEquals5() {
+ boolean result = new Vnfm().equals(null);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testEquals6() {
+ Vnfm vnfm = new Vnfm();
+ Vnfm vnfm2 = new Vnfm();
+ vnfm.setId("");
+ vnfm2.setId("");
+ boolean result = vnfm.equals(vnfm2);
+ assertTrue(result);
+ }
+
+ @Test
+ public void testEquals7() {
+ Vnfm vnfm = new Vnfm();
+ Vnfm vnfm2 = new Vnfm();
+ vnfm.setId("vnfmId");
+ vnfm2.setId("vnfm2Id");
+ boolean result = vnfm.equals(vnfm2);
+ assertFalse(result);
+ }
+
+ @Test
+ public void testUpdateVnfm() {
+ Vnfm vnfm = new Vnfm();
+ JSONObject obj = new JSONObject();
+ obj.put("name", "name");
+ obj.put("userName", "userName");
+ obj.put("pwd", "pwd");
+ obj.put("extraInfo", "extraInfo");
+ vnfm.updateVnfm(obj);
+ assertEquals("name", vnfm.getName());
+ assertEquals("userName", vnfm.getUserName());
+ }
+
+ @Test
+ public void testUpdateVnfmByEmpty() {
+ Vnfm vnfm = new Vnfm();
+ JSONObject obj = new JSONObject();
+ obj.put("name", "");
+ obj.put("userName", "");
+ obj.put("pwd", "");
+ obj.put("extraInfo", "");
+ vnfm.updateVnfm(obj);
+ //assertNull(vnfm.getName());
+ //assertNull(vnfm.getUserName());
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/exception/UnsupportedOperationExceptionTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/exception/UnsupportedOperationExceptionTest.java
new file mode 100644
index 0000000..6baaf57
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/exception/UnsupportedOperationExceptionTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.exception;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class UnsupportedOperationExceptionTest {
+ UnsupportedOperationException mess;
+
+ @Before
+ public void setUp(){
+ mess = new UnsupportedOperationException();
+ }
+
+ @Test
+ public void test() {
+
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/juju/config/ConfigItemTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/juju/config/ConfigItemTest.java
new file mode 100644
index 0000000..84dc214
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/juju/config/ConfigItemTest.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.juju.config;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ConfigItemTest {
+
+ @Test
+ public void testsetDefaults() {
+ ConfigItem configItem = new ConfigItem();
+ configItem.setDefaults("");
+ String result = configItem.getDefaults();
+ assertEquals("", result);
+ }
+ @Test
+ public void testsetdescription() {
+ ConfigItem configItem = new ConfigItem();
+ configItem.setDescription("");
+ String result = configItem.getDescription();
+ assertEquals("", result);
+ }
+ @Test
+ public void testsettype() {
+ ConfigItem configItem = new ConfigItem();
+ configItem.setType("");
+ String result = configItem.getType();
+ assertEquals("", result);
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/juju/config/ConfigTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/juju/config/ConfigTest.java
new file mode 100644
index 0000000..ee3faee
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/juju/config/ConfigTest.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.juju.config;
+
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class ConfigTest {
+ @Test
+ public void testsetDefaults() {
+
+ Map<String,ConfigItem> options=new HashMap<String,ConfigItem> ();
+ ConfigItem configItem=new ConfigItem();
+ configItem.setDescription("");
+ options.put("", configItem);
+ Config config=new Config(options);
+ config.setOptions(options);
+ Map map=config.getOptions();
+ assertEquals(options, map);
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/juju/config/OptionsTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/juju/config/OptionsTest.java
new file mode 100644
index 0000000..76e5b3e
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/juju/config/OptionsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.juju.config;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import mockit.MockUp;
+
+public class OptionsTest {
+
+ @Test
+ public void test() {
+ Options o=new Options();
+ new MockUp<Options>() {
+
+ };
+
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/process/VnfMgrTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/process/VnfMgrTest.java
new file mode 100644
index 0000000..1a9ae6e
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/process/VnfMgrTest.java
@@ -0,0 +1,404 @@
+/*
+ * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.service.process;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.roa.util.restclient.RestfulResponse;
+import org.openo.nfvo.jujuvnfmadapter.common.VnfmUtil;
+import org.openo.nfvo.jujuvnfmadapter.common.servicetoken.VnfmRestfulUtil;
+import org.openo.nfvo.jujuvnfmadapter.service.adapter.inf.IResourceManager;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfmInfo;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+public class VnfMgrTest {
+
+ VnfMgr mgr;
+ @Before
+ public void setUp() {
+ mgr = new VnfMgr();
+ mgr.getJujuVnfmInfoMapper();
+ mgr.getResourceManager();
+
+ }
+
+ @Test
+ public void addVnfTestNullJson() {
+ JSONObject vnfObject = new JSONObject();
+ String vnfmId = "1234";
+ JSONObject resp = mgr.addVnf(vnfObject, vnfmId);
+ assertEquals(resp.get("retCode"), -1);
+ }
+
+ @Test
+ public void addVnfTestOk() {
+
+ new MockUp<VnfmUtil>() {
+
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ JSONObject vnfmObject = new JSONObject();
+ vnfmObject.put("url", "http://localhost:8080");
+ return vnfmObject;
+ }
+ };
+ new MockUp<VnfmRestfulUtil>() {
+
+ @Mock
+ public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params,
+ String domainTokens) {
+ RestfulResponse resp = new RestfulResponse();
+ resp.setStatus(200);
+ return resp;
+ }
+ };
+ JSONObject vnfObject = new JSONObject();
+ vnfObject.put("vnfInstanceName", "test123");
+ vnfObject.put("vnfPackageId", "123");
+ String vnfmId = "1234";
+ JSONObject resp = mgr.addVnf(vnfObject, vnfmId);
+ assertEquals(resp.get("retCode"), -1);
+ }
+
+ @Test
+ public void addVnfTestNull() {
+
+ new MockUp<VnfmUtil>() {
+
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ JSONObject vnfmObject = new JSONObject();
+ return vnfmObject;
+ }
+ };
+ JSONObject vnfObject = new JSONObject();
+ vnfObject.put("vnfInstanceName", "test123");
+ String vnfmId = "1234";
+ JSONObject resp = mgr.addVnf(vnfObject, vnfmId);
+ assertEquals(resp.get("retCode"), -1);
+ }
+
+ @Test
+ public void addVnfTestNullRes() {
+
+ new MockUp<VnfmUtil>() {
+
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ JSONObject vnfmObject = new JSONObject();
+ vnfmObject.put("url", "http://localhost:8080");
+ return vnfmObject;
+ }
+ };
+ new MockUp<VnfmRestfulUtil>() {
+
+ @Mock
+ public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params,
+ String domainTokens) {
+
+ return null;
+ }
+ };
+ JSONObject vnfObject = new JSONObject();
+ vnfObject.put("vnfInstanceName", "test123");
+ String vnfmId = "1234";
+ JSONObject resp = mgr.addVnf(vnfObject, vnfmId);
+ assertEquals(resp.get("retCode"), -1);
+ }
+
+ @Test
+ public void deleteVnfTestNullJson() {
+
+ new MockUp<VnfmUtil>() {
+
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ return null;
+ }
+ };
+ JSONObject vnfObject = new JSONObject();
+ vnfObject.put("vnfInstanceName", "test123");
+ String vnfmId = "1234";
+ JSONObject resp = mgr.deleteVnf("vnfId", "vnfmId", vnfObject);
+ assertEquals(resp.get("retCode"), -1);
+ }
+
+ @Test
+ public void deleteVnfTestValidJson() {
+
+ new MockUp<VnfmUtil>() {
+
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ JSONObject obj = new JSONObject();
+ obj.put("url", "http://localhost:8080");
+ return obj;
+ }
+ };
+ new MockUp<VnfMgr>(){
+ @Mock
+ private JujuVnfmInfo findByVnfId(String vnfId){
+ JujuVnfmInfo info = new JujuVnfmInfo();
+ info.setVnfmId("1234");
+ return info;
+ }
+ };
+ JSONObject vnfObject = new JSONObject();
+ vnfObject.put("vnfInstanceName", "test123");
+ String vnfmId = "1234";
+ JSONObject resp = mgr.deleteVnf("vnfId", "vnfmId", vnfObject);
+ assertEquals(resp.get("retCode"), -1);
+ }
+
+ @Test
+ public void deleteVnf2TestNormal() {
+
+ new MockUp<VnfmUtil>() {
+
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ JSONObject obj = new JSONObject();
+ obj.put("url", "http://localhost:8080");
+ return obj;
+ }
+ };
+ new MockUp<VnfMgr>(){
+ @Mock
+ private JujuVnfmInfo findByVnfId(String vnfId){
+ JujuVnfmInfo info = new JujuVnfmInfo();
+ info.setVnfmId("1234");
+ return info;
+ }
+ @Mock
+ private void delJujuVnfmInfo(String vnfId){
+ return;
+ }
+ };
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params, String domainTokens) {
+ RestfulResponse resp = new RestfulResponse();
+ resp.setStatus(204);
+ return resp;
+ }
+ };
+ JSONObject vnfObject = new JSONObject();
+ vnfObject.put("vnfInstanceName", "test123");
+ String vnfmId = "1234";
+ JSONObject resp = mgr.deleteVnf("vnfId", "vnfmId", vnfObject);
+ assertEquals(resp.get("retCode"), 1);
+ }
+
+ @Test
+ public void getVnfTestNullResp() {
+ new MockUp<VnfmUtil>() {
+
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ return null;
+ }
+ };
+ JSONObject resp = mgr.getVnf("vnfId", "vnfmId");
+ assertEquals(resp.get("retCode"), -1);
+ }
+
+ @Test
+ public void getVnfTestValidJson() {
+ new MockUp<VnfmUtil>() {
+
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ JSONObject obj = new JSONObject();
+ obj.put("url", "http://localhost:8080");
+ return obj;
+ }
+ };
+ new MockUp<VnfMgr>(){
+ @Mock
+ private JujuVnfmInfo findByVnfId(String vnfId){
+ JujuVnfmInfo info = new JujuVnfmInfo();
+ info.setVnfmId("1234");
+ return info;
+ }
+ @Mock
+ private void delJujuVnfmInfo(String vnfId){
+ return;
+ }
+ };
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params, String domainTokens) {
+ RestfulResponse resp = new RestfulResponse();
+ resp.setStatus(201);
+ JSONObject obj = new JSONObject();
+ obj.put("data", new JSONObject());
+ resp.setResponseJson(obj.toString());
+ return resp;
+ }
+ };
+ JSONObject resp = mgr.getVnf("vnfId", "vnfmId");
+ assertEquals(resp.get("retCode"), -1);
+ }
+
+ @Test
+ public void getJobTestNullResp(){
+ new MockUp<VnfmUtil>() {
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ return null;
+ }
+ };
+ JSONObject resp = mgr.getJob("jobId", "vnfmId");
+ assertEquals(resp.get("retCode"), null);
+ }
+
+ @Test
+ public void getJobTestNullHttpResp(){
+ new MockUp<VnfmUtil>() {
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ JSONObject ret = new JSONObject();
+ ret.put("url", "http://localhost:8080");
+ return ret;
+ }
+ };
+ JSONObject resp = mgr.getJob("jobId", "vnfmId");
+ assertEquals(resp.get("retCode"), null);
+ }
+ @Test
+ public void getJobTestSuccessWithNullData(){
+ new MockUp<VnfmUtil>() {
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ JSONObject ret = new JSONObject();
+ ret.put("url", "http://localhost:8080");
+ return ret;
+ }
+ };
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params, String domainTokens) {
+ RestfulResponse res = new RestfulResponse();
+ res.setStatus(201);
+
+ return res;
+ }
+ };
+ JSONObject resp = mgr.getJob("jobId", "vnfmId");
+ assertEquals(resp.get("retCode"), null);
+ }
+ @Test
+ public void getJobTestOkWithNullData(){
+ new MockUp<VnfmUtil>() {
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ JSONObject ret = new JSONObject();
+ ret.put("url", "http://localhost:8080");
+ return ret;
+ }
+ };
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params, String domainTokens) {
+ RestfulResponse res = new RestfulResponse();
+ res.setStatus(200);
+
+ return res;
+ }
+ };
+ JSONObject resp = mgr.getJob("jobId", "vnfmId");
+ assertEquals(resp.get("retCode"), null);
+ }
+ @Test
+ public void getJobTestInternalError(){
+ new MockUp<VnfmUtil>() {
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ JSONObject ret = new JSONObject();
+ ret.put("url", "http://localhost:8080");
+ return ret;
+ }
+ };
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params, String domainTokens) {
+ RestfulResponse res = new RestfulResponse();
+ res.setStatus(500);
+
+ return res;
+ }
+ };
+ JSONObject resp = mgr.getJob("jobId", "vnfmId");
+ assertEquals(resp.get("retCode"), null);
+ }
+ @Test
+ public void getJobTestNormal(){
+ new MockUp<VnfmUtil>() {
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ JSONObject ret = new JSONObject();
+ ret.put("url", "http://localhost:8080");
+ return ret;
+ }
+ };
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params, String domainTokens) {
+ RestfulResponse res = new RestfulResponse();
+ JSONObject jsonData = new JSONObject();
+ jsonData.put("data", new JSONObject());
+ res.setStatus(200);
+ res.setResponseJson(jsonData.toString());
+ return res;
+ }
+ };
+ JSONObject resp = mgr.getJob("jobId", "vnfmId");
+ assertEquals(resp.get("retCode"), null);
+ }
+ @Test
+ public void getJobTestNullData(){
+ new MockUp<VnfmUtil>() {
+ @Mock
+ public JSONObject getVnfmById(String vnfmId) {
+ JSONObject ret = new JSONObject();
+ ret.put("url", "http://localhost:8080");
+ return ret;
+ }
+ };
+ new MockUp<VnfmRestfulUtil>(){
+ @Mock
+ public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params, String domainTokens) {
+ RestfulResponse res = new RestfulResponse();
+ JSONObject jsonData = new JSONObject();
+ jsonData.put("data", null);
+ res.setStatus(200);
+ res.setResponseJson(jsonData.toString());
+ return res;
+ }
+ };
+ JSONObject resp = mgr.getJob("jobId", "vnfmId");
+ assertEquals(resp.get("retCode"),null);
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/process/VnfResourceMgrTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/process/VnfResourceMgrTest.java
new file mode 100644
index 0000000..013ecd7
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/process/VnfResourceMgrTest.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.process;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.jujuvnfmadapter.service.constant.Constant;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfmInfo;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfmInfoExample;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfmInfoExample.Criteria;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfmInfoExample.Criterion;
+import org.openo.nfvo.jujuvnfmadapter.service.mapper.JujuVnfmInfoMapper;
+
+import mockit.Expectations;
+import mockit.Mock;
+import mockit.MockUp;
+import mockit.Mocked;
+import mockit.integration.junit4.JMockit;
+import net.sf.json.JSONObject;
+import static mockit.Deencapsulation.*;
+
+
+@RunWith(JMockit.class)
+
+public class VnfResourceMgrTest {
+ VnfResourceMgr vnfMgr;
+ JujuVnfmInfoMapper jujuVnfmInfoMapper;
+ JujuVnfmInfoExample jujuexample = new JujuVnfmInfoExample();
+ Criteria criteria = jujuexample.createCriteria();
+
+ @Before
+ public void setUp() {
+ vnfMgr = new VnfResourceMgr();
+ vnfMgr.setJujuVnfmInfoMapper(jujuVnfmInfoMapper);
+ vnfMgr.getJujuVnfmInfoMapper();
+ }
+
+ @Test
+ public void grantVnfResourceTest() throws ServiceException {
+
+ String vnfId = "1";
+ new Expectations(vnfMgr) {
+ {
+ invoke(vnfMgr, "findByVnfId", "1");
+ JujuVnfmInfo info = new JujuVnfmInfo();
+ info.setId("1");
+ info.setAppName("Test");
+ info.setJobId("1");
+ info.setVnfId(vnfId);
+ returns(info);
+ }
+ };
+ JSONObject compute = new JSONObject();
+ JSONObject res = vnfMgr.grantVnfResource(compute, vnfId);
+ assertEquals(res.get("retCode"), -1);
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/ConfigRoaTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/ConfigRoaTest.java
new file mode 100644
index 0000000..53893a5
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/ConfigRoaTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.service.rest;
+
+import static org.junit.Assert.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.baseservice.roa.util.restclient.RestfulResponse;
+import org.openo.nfvo.jujuvnfmadapter.common.JujuConfigUtil;
+import org.openo.nfvo.jujuvnfmadapter.common.servicetoken.VnfmRestfulUtil;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+public class ConfigRoaTest {
+ ConfigRoa roa;
+
+ @Before
+ public void setUp() {
+ roa = new ConfigRoa();
+ }
+
+ @Test
+ public void initUITest() {
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String res = roa.initUI(context, resp);
+ assertNotNull(res);
+ }
+
+ @Test
+ public void setDebugModelTest() throws ServiceException {
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ boolean res = roa.setDebugModel(1, context, resp);
+ assertTrue(res);
+ }
+
+ @Test
+ public void setDebug2ModelTest() throws ServiceException {
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ boolean res = roa.setDebugModel(2, context, resp);
+ 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);
+
+ }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/JujuClientRoaTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/JujuClientRoaTest.java
new file mode 100644
index 0000000..4f02669
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/JujuClientRoaTest.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.jujuvnfmadapter.common.StringUtil;
+import org.openo.nfvo.jujuvnfmadapter.service.adapter.impl.JujuClientManager;
+import org.openo.nfvo.jujuvnfmadapter.service.process.VnfMgr;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+public class JujuClientRoaTest {
+
+ JujuClientRoa roa;
+
+
+ @Before
+ public void setUp(){
+ roa = new JujuClientRoa();
+ roa.setJujuClientManager(new JujuClientManager());
+ roa.getJujuClientManager();
+
+ }
+
+ @Test
+ public void setCharmUrlTest() throws ServiceException {
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest context) {
+ String reqJsonObject = "{}";
+ return (T)JSONObject.fromObject(reqJsonObject);
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String res = roa.setCharmUrl(context, resp);
+ assertNotNull(res);
+ }
+ @Test
+ public void getVnfStatusTest() throws ServiceException {
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String res = roa.getVnfStatus("appName", context,resp);
+ assertNotNull(res);
+ }
+ @Test
+ public void deploySerivceTestFail() throws ServiceException {
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ return null;
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String res = roa.deploySerivce(context,resp);
+ assertNotNull(res);
+ }
+ @Test
+ public void deploySerivceTest() throws ServiceException {
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ JSONObject reqJsonObject = new JSONObject();
+ reqJsonObject.put("charmPath", "/abc/xyz");
+ reqJsonObject.put("mem", "100");
+ reqJsonObject.put("appName", "test");
+ return (T)reqJsonObject;
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String res = roa.deploySerivce(context,resp);
+ assertNotNull(res);
+ }
+
+ @Test
+ public void destroySerivceTestFail() throws ServiceException {
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ JSONObject reqJsonObject = new JSONObject();
+ reqJsonObject.put("charmPath", "/abc/xyz");
+ reqJsonObject.put("mem", "100");
+ reqJsonObject.put("appName", "test");
+ return (T)reqJsonObject;
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String res = roa.destroySerivce(context,resp);
+ assertNotNull(res);
+ }
+// @Test
+// public void destroySerivce2TestFail() throws ServiceException {
+// new MockUp<StringUtil>(){
+// @Mock
+// public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+// JSONObject reqJsonObject = new JSONObject();
+// reqJsonObject.put("appName", "test");
+// return (T)reqJsonObject;
+// }
+// };
+// HttpServletRequest context = null;
+// HttpServletResponse resp = new MockHttpServletResponse();
+// String res = roa.destroySerivce(context,resp);
+// assertNotNull(res);
+// }
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/TestMockUp.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/TestMockUp.java
new file mode 100644
index 0000000..0fd6300
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/TestMockUp.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016-2017, 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.openo.nfvo.jujuvnfmadapter.service.rest;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.nfvo.jujuvnfmadapter.common.StringUtil;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author quanzhong@huawei.com
+ * @version NFVO 0.5 Nov 2, 2016
+ */
+public class TestMockUp {
+ ConfigRoa roa;
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since NFVO 0.5
+ */
+ @Before
+ public void setUp() throws Exception {
+ roa = new ConfigRoa();
+ }
+
+ @Test
+ public void test() {
+ new MockUp<StringUtil>(){
+ @Mock
+ public boolean isValidUrl(String url) {
+ return true;
+ }
+
+ };
+ Assert.assertTrue(StringUtil.isValidUrl("abc"));
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/VnfResourceRoaTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/VnfResourceRoaTest.java
new file mode 100644
index 0000000..4732233
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/VnfResourceRoaTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.rest;
+
+import static org.junit.Assert.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.jujuvnfmadapter.common.StringUtil;
+import org.openo.nfvo.jujuvnfmadapter.service.process.VnfResourceMgr;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+public class VnfResourceRoaTest {
+
+ VnfResourceRoa roa = new VnfResourceRoa();
+
+ @Before
+ public void setUp(){
+ roa.setVnfResourceMgr(new VnfResourceMgr());
+ }
+
+ @Test
+ public void grantVnfResTest() throws ServiceException{
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest context) {
+ String reqJsonObject = "{}";
+ return (T)JSONObject.fromObject(reqJsonObject);
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String vnfId = "1234";
+ String res = roa.grantVnfRes(context, vnfId);
+ assertNotNull(res);
+ }
+
+} \ No newline at end of file
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/VnfRoaTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/VnfRoaTest.java
new file mode 100644
index 0000000..e88054f
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/VnfRoaTest.java
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2016 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.openo.nfvo.jujuvnfmadapter.service.rest;
+
+import static org.junit.Assert.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Context;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.jujuvnfmadapter.common.StringUtil;
+import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfmInfo;
+import org.openo.nfvo.jujuvnfmadapter.service.process.VnfMgr;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+public class VnfRoaTest {
+
+ VnfRoa roa = new VnfRoa();
+ @Before
+ public void setUp(){
+ roa.setVnfMgr(new VnfMgr());
+ }
+
+ @Test
+ public void addVnfTestNull() throws ServiceException{
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ return null;
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String vnfmId = "1234";
+ String res = roa.addVnf(context, resp, vnfmId);
+ assertNotNull(res);
+ }
+
+ @Test
+ public void addVnfTest() throws ServiceException{
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ String vnfJsonStr = "{}";
+ return (T)JSONObject.fromObject(vnfJsonStr);
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String vnfmId = "1234";
+ String res = roa.addVnf(context, resp, vnfmId);
+ assertNotNull(res);
+ }
+ @Test
+ public void delVnfTestNull() throws ServiceException{
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ return null;
+ }
+ };
+ new MockUp<VnfMgr>(){
+ @Mock
+ private JujuVnfmInfo findByVnfId(String vnfId){
+ JujuVnfmInfo info = new JujuVnfmInfo();
+ info.setVnfmId("1234");
+ return info;
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String vnfmId = "1234";
+ String res = roa.delVnf("vnfmId", resp, "vnfInstanceId",context);
+ assertNotNull(res);
+ }
+ @Test
+ public void delVnf2TestNull() throws ServiceException{
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ return null;
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String vnfmId = "1234";
+ String res = roa.delVnf(null, resp, "vnfInstanceId",context);
+ assertNotNull(res);
+ }
+ @Test
+ public void delVnf3TestNull() throws ServiceException{
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ return null;
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String vnfmId = "1234";
+ String res = roa.delVnf(vnfmId, resp, null,context);
+ assertNotNull(res);
+ }
+ @Test
+ public void getVnf1TestNull() throws ServiceException{
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ return null;
+ }
+ };
+ new MockUp<VnfMgr>(){
+ @Mock
+ private JujuVnfmInfo findByVnfId(String vnfId){
+ JujuVnfmInfo info = new JujuVnfmInfo();
+ info.setVnfmId("1234");
+ return info;
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String vnfmId = "1234";
+ String res = roa.getVnf(vnfmId, resp, "vnfInstanceId",context);
+ assertNotNull(res);
+ }
+ @Test
+ public void getVnf2TestNull() throws ServiceException{
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ return null;
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String vnfmId = "1234";
+ String res = roa.getVnf(null, resp, "vnfInstanceId",context);
+ assertNotNull(res);
+ }
+ @Test
+ public void getVnf3TestNull() throws ServiceException{
+ new MockUp<StringUtil>(){
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ return null;
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String vnfmId = "1234";
+ String res = roa.getVnf(vnfmId, resp, null,context);
+ assertNotNull(res);
+ }
+ @Test
+ public void getJobTestNull() throws ServiceException{
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String res = roa.getJob("jobId", "vnfmId", resp,"responseId");
+ assertNotNull(res);
+ }
+ @Test
+ public void getJobTest2Null() throws ServiceException{
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String res = roa.getJob(null, "vnfmId", resp,"responseId");
+ assertNotNull(res);
+ }
+ @Test
+ public void getJobTest3Null() throws ServiceException{
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String res = roa.getJob("jobId", null, resp,"responseId");
+ assertNotNull(res);
+ }
+
+ @Test
+ public void getJobTestNormal() throws ServiceException{
+ new MockUp<VnfMgr>(){
+ @Mock
+ public JSONObject getJob(String jobId, String vnfmId) {
+ JSONObject obj = new JSONObject();
+ JSONObject dataObj = new JSONObject();
+ dataObj.put("id", "1234");
+ dataObj.put("status", "Success");
+ obj.put("data", dataObj);
+ obj.put("retCode", 1);
+ return obj;
+ }
+
+ };
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String res = roa.getJob("jobId", "vnfmId", resp,"responseId");
+ assertNotNull(res);
+ }
+
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/exceptionmapper/ExceptionMessageTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/exceptionmapper/ExceptionMessageTest.java
new file mode 100644
index 0000000..1b497bf
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/exceptionmapper/ExceptionMessageTest.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.rest.exceptionmapper;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ExceptionMessageTest {
+
+ ExceptionMessage mess;
+
+ @Before
+ public void setUp(){
+ mess = new ExceptionMessage();
+ }
+
+ @Test
+ public void getErrorCodeTest() {
+ String errorCode = "404";
+ String message = "success";
+ int httpCode = 200;
+ mess.setErrorCode(errorCode);
+ mess.setMessage(message);
+ mess.setHttpCode(httpCode);
+ assertEquals(mess.getErrorCode(), errorCode);
+ assertEquals(mess.getHttpCode(),httpCode);
+ assertEquals(mess.getMessage(),message);
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/exceptionmapper/GenericExceptionMapperTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/exceptionmapper/GenericExceptionMapperTest.java
new file mode 100644
index 0000000..9582f9d
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/exceptionmapper/GenericExceptionMapperTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.rest.exceptionmapper;
+
+import static org.junit.Assert.*;
+
+import javax.ws.rs.core.Response;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class GenericExceptionMapperTest {
+
+ GenericExceptionMapper genericExpMess;
+
+
+ @Before
+ public void setUp(){
+ genericExpMess = new GenericExceptionMapper();
+ }
+
+
+ @Test
+ public void toResponseTest() {
+ Response resp = genericExpMess.toResponse(new Exception("Testing"));
+ assertEquals(resp.getStatus(),500);
+
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/exceptionmapper/ServiceExceptionMapperTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/exceptionmapper/ServiceExceptionMapperTest.java
new file mode 100644
index 0000000..14c027a
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/exceptionmapper/ServiceExceptionMapperTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017 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.openo.nfvo.jujuvnfmadapter.service.rest.exceptionmapper;
+
+import static org.junit.Assert.*;
+
+import javax.ws.rs.core.Response;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+
+public class ServiceExceptionMapperTest {
+
+ ServiceExceptionMapper serviceExMapper;
+
+
+ @Before
+ public void setUp(){
+ serviceExMapper = new ServiceExceptionMapper();
+ }
+
+
+ @Test
+ public void toResponseTest() {
+ Response resp = serviceExMapper.toResponse(new ServiceException("Testing"));
+ assertEquals(resp.getStatus(),500);
+
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/fullstack/JujuClientRoaTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/fullstack/JujuClientRoaTest.java
new file mode 100644
index 0000000..959f374
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/fullstack/JujuClientRoaTest.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2016, 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.openo.nfvo.jujuvnfmadapter.service.rest.fullstack;
+
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.openo.nfvo.jujuvnfmadapter.common.EntityUtils;
+import org.apache.log4j.Logger;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openo.nfvo.jujuvnfmadapter.common.EntityUtils.ExeRes;
+import org.openo.nfvo.jujuvnfmadapter.service.adapter.inf.IResourceManager;
+import org.openo.nfvo.jujuvnfmadapter.service.rest.JujuClientRoa;
+import org.python.jline.internal.Log;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author quanzhong@huawei.com
+ * @version NFVO 0.5 Nov 3, 2016
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration({"classpath:test.xml"})
+public class JujuClientRoaTest {
+
+ Logger logger = Logger.getLogger(JujuClientRoaTest.class);
+
+ @Resource
+ private JujuClientRoa jujuClientRoa;
+ @Resource
+ private IResourceManager resourceManager;
+
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since NFVO 0.5
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void test() {
+ Assert.assertNotNull(jujuClientRoa);
+ }
+
+ @Test
+ public void testSetCharmUrl() {
+ HttpServletResponse resp = new MockHttpServletResponse();
+ HttpServletRequest request;
+ String result = null;
+ try {
+ request = TestHelper.buildDefaultRequest("setCharmUrl.json");
+ result = jujuClientRoa.setCharmUrl(request, resp);
+
+ } catch(Exception e) {
+ logger.error("error:",e);
+
+ }
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testGetVnfStatus() {
+
+ //mock method EntityUtils#execute
+ new MockUp<EntityUtils>(){
+ @Mock
+ public ExeRes execute(String dir, List<String> command) {
+ ExeRes res = new ExeRes();
+ res.setCode(ExeRes.SUCCESS);
+ res.setBody(null);
+ return res;
+ }
+ };
+
+ HttpServletResponse resp = new MockHttpServletResponse();
+ MockHttpServletRequest request;
+ String result = null;
+ try {
+ request = TestHelper.buildDefaultRequest(null);
+ String modelName = "mediawiki.yaml";
+ request.setParameter("modelName", modelName);
+ result = jujuClientRoa.getVnfStatus(modelName, request, resp);
+ Log.info(result);
+ } catch(Exception e) {
+ logger.error("error:",e);
+
+ }
+ JSONObject jr = JSONObject.fromObject(result);
+ Assert.assertNotNull(result);
+ Assert.assertEquals(0, jr.getInt("retCode"));
+ }
+
+ // @Test
+ public void testDeploySerivce() {
+ HttpServletResponse resp = new MockHttpServletResponse();
+ HttpServletRequest request;
+ String result = null;
+ try {
+ request = TestHelper.buildDefaultRequest("deployService.json");
+ result = jujuClientRoa.deploySerivce(request, resp);
+ Assert.assertNotNull(result);
+ JSONObject json = JSONObject.fromObject(result);
+ logger.info(json);
+ Assert.assertEquals(json.getInt(EntityUtils.RESULT_CODE_KEY),EntityUtils.ExeRes.SUCCESS);
+
+ } catch(Exception e) {
+ logger.error("error:",e);
+
+ }
+
+ }
+
+// @Test
+ public void testDestroySerivce() {
+ HttpServletResponse resp = new MockHttpServletResponse();
+ HttpServletRequest request;
+ String result = null;
+ try {
+ request = TestHelper.buildDefaultRequest("destroySerivce.json");
+ result = jujuClientRoa.setCharmUrl(request, resp);
+
+ } catch(Exception e) {
+ logger.error("error:",e);
+
+ }
+ Assert.assertNotNull(result);
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/fullstack/TestHelper.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/fullstack/TestHelper.java
new file mode 100644
index 0000000..cf8bc30
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/openo/nfvo/jujuvnfmadapter/service/rest/fullstack/TestHelper.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2016, 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.openo.nfvo.jujuvnfmadapter.service.rest.fullstack;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.openo.nfvo.jujuvnfmadapter.common.FileUtils;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author quanzhong@huawei.com
+ * @version NFVO 0.5 Nov 3, 2016
+ */
+public class TestHelper {
+
+ @SuppressWarnings("deprecation")
+ public static MockHttpServletRequest buildMockRequest(File file) throws FileNotFoundException, IOException {
+
+ String contnet = IOUtils.toString(new FileInputStream(file));
+ byte[] content = contnet.getBytes();
+ MockHttpServletRequest context = new MockHttpServletRequest();
+ context.setContentType("application/json");
+ context.setContent(content);
+ return context;
+ }
+
+ public static MockHttpServletRequest buildMockRequest(String content) throws FileNotFoundException, IOException {
+ MockHttpServletRequest context = new MockHttpServletRequest();
+ context.setContentType("application/json");
+ context.setContent(content.getBytes());
+ return context;
+ }
+
+ public static MockHttpServletRequest buildDefaultRequest(String fileName)
+ throws FileNotFoundException, IOException {
+ MockHttpServletRequest context = new MockHttpServletRequest();
+ context.setContentType("application/json");
+ if(fileName != null) {
+ String file = FileUtils.getClassPath() + File.separator + fileName;
+ InputStream input = new FileInputStream(file);
+ @SuppressWarnings("deprecation")
+ String contnet = IOUtils.toString(input);
+ byte[] content = contnet.getBytes();
+ context.setContent(content);
+ }
+ return context;
+ }
+
+}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/deployService.json b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/deployService.json
new file mode 100644
index 0000000..6dc211e
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/deployService.json
@@ -0,0 +1,4 @@
+{
+"appName":"test.yaml",
+"charmPath":"E:/workspace/openo-common-utils/src/org/openo/common/yaml"
+} \ No newline at end of file
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/destroyService.json b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/destroyService.json
new file mode 100644
index 0000000..7a73a41
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/destroyService.json
@@ -0,0 +1,2 @@
+{
+} \ No newline at end of file
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/example.json b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/example.json
new file mode 100644
index 0000000..5fefaa8
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/example.json
@@ -0,0 +1 @@
+{"InstallTime": "1295768962", "Comments": "Will test without extension.", "Theme": "classic/1.0", "Version": "4.0b10pre", "id": "ec8030f7-c20a-464f-9b0e-13a3a9e97384", "Vendor": "Mozilla", "EMCheckCompatibility": "false", "Throttleable": "1", "Email": "deinspanjer@mozilla.com", "URL": "http://nighthacks.com/roller/jag/entry/the_shit_finally_hits_the", "version": "4.0b10pre", "CrashTime": "1295903735", "ReleaseChannel": "nightly", "submitted_timestamp": "2011-01-24T13:15:48.550858", "buildid": "20110121153230", "timestamp": 1295903748.551002, "Notes": "Renderers: 0x22600,0x22600,0x20400", "StartupTime": "1295768964", "FramePoisonSize": "4096", "FramePoisonBase": "7ffffffff0dea000", "AdapterRendererIDs": "0x22600,0x22600,0x20400", "Add-ons": "compatibility@addons.mozilla.org:0.7,enter.selects@agadak.net:6,{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}:1.3.3,sts-ui@sidstamm.com:0.1,masspasswordreset@johnathan.nightingale:1.04,support@lastpass.com:1.72.0,{972ce4c6-7e08-4474-a285-3208198ce6fd}:4.0b10pre", "BuildID": "20110121153230", "SecondsSinceLastCrash": "810473", "ProductName": "Firefox", "legacy_processing": 0} \ No newline at end of file
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/setCharmUrl.json b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/setCharmUrl.json
new file mode 100644
index 0000000..7a73a41
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/setCharmUrl.json
@@ -0,0 +1,2 @@
+{
+} \ No newline at end of file
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/test.xml b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/test.xml
new file mode 100644
index 0000000..0663c14
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/test.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2016 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.
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
+ xmlns:ctx="http://www.springframework.org/schema/context"
+ xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+ xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context.xsd
+ http://www.springframework.org/schema/osgi-compendium
+ http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
+ http://cxf.apache.org/jaxrs
+ http://cxf.apache.org/schemas/jaxrs.xsd
+ http://cxf.apache.org/transports/http/configuration
+ http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://www.springframework.org/schema/aop
+ http://www.springframework.org/schema/aop/spring-aop-3.0.xsd" >
+
+ <import resource="classpath:spring/JujuVnfmadapter/services.xml"/>
+
+</beans> \ No newline at end of file
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/test.yaml b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/test.yaml
new file mode 100644
index 0000000..00c532d
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/test.yaml
@@ -0,0 +1,10 @@
+name: Test User
+
+address:
+ line1: My Address Line 1
+ line2: Address line 2
+ city: Washington D.C.
+ zip: 20000
+roles:
+ - User
+ - Editor \ No newline at end of file
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/webapp/webtest.xml b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/webapp/webtest.xml
new file mode 100644
index 0000000..dd71a96
--- /dev/null
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/webapp/webtest.xml
@@ -0,0 +1,15 @@
+<!--
+ Copyright 2016 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.
+ -->