diff options
Diffstat (limited to 'huawei/vnfmadapter/VnfmadapterService/service')
16 files changed, 1133 insertions, 384 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/DefaultAsyncCallbackTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/DefaultAsyncCallbackTest.java new file mode 100644 index 00000000..a6d557c0 --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/DefaultAsyncCallbackTest.java @@ -0,0 +1,29 @@ +/* + * 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.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import org.junit.Test; + +public class DefaultAsyncCallbackTest { + + + @Test + public void callback() { + DefaultAsyncCallback defaultAsyncCallback = new DefaultAsyncCallback(); + defaultAsyncCallback.callback(null); + defaultAsyncCallback.handleExcepion(null); + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ExceptionArgsTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ExceptionArgsTest.java new file mode 100644 index 00000000..2f9f718b --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ExceptionArgsTest.java @@ -0,0 +1,41 @@ +/* + * 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.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class ExceptionArgsTest { + + + @Test + public void test() { + String[] args = {"test"}; + ExceptionArgs exceptionArgs = new ExceptionArgs(); + exceptionArgs.setAdviceArgs(args); + exceptionArgs.setDescArgs(args); + exceptionArgs.setDetailArgs(args); + exceptionArgs.setReasonArgs(args); + ExceptionArgs exceptionArgsParamed = new ExceptionArgs(args,args,args,args); + exceptionArgsParamed.getAdviceArgs(); + exceptionArgsParamed.getDescArgs(); + exceptionArgsParamed.getDetailArgs(); + exceptionArgsParamed.getReasonArgs(); + assertNotNull(exceptionArgsParamed); + + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManagerTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManagerTest.java index 1b4e9c30..b79d0414 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManagerTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManagerTest.java @@ -33,7 +33,6 @@ import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulParametes; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VNFRestfulUtil; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VnfmRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect.ConnectMgrVnfm; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.testutils.JsonUtil; @@ -3597,7 +3596,270 @@ public class AdapterResourceManagerTest { paramsMap.put("csarid", "csarid123"); paramsMap.put("vnfmid", "vnfmid1234"); JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap); - assertTrue(res.get("reason").equals("get allcloud failed and IOException.Connection refused: connect")); + assertTrue(res.get("reason").equals("get allcloud failed and IOException.Connection refused (Connection refused)")); } - -} + + @Test + public void uploadVNFPackageTestVnfdPlanInfo() throws IOException { + + new MockUp<VNFRestfulUtil>() { + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + RestfulResponse rr = new RestfulResponse(); + Map<String, String> header = new HashMap<>(); + header.put("Content-Type", "Application/Json"); + header.put("X-FormId", "jhfdl"); + rr.setRespHeaderMap(header); + rr.setStatus(200); + rr.setResponseJson("shdfhj"); + + return rr; + + } + }; + + new MockUp<VnfmUtil>() { + @Mock + public JSONObject getVnfmById(String vnfmId) { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("url", "https://localhost:80"); + jsonObject.put("userName", "ubuntu"); + jsonObject.put("password", "******"); + return jsonObject; + + } + }; + + new MockUp<DownloadCsarManager>() { + @Mock + public String download(String url, String filepath) { + String response = "Success"; + return response; + } + + @Mock + public int unzipCSAR(String fileName, String filePath) { + + return 0; + } + }; + + new MockUp<ConnectMgrVnfm>() { + @Mock + public int connect(JSONObject vnfmObj, String authModel) { + + return 200; + + } + + @Mock + public String getAccessSession() { + + return "conn"; + } + }; + + new MockUp<JSONObject>() { + @Mock + public JSONObject fromObject(Object object) { + JSONObject js = new JSONObject(); + js.put("id", "upload-id-123"); + js.put("Result", "Success"); + js.put("Check", "Ok"); + js.put("url", "http://localhost:80"); + js.put("userName", "User"); + js.put("password", "pass"); + js.put("downloadUri", "http://127.0.0.1:80"); + js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12"); + js.put("keyStorePass", "Changeme_123"); + js.put("keyStoreType", "PKCS12"); + JSONArray ja = new JSONArray(); + String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}"; + ja.add(str); + JSONArray ja1 = new JSONArray(); + String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}"; + ; + ja1.add(str1); + JSONArray ja2 = new JSONArray(); + String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}"; + ja2.add(str2); + JSONObject jsObject = new JSONObject(); + jsObject.put("downloadUrl", "http://localhost:80"); + jsObject.put("csarName", "CSCF"); + JSONObject jsEms = new JSONObject(); + jsEms.put("emsUuid", "123erbhi-hjdek123"); + JSONObject jsCsar = new JSONObject(); + jsCsar.put("csar_file_path", "/home/ubuntu/check/"); + jsCsar.put("csar_file_name", "Csar_File"); + jsCsar.put("emsUuid", jsEms); + JSONObject jsTemp = new JSONObject(); + jsTemp.put("template", jsCsar); + js.put("vCSCF", jsTemp); + js.put("vim_info", ja); + js.put("template", ja2); + js.put("templates", ja1); + js.put("packageInfo", jsObject); + return js; + } + }; + + System.setProperty("catalina.base", + "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release"); + + JSONObject vnfpkg = new JSONObject(); + JSONObject vnfpkg1 = new JSONObject(); + vnfpkg.put("name", "test"); + JSONObject obj = new JSONObject(); + obj.put("csar_file_path", "src/test/resources/Check10.txt"); + obj.put("csar_file_name", "casrFile"); + vnfpkg.put("template", obj); + Map<String, String> paramsMap = new HashMap<>(); + paramsMap.put("csarid", "csarid123"); + paramsMap.put("vnfmid", "vnfmid1234"); + String testString = "test\nstring"; + JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap); + assertTrue(res.get("reason") + .equals("get allcloud failed and IOException.Connection refused (Connection refused)")); + } + + @Test + public void uploadVNFPackageSuccessTest() { + + new MockUp<VNFRestfulUtil>() { + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + RestfulResponse rr = new RestfulResponse(); + Map<String, String> header = new HashMap<>(); + header.put("Content-Type", "Application/Json"); + header.put("X-FormId", "jhfdl"); + rr.setRespHeaderMap(header); + rr.setStatus(200); + rr.setResponseJson("shdfhj"); + + return rr; + + } + }; + + new MockUp<VnfmUtil>() { + @Mock + public JSONObject getVnfmById(String vnfmId) { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("url", "https://localhost:80"); + jsonObject.put("userName", "ubuntu"); + jsonObject.put("password", "******"); + return jsonObject; + + } + }; + + new MockUp<DownloadCsarManager>() { + @Mock + public String download(String url, String filepath) { + String response = "Success"; + return response; + } + + @Mock + public int unzipCSAR(String fileName, String filePath) { + + return 0; + } + }; + + new MockUp<HttpClient>() { + @Mock + public int executeMethod(HttpMethod method) { + return 200; + } + }; + + new MockUp<HttpMethodBase>() { + + @Mock + public int getStatusCode() { + + return 200; + } + + }; + + new MockUp<ConnectMgrVnfm>() { + @Mock + public int connect(JSONObject vnfmObj, String authModel) { + + return 200; + + } + + @Mock + public String getAccessSession() { + + return "conn"; + } + }; + + new MockUp<JSONObject>() { + @Mock + public JSONObject fromObject(Object object) { + JSONObject js = new JSONObject(); + js.put("id", "upload-id-123"); + js.put("Result", "Success"); + js.put("Check", "Ok"); + js.put("url", "http://localhost:80"); + js.put("userName", "User"); + js.put("password", "pass"); + js.put("downloadUri", "http://127.0.0.1:80"); + js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12"); + js.put("keyStorePass", "Changeme_123"); + js.put("keyStoreType", "PKCS12"); + JSONArray ja = new JSONArray(); + String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}"; + ja.add(str); + JSONArray ja1 = new JSONArray(); + String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}"; + ; + ja1.add(str1); + JSONArray ja2 = new JSONArray(); + String str2 = "{\"template_name\": \"VNFD_vUGW\",\"topology_template\":[{\"plan_name\": \"Normal_E9K\",\"plan_id\": \"Normal_E9K\"}]}"; + ja2.add(str2); + JSONObject verTmpObj = ja2.getJSONObject(0); + JSONObject jsObject = new JSONObject(); + jsObject.put("downloadUrl", "http://localhost:80"); + jsObject.put("csarName", "CSCF"); + JSONObject jsEms = new JSONObject(); + jsEms.put("emsUuid", "123erbhi-hjdek123"); + JSONObject jsCsar = new JSONObject(); + jsCsar.put("csar_file_path", "/home/ubuntu/check/"); + jsCsar.put("csar_file_name", "Csar_File"); + jsCsar.put("emsUuid", jsEms); + JSONObject jsTemp = new JSONObject(); + jsTemp.put("template", jsCsar); + js.put("vCSCF", jsTemp); + js.put("vim_info", ja); + js.put("template", verTmpObj); + js.put("templates", ja1); + js.put("packageInfo", jsObject); + return js; + } + }; + + System.setProperty("catalina.base", + "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release"); + + JSONObject vnfpkg = new JSONObject(); + JSONObject vnfpkg1 = new JSONObject(); + vnfpkg.put("name", "test"); + JSONObject obj = new JSONObject(); + obj.put("csar_file_path", "src/test/resources/Check10.txt"); + obj.put("csar_file_name", "casrFile"); + vnfpkg.put("template", obj); + Map<String, String> paramsMap = new HashMap<>(); + paramsMap.put("csarid", "csarid123"); + paramsMap.put("vnfmid", "vnfmid1234"); + JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap); + assertEquals(res.get("retCode"), 200); + } +}
\ No newline at end of file diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/TestConstant.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/TestConstant.java index 7780c648..2b40315e 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/TestConstant.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/TestConstant.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Huawei Technologies Co., Ltd. + * Copyright 2020 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. @@ -17,25 +17,141 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant; import junit.framework.Assert; import org.junit.Test; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.ParamConstants; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.UrlConstant; import static org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant.AUTHLIST; import java.util.List; -/** - * Created by QuanZhong on 2017/3/17. - */ public class TestConstant { @Test public void testCreate(){ List<String> authlist = AUTHLIST; authlist.contains("abc"); - String url = UrlConstant.PORT_COMMON; - authlist.contains(url); - String abc = ParamConstants.CONNECTMGR_CONNECT; - authlist.contains(abc); + String post = Constant.POST; + authlist.contains(post); + String put = Constant.PUT; + authlist.contains(put); + String delete = Constant.DELETE; + authlist.contains(delete); + String get = Constant.GET; + authlist.contains(get); + String asyncpost = Constant.ASYNCPOST; + authlist.contains(asyncpost); + String asyncget = Constant.ASYNCGET; + authlist.contains(asyncget); + String asyncput = Constant.ASYNCPUT; + authlist.contains(asyncput); + String asyncdelete = Constant.ASYNCDELETE; + authlist.contains(asyncdelete); + String https = Constant.HTTPS; + authlist.contains(https); + String encodeing = Constant.ENCODEING; + authlist.contains(encodeing); + String cookie = Constant.COOKIE; + authlist.contains(cookie); + String accesssession = Constant.ACCESSSESSION; + authlist.contains(accesssession); + String contentType = Constant.CONTENT_TYPE; + authlist.contains(contentType); + String application = Constant.APPLICATION; + authlist.contains(application); + String headerSubjectToken = Constant.HEADER_SUBJECT_TOKEN; + authlist.contains(headerSubjectToken); + String headerAuthToken = Constant.HEADER_AUTH_TOKEN; + authlist.contains(headerAuthToken); + String xAuthToken = Constant.X_AUTH_TOKEN; + authlist.contains(xAuthToken); + String downloadcsarSuccess = Constant.DOWNLOADCSAR_SUCCESS; + authlist.contains(downloadcsarSuccess); + int unzipSuccess = Constant.UNZIP_SUCCESS; + authlist.contains(unzipSuccess); + int unzipFail = Constant.UNZIP_FAIL; + authlist.contains(unzipFail); + String downloadcsarFail = Constant.DOWNLOADCSAR_FAIL; + authlist.contains(downloadcsarFail); + int httpOk = Constant.HTTP_OK; + authlist.contains(httpOk); + int httpCreated = Constant.HTTP_CREATED; + authlist.contains(httpCreated); + int httpAccepted = Constant.HTTP_ACCEPTED; + authlist.contains(httpAccepted); + int httpNocontent = Constant.HTTP_NOCONTENT; + authlist.contains(httpNocontent); + int httpBadRequest = Constant.HTTP_BAD_REQUEST; + authlist.contains(httpBadRequest); + int httpUnauthorized = Constant.HTTP_UNAUTHORIZED; + authlist.contains(httpUnauthorized); + int httpNotfound = Constant.HTTP_NOTFOUND; + authlist.contains(httpNotfound); + int httpNotAcceptable = Constant.HTTP_NOT_ACCEPTABLE; + authlist.contains(httpNotAcceptable); + int httpConflict = Constant.HTTP_CONFLICT; + authlist.contains(httpConflict); + int httpInvalidParameters = Constant.HTTP_INVALID_PARAMETERS; + authlist.contains(httpInvalidParameters); + int httpInnererror = Constant.HTTP_INNERERROR; + authlist.contains(httpInnererror); + int internalException = Constant.INTERNAL_EXCEPTION; + authlist.contains(internalException); + int repeatRegTime = Constant.REPEAT_REG_TIME; + authlist.contains(repeatRegTime); + int minPwdLength = Constant.MIN_PWD_LENGTH; + authlist.contains(minPwdLength); + int maxPwdLength = Constant.MAX_PWD_LENGTH; + authlist.contains(maxPwdLength); + int minUrlLength = Constant.MIN_URL_LENGTH; + authlist.contains(minUrlLength); + int maxVnfmNameLength = Constant.MAX_VNFM_NAME_LENGTH; + authlist.contains(maxVnfmNameLength); + int minVnfmNameLength = Constant.MIN_VNFM_NAME_LENGTH; + authlist.contains(maxVnfmNameLength); + int maxUrlLength = Constant.MAX_URL_LENGTH; + authlist.contains(maxUrlLength); + int restSuccess = Constant.REST_SUCCESS; + authlist.contains(restSuccess); + int defaultCollectionSize = Constant.DEFAULT_COLLECTION_SIZE; + authlist.contains(defaultCollectionSize); + int restFail = Constant.REST_FAIL; + authlist.contains(restFail); + String roarand = Constant.ROARAND; + authlist.contains(roarand); + String anonymous = Constant.ANONYMOUS; + authlist.contains(anonymous); + String certificate = Constant.CERTIFICATE; + authlist.contains(certificate); + String retcode = Constant.RETCODE; + authlist.contains(retcode); + String reason = Constant.REASON; + authlist.contains(reason); + String status = Constant.STATUS; + authlist.contains(status); + String vnfpkginfo = Constant.VNFPKGINFO; + authlist.contains(vnfpkginfo); + int errorStatusCode = Constant.ERROR_STATUS_CODE; + authlist.contains(errorStatusCode); + String colon = Constant.COLON; + authlist.contains(colon); + String errormsg = Constant.ERRORMSG; + authlist.contains(errormsg); + String vimid = Constant.VIMID; + authlist.contains(vimid); + String vnfmid = Constant.VNFMID; + authlist.contains(vnfmid); + String action = Constant.ACTION; + authlist.contains(action); + String vnfdid = Constant.VNFDID; + authlist.contains(vnfdid); + String jobid = Constant.JOBID; + authlist.contains(jobid); + String fileSeparator = Constant.FILE_SEPARATOR; + authlist.contains(fileSeparator); + String password = Constant.PASSWORD; + authlist.contains(password); + String username = Constant.USERNAME; + authlist.contains(username); + String localHost = Constant.LOCAL_HOST; + authlist.contains(localHost); + Assert.assertTrue(true); } } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/TestParamConstants.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/TestParamConstants.java new file mode 100644 index 00000000..f312cdbe --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/TestParamConstants.java @@ -0,0 +1,126 @@ +/* + * Copyright 2020 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant; + +import junit.framework.Assert; +import org.junit.Test; + +import java.util.List; + +import static org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant.AUTHLIST; + +public class TestParamConstants { + @Test + public void testCreate(){ + List<String> authlist = AUTHLIST; + authlist.contains("abc"); + String abc = ParamConstants.CONNECTMGR_CONNECT; + authlist.contains(abc); + String getTokensV2 = ParamConstants.GET_TOKENS_V2; + authlist.contains(getTokensV2); + String getTokensV3 = ParamConstants.GET_TOKENS_V3; + authlist.contains(getTokensV3); + String getTokenSucResp = ParamConstants.GET_TOKEN_SUC_RESP; + authlist.contains(getTokenSucResp); + String getTokenFailResp = ParamConstants.GET_TOKEN_FAIL_RESP; + authlist.contains(getTokenFailResp); + String rest3rdConnection = ParamConstants.REST_3RD_CONNECTION; + authlist.contains(rest3rdConnection); + String rest3rdDisconnect = ParamConstants.REST_3RD_DISCONNECT; + authlist.contains(rest3rdDisconnect); + String rest3rdHandshake= ParamConstants.REST_3RD_HANDSHAKE; + authlist.contains(rest3rdHandshake); + String csmAuthConnectSouth= ParamConstants.CSM_AUTH_CONNECT_SOUTH; + authlist.contains(csmAuthConnectSouth); + String csmAuthConnectSouthDisconnect = ParamConstants.CSM_AUTH_CONNECT_SOUTH_DISCONNECT; + authlist.contains(csmAuthConnectSouthDisconnect); + String csmAuthConnect = ParamConstants.CSM_AUTH_CONNECT; + authlist.contains(csmAuthConnect); + String csmAuthDisconnect = ParamConstants.CSM_AUTH_DISCONNECT; + authlist.contains(csmAuthDisconnect); + String csmAuthHandshake = ParamConstants.CSM_AUTH_HANDSHAKE; + authlist.contains(csmAuthHandshake); + String vnfmmed = ParamConstants.VNFMMED; + authlist.contains(vnfmmed); + String connectmgrConnect = ParamConstants.CONNECTMGR_CONNECT; + authlist.contains(connectmgrConnect); + String connectmgrDisconnect = ParamConstants.CONNECTMGR_DISCONNECT; + authlist.contains(connectmgrDisconnect); + String connectmgrHandshake = ParamConstants.CONNECTMGR_HANDSHAKE; + authlist.contains(connectmgrHandshake); + String createVnfPerf = ParamConstants.CREATE_VNF_PERF; + authlist.contains(createVnfPerf); + String vnfmgrInstance = ParamConstants.VNFMGR_INSTANCE; + authlist.contains(vnfmgrInstance); + String vnfdFlavor = ParamConstants.VNFD_FLAVOR; + authlist.contains(vnfdFlavor); + String updateResource = ParamConstants.UPDATE_RESOURCE; + authlist.contains(updateResource); + String vnfQuery = ParamConstants.VNF_QUERY; + authlist.contains(vnfQuery); + String vmsQuery = ParamConstants.VMS_QUERY; + authlist.contains(vmsQuery); + String vnfmgrVnfkpi = ParamConstants.VNFMGR_VNFKPI; + authlist.contains(vnfmgrVnfkpi); + String resVnf = ParamConstants.RES_VNF; + authlist.contains(resVnf); + String notifyVnfPerf = ParamConstants.NOTIFY_VNF_PERF; + authlist.contains(notifyVnfPerf); + String paramModule = ParamConstants.PARAM_MODULE; + authlist.contains(paramModule); + String getAllSos = ParamConstants.GET_ALL_SOS; + authlist.contains(getAllSos); + String operationLogPath = ParamConstants.OPERATION_LOG_PATH; + authlist.contains(operationLogPath); + String systemLogPath = ParamConstants.SYSTEM_LOG_PATH; + authlist.contains(systemLogPath); + String securityLogPath = ParamConstants.SECURITY_LOG_PATH; + authlist.contains(securityLogPath); + String getVnfmVnf = ParamConstants.GET_VNFM_VNF; + authlist.contains(getVnfmVnf); + String getResNet = ParamConstants.GET_RES_NET; + authlist.contains(getResNet); + String getJobStatus = ParamConstants.GET_JOB_STATUS; + authlist.contains(getJobStatus); + String vnfInstance = ParamConstants.VNF_INSTANCE; + authlist.contains(vnfInstance); + String vnfInstanceDel = ParamConstants.VNF_INSTANCE_DEL; + authlist.contains(vnfInstanceDel); + String vnfInstanceGetU2000 = ParamConstants.VNF_INSTANCE_GET_U2000; + authlist.contains(vnfInstanceGetU2000); + String vnfInstanceGet = ParamConstants.VNF_INSTANCE_GET; + authlist.contains(vnfInstanceGet); + String vnfConfigurationGet = ParamConstants.VNF_CONFIGURATION_GET; + authlist.contains(vnfConfigurationGet); + String vnfScale = ParamConstants.VNF_SCALE; + authlist.contains(vnfScale); + String vnfGetVminfo = ParamConstants.VNF_GET_VMINFO; + authlist.contains(vnfGetVminfo); + String msbRegisterUrl = ParamConstants.MSB_REGISTER_URL; + authlist.contains(msbRegisterUrl); + String msbUnregisterUrl = ParamConstants.MSB_UNREGISTER_URL; + authlist.contains(msbUnregisterUrl); + String esrGetVnfmUrl = ParamConstants.ESR_GET_VNFM_URL; + authlist.contains(esrGetVnfmUrl); + String esrGetVnfmsUrl = ParamConstants.ESR_GET_VNFMS_URL; + authlist.contains(esrGetVnfmsUrl); + String grantResUrl = ParamConstants.GRANT_RES_URL; + authlist.contains(grantResUrl); + String healVnf = ParamConstants.HEAL_VNF; + authlist.contains(healVnf); + Assert.assertTrue(true); + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/TestUrlConstant.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/TestUrlConstant.java new file mode 100644 index 00000000..604e2f1b --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/TestUrlConstant.java @@ -0,0 +1,59 @@ +/* + * Copyright 2020 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant; + +import junit.framework.Assert; +import org.junit.Test; + +import java.util.List; + +import static org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant.AUTHLIST; + + +public class TestUrlConstant { + @Test + public void testCreate(){ + List<String> authlist = AUTHLIST; + authlist.contains("abc"); + String url = UrlConstant.PORT_COMMON; + authlist.contains(url); + String abc = ParamConstants.CONNECTMGR_CONNECT; + authlist.contains(abc); + String url_job_status_get = UrlConstant.URL_JOBSTATUS_GET; + authlist.contains(url_job_status_get); + String url_rest_msb_register = UrlConstant.REST_MSB_REGISTER; + authlist.contains(url_rest_msb_register); + String url_rest_drivermgr_register = UrlConstant.REST_DRIVERMGR_REGISTER; + authlist.contains(url_rest_drivermgr_register); + String url_rest_csarinfo_get = UrlConstant.REST_CSARINFO_GET; + authlist.contains(url_rest_csarinfo_get); + String url_rest_vnfminfo_get = UrlConstant.REST_VNFMINFO_GET; + authlist.contains(url_rest_vnfminfo_get); + String url_allcloud_get = UrlConstant.URL_ALLCLOUD_GET; + authlist.contains(url_allcloud_get); + String url_allcloud_new_get = UrlConstant.URL_ALLCLOUD_NEW_GET; + authlist.contains(url_allcloud_new_get); + String url_vnfpackage_post = UrlConstant.URL_VNFPACKAGE_POST; + authlist.contains(url_vnfpackage_post); + String url_vnfdinfo_get = UrlConstant.URL_VNFDINFO_GET; + authlist.contains(url_vnfdinfo_get); + String url_vnfdplaninfo_get = UrlConstant.URL_VNFDPLANINFO_GET; + authlist.contains(url_vnfdplaninfo_get); + String portUploadvnfpkg = UrlConstant.PORT_UPLOADVNFPKG; + authlist.contains(portUploadvnfpkg); + Assert.assertTrue(true); + } +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/api/ConnectInfoTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/api/ConnectInfoTest.java index 93e9e39f..85fd92c5 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/api/ConnectInfoTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/api/ConnectInfoTest.java @@ -16,10 +16,10 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.api; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; import org.junit.Test; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.api.ConnectInfo; +import junit.framework.Assert; public class ConnectInfoTest { @@ -85,6 +85,34 @@ public class ConnectInfoTest { ConnectInfo info2 = new ConnectInfo("localhost","user","password","auth"); assertTrue(!info1.equals(info2)); } - - + @Test + public void setUrlTest() throws NoSuchFieldException, IllegalAccessException { + ConnectInfo connectInfo = new ConnectInfo("localhost"); + connectInfo.setUrl("localhost"); + assertTrue(connectInfo.getUrl().equals("localhost")); + } + @Test + public void setUserNameTest() throws NoSuchFieldException, IllegalAccessException { + ConnectInfo connectInfo = new ConnectInfo("localhost"); + connectInfo.setUserName("user"); + assertTrue(connectInfo.getUserName().equals("user")); + } + @Test + public void setUserPwdTest() throws NoSuchFieldException, IllegalAccessException { + ConnectInfo connectInfo = new ConnectInfo("localhost"); + connectInfo.setUserPwd("password"); + assertTrue(connectInfo.getUserPwd().equals("password")); + } + @Test + public void setAuthenticateModeTest() throws NoSuchFieldException, IllegalAccessException { + ConnectInfo connectInfo = new ConnectInfo("localhost"); + connectInfo.setAuthenticateMode("auth"); + assertTrue(connectInfo.getAuthenticateMode().equals("auth")); + } + @Test + public void testToString() { + ConnectInfo connectInfo = new ConnectInfo("localhost","user","password","auth"); + String expected = connectInfo.toString(); + Assert.assertEquals(expected, connectInfo.toString()); + } } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/HttpRequestsTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/HttpRequestsTest.java index 185f2b28..3e9972af 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/HttpRequestsTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/HttpRequestsTest.java @@ -16,7 +16,8 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; @@ -24,76 +25,112 @@ import java.util.List; import org.apache.commons.httpclient.Header; import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmException; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect.HttpRequests; public class HttpRequestsTest { - String authenticateMode = "test"; - HttpRequests.Builder builder = new HttpRequests.Builder(authenticateMode); - - @Test - public void addHeaderTest(){ - builder.addHeader("id", "1234"); - assertTrue(true); - } - @Test - public void addHeadersTest(){ - Header header = new Header(); - builder.addHeaders(header, header); - assertNotNull(builder); - } - @Test - public void addHeadersListTest(){ - List<Header> list = new ArrayList<>(); - Header header = new Header(); - list.add(header); - builder.addHeaders(list); - assertNotNull(builder); - } - - @Test(expected = VnfmException.class) - public void setUrlTestException() throws VnfmException{ - String url=null; - String path=null; - builder.setUrl(url, path); - } - @Test(expected = VnfmException.class) - public void setUrlTestException2() throws VnfmException{ - String url=""; - String path=null; - builder.setUrl(url, path); - } - - @Test(expected = VnfmException.class) - public void setUrlTestNormal() throws VnfmException{ - String url="/test/123"; - String path="http://localhost:8080"; - builder.setUrl(url, path); - } - - @Test(expected = VnfmException.class) - public void setUrl2TestException() throws VnfmException{ - String url=null; - String path=null; - builder.setUrl(url, path,101); - } - @Test(expected = VnfmException.class) - public void setUrl2TestException2() throws VnfmException{ - String url=""; - String path=null; - builder.setUrl(url, path,101); - } - - @Test(expected = VnfmException.class) - public void setUrl2TestNormal() throws VnfmException{ - String url="/test/123"; - String path="http://localhost:8080"; - builder.setUrl(url, path,101); - } - @Test(expected = Exception.class) - public void requestTestException(){ - String res = builder.request(); - assertNotNull(res); - } + String authenticateMode = "test"; + HttpRequests.Builder builder = new HttpRequests.Builder(authenticateMode); + + @Test + public void addHeaderTest() { + builder.addHeader("id", "1234"); + assertTrue(true); + } + + @Test + public void addHeadersTest() { + Header header = new Header(); + builder.addHeaders(header, header); + assertNotNull(builder); + } + + @Test + public void addHeadersListTest() { + List<Header> list = new ArrayList<>(); + Header header = new Header(); + list.add(header); + builder.addHeaders(list); + assertNotNull(builder); + } + + @Test(expected = VnfmException.class) + public void setUrlTestException() throws VnfmException { + String url = null; + String path = null; + builder.setUrl(url, path); + } + + @Test(expected = VnfmException.class) + public void setUrlTestException2() throws VnfmException { + String url = ""; + String path = null; + builder.setUrl(url, path); + } + + @Test(expected = VnfmException.class) + public void setUrlTestNormal() throws VnfmException { + String url = "/test/123"; + String path = "http://localhost:8080"; + builder.setUrl(url, path); + } + + @Test(expected = VnfmException.class) + public void setUrl2TestException() throws VnfmException { + String url = null; + String path = null; + builder.setUrl(url, path, 101); + } + + @Test(expected = VnfmException.class) + public void setUrl2TestException2() throws VnfmException { + String url = ""; + String path = null; + builder.setUrl(url, path, 101); + } + + @Test(expected = VnfmException.class) + public void setUrl2TestNormal() throws VnfmException { + String url = "/test/123"; + String path = "http://localhost:8080"; + builder.setUrl(url, path, 101); + } + + @Test(expected = Exception.class) + public void requestTestException() { + String res = builder.request(); + assertNotNull(res); + } + + @Test + public void postTest() throws VnfmException { + assertNotNull(builder.post()); + } + + @Test + public void putTest() throws VnfmException { + assertNotNull(builder.put()); + } + + @Test + public void getTest() throws VnfmException { + assertNotNull(builder.get()); + } + + @Test + public void deleteTest() throws VnfmException { + assertNotNull(builder.delete()); + } + + @Test + public void setParamsTest() throws VnfmException { + String json = "test"; + assertNotNull(builder.setParams(json)); + } + + @Test + public void setEncodingTest() throws VnfmException { + String json = "test"; + assertNotNull(builder.setEncoding(json)); + } } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/SslAnonymousSocketTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/SslAnonymousSocketTest.java index 1e382a4e..783dc5c4 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/SslAnonymousSocketTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/SslAnonymousSocketTest.java @@ -22,11 +22,18 @@ import java.net.Socket; import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.params.HttpConnectionParams; +import org.junit.Before; import org.junit.Test; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect.SslAnonymousSocket; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmException; public class SslAnonymousSocketTest { + + @Before + public void init() throws VnfmException { + SslAnonymousSocket sslsocket = new SslAnonymousSocket(); + sslsocket.init(); + } @Test(expected = IOException.class) public void createSocketTestException() throws IOException, ConnectTimeoutException { String host= "localhost"; @@ -48,5 +55,5 @@ public class SslAnonymousSocketTest { SslAnonymousSocket sslsocket = new SslAnonymousSocket(); Socket socket = sslsocket.createSocket(host, port, localAddress, localPort, params); } - + } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/SslCertificateSocketTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/SslCertificateSocketTest.java index 0e31faf8..f0246d6f 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/SslCertificateSocketTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/SslCertificateSocketTest.java @@ -58,4 +58,17 @@ public class SslCertificateSocketTest { e.printStackTrace(); } } + + + @Test + public void createSocketTest6() { + SslCertificateSocket socket = new SslCertificateSocket(); + try { + HttpConnectionParams params = new HttpConnectionParams(); + params.setConnectionTimeout(3000); + socket.createSocket("http://127.0.0.1", 1234); + } catch(IOException e) { + e.printStackTrace(); + } + } } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/SslProtocolSocketFactoryTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/SslProtocolSocketFactoryTest.java index 27236ca7..bd701206 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/SslProtocolSocketFactoryTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/SslProtocolSocketFactoryTest.java @@ -16,12 +16,12 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmException; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect.SslProtocolSocketFactory; public class SslProtocolSocketFactoryTest { @@ -45,4 +45,16 @@ public class SslProtocolSocketFactoryTest { SslProtocolSocketFactory.getInstance().refresh("Anonymous"); assertTrue(true); } + @Test + public void getAnonymousTest() throws VnfmException{ + String authenticateMode="Anonymous"; + SslProtocolSocketFactory.getInstance().get(authenticateMode); + assertTrue(true); + } + @Test + public void getCertificateTest() throws VnfmException{ + String authenticateMode="Certificate"; + SslProtocolSocketFactory.getInstance().get(authenticateMode); + assertTrue(true); + } } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/entity/VnfmTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/entity/VnfmTest.java index 7da877ac..2e0bc886 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/entity/VnfmTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/entity/VnfmTest.java @@ -55,6 +55,22 @@ public class VnfmTest { } @Test + public void testProps(){ + Vnfm tempVnfm = new Vnfm(); + tempVnfm.getId(); + tempVnfm.setId("123"); + tempVnfm.getVersion(); + tempVnfm.setVersion("1234"); + tempVnfm.getVnfdId(); + tempVnfm.setVnfdId("123"); + tempVnfm.getVnfPackageId(); + tempVnfm.setVnfPackageId("123"); + tempVnfm.toString(); + assertTrue(true); + } + + + @Test public void equalsTest2(){ assertTrue(vnfm.equals(vnfm)); } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgrTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgrTest.java index c593ca58..af97c25a 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgrTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgrTest.java @@ -45,14 +45,14 @@ public class AuthMgrTest { @Test public void testAuthToken() { - new MockUp<VnfmRestfulUtil>() { - - @Mock - public RestfulResponse getRestResByDefault(String auth, String method, JSONObject authParams) { - RestfulResponse response = null; - return response; - } - }; +// new MockUp<VnfmRestfulUtil>() { +// +// @Mock +// public RestfulResponse getRestResByDefault(String auth, String method, JSONObject authParams) { +// RestfulResponse response = null; +// return response; +// } +// }; AuthMgr authMgr = new AuthMgr(); String data = "{\"auth\":{\"identity\":{\"password\":{\"user\":{\"name\":\"om_team\",\"password\":\"123\"}}}}}"; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/RegisterMgrTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/RegisterMgrTest.java index 4fdd7057..5c965ccc 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/RegisterMgrTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/RegisterMgrTest.java @@ -36,30 +36,33 @@ public class RegisterMgrTest { @Test public void testRegister() { - new MockUp<VnfmRestfulUtil>() { - - @Mock - public RestfulResponse getRemoteResponse(String url, String methodType, String params) { - RestfulResponse rsp = new RestfulResponse(); - rsp.setStatus(200); - return rsp; - } - }; +// new MockUp<VnfmRestfulUtil>() { +// +// @Mock +// public RestfulResponse getRemoteResponse(String url, String methodType, String params) { +// RestfulResponse rsp = new RestfulResponse(); +// rsp.setStatus(200); +// return rsp; +// } +// }; RegisterMgr register = new RegisterMgr(); register.register(); + + + } @Test public void testUnRegister() { - new MockUp<VnfmRestfulUtil>() { - - @Mock - public RestfulResponse getRemoteResponse(String url, String methodType, String params) { - RestfulResponse rsp = new RestfulResponse(); - rsp.setStatus(200); - return rsp; - } - }; +// new MockUp<VnfmRestfulUtil>() { +// +// @Mock +// public RestfulResponse getRemoteResponse(String url, String methodType, String params) { +// RestfulResponse rsp = new RestfulResponse(); +// rsp.setStatus(200); +// return rsp; +// } +// }; RegisterMgr register = new RegisterMgr(); register.unRegister(); } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgrTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgrTest.java index 7e34e79e..bbf23670 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgrTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgrTest.java @@ -79,13 +79,13 @@ public class VnfMgrTest { @Test public void testAddVnfByVnfmObjcetIsNullObject() { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - return new JSONObject(true); - } - }; +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// return new JSONObject(true); +// } +// }; String data = "{\"soId\": \"soId\",\"vapp_info\":{\"vnfm_id\":\"vnfm_id\",\"soId\": \"soId\",\"do_id\": \"do_id\"}}"; JSONObject subJsonObject = JSONObject.fromObject(data); @@ -99,15 +99,15 @@ public class VnfMgrTest { @Test public void testAddVnfByVnfmObjcetTypeEmpty() { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - JSONObject obj = new JSONObject(); - obj.put("type", ""); - return obj; - } - }; +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// JSONObject obj = new JSONObject(); +// obj.put("type", ""); +// return obj; +// } +// }; String data = "{\"soId\": \"soId\",\"vapp_info\":{\"vnfm_id\":\"vnfm_id\",\"soId\": \"soId\",\"do_id\": \"do_id\"}}"; JSONObject subJsonObject = JSONObject.fromObject(data); @@ -121,40 +121,40 @@ public class VnfMgrTest { @Test public void testAddVnf() { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - JSONObject obj = new JSONObject(); - obj.put("type", "hw"); - obj.put("vnfmId", "123"); - obj.put("userName", "admin"); - obj.put("password", "admin"); - obj.put("url", "https://10.2.31.2:30001"); - return obj; - } - }; - - new MockUp<VnfMgrVnfm>() { - - @Mock - public JSONObject createVnf(JSONObject subJsonObject, JSONObject vnfmObjcet) { - JSONObject restJson = new JSONObject(); - restJson.put("retCode", Constant.REST_SUCCESS); - return restJson; - } - }; - - new MockUp<AdapterResourceManager>() { - - @Mock - public JSONObject uploadVNFPackage(JSONObject subJsonObject, Map<String, String> conMap) { - JSONObject restJson = new JSONObject(); - restJson.put("retCode", Constant.REST_SUCCESS); - restJson.put("vnfdId", "123"); - return restJson; - } - }; +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// JSONObject obj = new JSONObject(); +// obj.put("type", "hw"); +// obj.put("vnfmId", "123"); +// obj.put("userName", "admin"); +// obj.put("password", "admin"); +// obj.put("url", "https://10.2.31.2:30001"); +// return obj; +// } +// }; + +// new MockUp<VnfMgrVnfm>() { +// +// @Mock +// public JSONObject createVnf(JSONObject subJsonObject, JSONObject vnfmObjcet) { +// JSONObject restJson = new JSONObject(); +// restJson.put("retCode", Constant.REST_SUCCESS); +// return restJson; +// } +// }; +// +// new MockUp<AdapterResourceManager>() { +// +// @Mock +// public JSONObject uploadVNFPackage(JSONObject subJsonObject, Map<String, String> conMap) { +// JSONObject restJson = new JSONObject(); +// restJson.put("retCode", Constant.REST_SUCCESS); +// restJson.put("vnfdId", "123"); +// return restJson; +// } +// }; String data = "{\"vnfPackageId\": \"vnfPackageId\",\"vnfId\": \"vnfId\",\"additionalParam\":{\"parameters\":{\"input\":\"input\"}}}"; @@ -169,28 +169,28 @@ public class VnfMgrTest { @Test public void testDeleteVnf() { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - JSONObject obj = new JSONObject(); - obj.put("type", "hw"); - obj.put("vnfmId", "123"); - obj.put("userName", "admin"); - obj.put("password", "admin"); - obj.put("url", "https://10.2.31.2:30001"); - return obj; - } - }; - new MockUp<VnfMgrVnfm>() { - - @Mock - public JSONObject removeVnf(JSONObject vnfmObject, String vnfId, JSONObject vnfObject) { - JSONObject obj = new JSONObject(); - obj.put("retCode", Constant.REST_SUCCESS); - return obj; - } - }; +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// JSONObject obj = new JSONObject(); +// obj.put("type", "hw"); +// obj.put("vnfmId", "123"); +// obj.put("userName", "admin"); +// obj.put("password", "admin"); +// obj.put("url", "https://10.2.31.2:30001"); +// return obj; +// } +// }; +// new MockUp<VnfMgrVnfm>() { +// +// @Mock +// public JSONObject removeVnf(JSONObject vnfmObject, String vnfId, JSONObject vnfObject) { +// JSONObject obj = new JSONObject(); +// obj.put("retCode", Constant.REST_SUCCESS); +// return obj; +// } +// }; VnfMgr vnfMgr = new VnfMgr(); JSONObject vnfObject = new JSONObject(); JSONObject result = vnfMgr.deleteVnf("vnfId", "vnfmId", vnfObject); @@ -202,14 +202,14 @@ public class VnfMgrTest { @Test public void testDeleteVnfByVnfmObjcetIsNullObject() { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - JSONObject obj = new JSONObject(true); - return obj; - } - }; +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// JSONObject obj = new JSONObject(true); +// return obj; +// } +// }; VnfMgr vnfMgr = new VnfMgr(); JSONObject vnfObject = new JSONObject(); JSONObject result = vnfMgr.deleteVnf("vnfId", "vnfmId", vnfObject); @@ -222,13 +222,13 @@ public class VnfMgrTest { @Test public void testDeleteVnfByException() { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - throw new JSONException(); - } - }; +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// throw new JSONException(); +// } +// }; VnfMgr vnfMgr = new VnfMgr(); JSONObject vnfObject = new JSONObject(); JSONObject result = vnfMgr.deleteVnf("vnfId", "vnfmId", vnfObject); @@ -241,53 +241,53 @@ public class VnfMgrTest { @Test public void testGetVnf() throws IOException { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - JSONObject obj = new JSONObject(); - obj.put("type", "hw"); - obj.put("vnfmId", "123"); - obj.put("userName", "admin"); - obj.put("password", "admin"); - obj.put("url", "https://127.0.0.1:30001"); - return obj; - } - }; - - new MockUp<VnfmDaoImpl>() { - - @Mock - public Vnfm getVnfmById(String vnfmId) { - Vnfm obj = new Vnfm(); - obj.setId("123"); - obj.setVersion("v2.0"); - obj.setVnfdId("234"); - obj.setVnfPackageId("123"); - return obj; - } - }; - - new MockUp<ResultRequestUtil>() { - - @Mock - public JSONObject call(JSONObject vnfmObjcet, String path, String methodName, String paramsJson) { - JSONObject resultJson = new JSONObject(); - resultJson.put("retCode", Constant.HTTP_OK); - JSONObject data = new JSONObject(); - - JSONArray result = new JSONArray(); - JSONObject basicInfo = new JSONObject(); - basicInfo.put("id", "NE=345"); - basicInfo.put("vapp_name", "sc"); - basicInfo.put("status", "active"); - result.add(basicInfo); - data.put("basic", result); - resultJson.put("data", data.toString()); - return resultJson; - } - }; - +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// JSONObject obj = new JSONObject(); +// obj.put("type", "hw"); +// obj.put("vnfmId", "123"); +// obj.put("userName", "admin"); +// obj.put("password", "admin"); +// obj.put("url", "https://127.0.0.1:30001"); +// return obj; +// } +// }; +// +// new MockUp<VnfmDaoImpl>() { +// +// @Mock +// public Vnfm getVnfmById(String vnfmId) { +// Vnfm obj = new Vnfm(); +// obj.setId("123"); +// obj.setVersion("v2.0"); +// obj.setVnfdId("234"); +// obj.setVnfPackageId("123"); +// return obj; +// } +// }; +// +// new MockUp<ResultRequestUtil>() { +// +// @Mock +// public JSONObject call(JSONObject vnfmObjcet, String path, String methodName, String paramsJson) { +// JSONObject resultJson = new JSONObject(); +// resultJson.put("retCode", Constant.HTTP_OK); +// JSONObject data = new JSONObject(); +// +// JSONArray result = new JSONArray(); +// JSONObject basicInfo = new JSONObject(); +// basicInfo.put("id", "NE=345"); +// basicInfo.put("vapp_name", "sc"); +// basicInfo.put("status", "active"); +// result.add(basicInfo); +// data.put("basic", result); +// resultJson.put("data", data.toString()); +// return resultJson; +// } +// }; +// JSONObject result = vnfMgr.getVnf("vnfId", "vnfmId"); JSONObject restJson = new JSONObject(); @@ -298,14 +298,14 @@ public class VnfMgrTest { @Test public void testGetVnfFail() throws IOException { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - JSONObject obj = new JSONObject(true); - return obj; - } - }; +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// JSONObject obj = new JSONObject(true); +// return obj; +// } +// }; JSONObject result = vnfMgr.getVnf("vnfId", "vnfmId"); JSONObject restJson = new JSONObject(); @@ -315,13 +315,13 @@ public class VnfMgrTest { @Test public void testGetVnfFail1() throws IOException { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - throw new JSONException(); - } - }; +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// throw new JSONException(); +// } +// }; JSONObject result = vnfMgr.getVnf("vnfId", "vnfmId"); JSONObject restJson = new JSONObject(); @@ -331,13 +331,13 @@ public class VnfMgrTest { @Test public void testSaveVnfInfo() { - new MockUp<VnfmDaoImpl>() { - - @Mock - public int insertVnfm(Vnfm vnfm) throws ServiceException { - return 1; - } - }; +// new MockUp<VnfmDaoImpl>() { +// +// @Mock +// public int insertVnfm(Vnfm vnfm) throws ServiceException { +// return 1; +// } +// }; VnfMgr vnfMgr = new VnfMgr(); VnfmDao dao = new VnfmDaoImpl(); @@ -356,13 +356,13 @@ public class VnfMgrTest { @Test public void testSaveVnfInfoFail() { - new MockUp<VnfmDaoImpl>() { - - @Mock - public int insertVnfm(Vnfm vnfm) throws ServiceException { - return 1; - } - }; +// new MockUp<VnfmDaoImpl>() { +// +// @Mock +// public int insertVnfm(Vnfm vnfm) throws ServiceException { +// return 1; +// } +// }; VnfMgr vnfMgr = new VnfMgr(); VnfmDao dao = new VnfmDaoImpl(); @@ -379,13 +379,13 @@ public class VnfMgrTest { @Test public void testSaveVnfInfoServiceException() { - new MockUp<VnfmDaoImpl>() { - - @Mock - public int insertVnfm(Vnfm vnfm) throws ServiceException { - throw new ServiceException(); - } - }; +// new MockUp<VnfmDaoImpl>() { +// +// @Mock +// public int insertVnfm(Vnfm vnfm) throws ServiceException { +// throw new ServiceException(); +// } +// }; VnfMgr vnfMgr = new VnfMgr(); VnfmDao dao = new VnfmDaoImpl(); @@ -404,25 +404,25 @@ public class VnfMgrTest { @Test public void testGetJob() { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - JSONObject obj = new JSONObject(); - obj.put("test", "success"); - return obj; - } - }; - - new MockUp<VnfMgrVnfm>() { - - @Mock - public JSONObject getJob(JSONObject vnfmObject, String jobId) { - JSONObject res = new JSONObject(); - res.put(Constant.RETCODE, Constant.REST_SUCCESS); - return res; - } - }; +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// JSONObject obj = new JSONObject(); +// obj.put("test", "success"); +// return obj; +// } +// }; +// +// new MockUp<VnfMgrVnfm>() { +// +// @Mock +// public JSONObject getJob(JSONObject vnfmObject, String jobId) { +// JSONObject res = new JSONObject(); +// res.put(Constant.RETCODE, Constant.REST_SUCCESS); +// return res; +// } +// }; VnfMgr vnfMgr = new VnfMgr(); JSONObject result = vnfMgr.getJob("", ""); @@ -433,13 +433,13 @@ public class VnfMgrTest { @Test public void testGetJobFail() { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - return new JSONObject(); - } - }; +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// return new JSONObject(); +// } +// }; VnfMgr vnfMgr = new VnfMgr(); JSONObject result = vnfMgr.getJob("", ""); @@ -450,13 +450,13 @@ public class VnfMgrTest { @Test public void testGetJobFail1() { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - return new JSONObject(true); - } - }; +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// return new JSONObject(true); +// } +// }; VnfMgr vnfMgr = new VnfMgr(); JSONObject result = vnfMgr.getJob("", ""); @@ -467,30 +467,30 @@ public class VnfMgrTest { @Test public void testScaleVnf() { - new MockUp<VnfmUtil>() { - - @Mock - public JSONObject getVnfmById(String vnfmId) { - JSONObject obj = new JSONObject(); - obj.put("type", "hw"); - obj.put("vnfmId", "123"); - obj.put("userName", "admin"); - obj.put("password", "admin"); - obj.put("url", "https://10.2.31.2:30001"); - return obj; - } - }; - - new MockUp<VnfMgrVnfm>() { - - @Mock - public JSONObject scaleVnf(JSONObject vnfObject, JSONObject vnfmObject, String vnfmId, - String vnfInstanceId) { - JSONObject restJson = new JSONObject(); - restJson.put("retCode", Constant.REST_SUCCESS); - return restJson; - } - }; +// new MockUp<VnfmUtil>() { +// +// @Mock +// public JSONObject getVnfmById(String vnfmId) { +// JSONObject obj = new JSONObject(); +// obj.put("type", "hw"); +// obj.put("vnfmId", "123"); +// obj.put("userName", "admin"); +// obj.put("password", "admin"); +// obj.put("url", "https://10.2.31.2:30001"); +// return obj; +// } +// }; + +// new MockUp<VnfMgrVnfm>() { +// +// @Mock +// public JSONObject scaleVnf(JSONObject vnfObject, JSONObject vnfmObject, String vnfmId, +// String vnfInstanceId) { +// JSONObject restJson = new JSONObject(); +// restJson.put("retCode", Constant.REST_SUCCESS); +// return restJson; +// } +// }; String data = "{\"vnfPackageId\": \"vnfPackageId\",\"vnfId\": \"vnfId\",\"additionalParam\":{\"parameters\":{\"input\":\"input\"}}}"; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgrTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgrTest.java index 9d63e2cc..e5c520fb 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgrTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgrTest.java @@ -55,16 +55,16 @@ public class VnfResourceMgrTest { @Test public void testgrantVnfResourceSuccess() { - new MockUp<VnfmRestfulUtil>() { - - @Mock - public RestfulResponse getRemoteResponse(String url, String methodType, String params) { - RestfulResponse rsp = new RestfulResponse(); - rsp.setStatus(200); - rsp.setResponseJson(new JSONObject().toString()); - return rsp; - } - }; +// new MockUp<VnfmRestfulUtil>() { +// +// @Mock +// public RestfulResponse getRemoteResponse(String url, String methodType, String params) { +// RestfulResponse rsp = new RestfulResponse(); +// rsp.setStatus(200); +// rsp.setResponseJson(new JSONObject().toString()); +// return rsp; +// } +// }; JSONObject vnfObj = new JSONObject(); String data = @@ -79,16 +79,16 @@ public class VnfResourceMgrTest { @Test public void testgrantVnfResourceSuccess1() { - new MockUp<VnfmRestfulUtil>() { - - @Mock - public RestfulResponse getRemoteResponse(String url, String methodType, String params) { - RestfulResponse rsp = new RestfulResponse(); - rsp.setStatus(200); - rsp.setResponseJson(new JSONObject().toString()); - return rsp; - } - }; +// new MockUp<VnfmRestfulUtil>() { +// +// @Mock +// public RestfulResponse getRemoteResponse(String url, String methodType, String params) { +// RestfulResponse rsp = new RestfulResponse(); +// rsp.setStatus(200); +// rsp.setResponseJson(new JSONObject().toString()); +// return rsp; +// } +// }; JSONObject vnfObj = new JSONObject(); String data = @@ -103,16 +103,16 @@ public class VnfResourceMgrTest { @Test public void testgrantVnfResourceSuccess2() { - new MockUp<VnfmRestfulUtil>() { - - @Mock - public RestfulResponse getRemoteResponse(String url, String methodType, String params) { - RestfulResponse rsp = new RestfulResponse(); - rsp.setStatus(200); - rsp.setResponseJson(new JSONObject().toString()); - return rsp; - } - }; +// new MockUp<VnfmRestfulUtil>() { +// +// @Mock +// public RestfulResponse getRemoteResponse(String url, String methodType, String params) { +// RestfulResponse rsp = new RestfulResponse(); +// rsp.setStatus(200); +// rsp.setResponseJson(new JSONObject().toString()); +// return rsp; +// } +// }; JSONObject vnfObj = new JSONObject(); String data = @@ -127,16 +127,16 @@ public class VnfResourceMgrTest { @Test public void testgrantVnfResourceSuccess3() { - new MockUp<VnfmRestfulUtil>() { - - @Mock - public RestfulResponse getRemoteResponse(String url, String methodType, String params) { - RestfulResponse rsp = new RestfulResponse(); - rsp.setStatus(200); - rsp.setResponseJson(new JSONObject().toString()); - return rsp; - } - }; +// new MockUp<VnfmRestfulUtil>() { +// +// @Mock +// public RestfulResponse getRemoteResponse(String url, String methodType, String params) { +// RestfulResponse rsp = new RestfulResponse(); +// rsp.setStatus(200); +// rsp.setResponseJson(new JSONObject().toString()); +// return rsp; +// } +// }; JSONObject vnfObj = new JSONObject(); String data = |