diff options
author | SravanKumarGunda <sravan.kumar1@huawei.com> | 2020-07-30 19:34:57 +0530 |
---|---|---|
committer | SravanKumarGunda <sravan.kumar1@huawei.com> | 2020-08-18 16:43:06 +0530 |
commit | e2ce0d5bf9476134ba5427496c9d20089ca856cb (patch) | |
tree | abcabd094f2a92fabe4cee02236e5fde2cdf208e | |
parent | 87abb288ba1e107fb75148effd967420b6c76148 (diff) |
Code Improvements-Vnfsdk-refrepo sonar issue fixes
Signed-off-by: SravanKumarGunda <sravan.kumar1@huawei.com>
Issue-ID: VNFSDK-608
Change-Id: Ifba4c2f804786b40305c562460071ef430164de2
34 files changed, 209 insertions, 183 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java index 5697ddf7..777080f1 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java @@ -57,11 +57,7 @@ public final class FileUtil { */ public static boolean createDirectory(String dir) { File folder = new File(dir); - if (!folder.exists() && !folder.mkdirs()) { - return false; - } else { - return true; - } + return folder.exists() || folder.mkdirs(); } /** @@ -156,7 +152,7 @@ public final class FileUtil { gson.toJson(obj, writer); bResult = true; } catch (Exception e) { //NOSONAR - logger.info("Exception: writeJsonDatatoFile-->" + fileAbsPath, e); + logger.info("Exception: writeJsonDatatoFile-->{} {}" , fileAbsPath, e); } return bResult; } @@ -180,7 +176,7 @@ public final class FileUtil { try(JsonReader jsonReader = new JsonReader(new FileReader(fileAbsPath))) { obj = gson.fromJson(jsonReader, clazz); } catch (Exception e1) { //NOSONAR - logger.info("IOException Exception: writeJsonDatatoFile-->" + fileAbsPath, e1); + logger.info("IOException Exception: writeJsonDatatoFile-->{} {}" , fileAbsPath, e1); } return obj; } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfig.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfig.java index af6f428f..c03fc254 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfig.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfig.java @@ -20,7 +20,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class HttpServerPathConfig { - public static final Logger logger = LoggerFactory.getLogger(FileUtil.class); + public static final Logger logger = LoggerFactory.getLogger(HttpServerPathConfig.class); protected static String httpServerPath; diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/ToolUtil.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/ToolUtil.java index 16be15c3..5ee7c30b 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/ToolUtil.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/ToolUtil.java @@ -76,7 +76,8 @@ public class ToolUtil { public static String storeChunkFileInLocal(String dirName, String fileName, InputStream uploadedInputStream) throws IOException { File tmpDir = new File(dirName); - LOG.info("tmpdir = " + File.separator + dirName); + dirName = File.separator + dirName; + LOG.info("tmpdir = {}" , dirName); if(!tmpDir.exists()) { tmpDir.mkdirs(); } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/connection/ConnectionUtil.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/connection/ConnectionUtil.java index 3184e420..420ab460 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/connection/ConnectionUtil.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/connection/ConnectionUtil.java @@ -58,7 +58,7 @@ public class ConnectionUtil { if(null == sqlSessionFactory) { LOGGER.error("begin generate"); sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); - LOGGER.error("end generate = " + sqlSessionFactory); + LOGGER.error("end generate = {}" , sqlSessionFactory); } } catch(FileNotFoundException ex) { LOGGER.error("File Not Found Exception caught", ex); diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeException.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeException.java index b41a759d..c0d60983 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeException.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeException.java @@ -22,7 +22,7 @@ public class ErrorCodeException extends Exception { private final int errorCode; - public ErrorCodeException(Throwable source, int category, int code, String debugMessage, String[] arguments) { + public ErrorCodeException(Throwable source, int category, int code, String debugMessage, String[] arguments) { //NOSONAR super(debugMessage, source); this.errorCode = code; } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/impl/MarketplaceDaoImpl.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/impl/MarketplaceDaoImpl.java index f275cf91..eac1dc2b 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/impl/MarketplaceDaoImpl.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/impl/MarketplaceDaoImpl.java @@ -142,7 +142,7 @@ public class MarketplaceDaoImpl implements IMarketplaceDao { mapper.deletePackageData(csarId); session.commit(); } catch(PersistenceException e) { - LOGGER.error(EXCEPTION, e);; + LOGGER.error(EXCEPTION, e); } finally { session.close(); } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/resource/PackageManager.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/resource/PackageManager.java index f1f9e2d4..8953b966 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/resource/PackageManager.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/resource/PackageManager.java @@ -53,9 +53,11 @@ public class PackageManager { * @throws MarketplaceResourceException e */ public PackageData addPackage(PackageData packageData) throws MarketplaceResourceException { - LOGGER.info("start add package info to db.info:" + MarketplaceDbUtil.objectToString(packageData)); + String jsonPackageData = MarketplaceDbUtil.objectToString(packageData); + LOGGER.info("start add package info to db.info:{}" , jsonPackageData); PackageData data = handler.create(packageData); - LOGGER.info(" package info to db end.info:" + MarketplaceDbUtil.objectToString(data)); + String jsonData = MarketplaceDbUtil.objectToString(data); + LOGGER.info(" package info to db end.info:{}" , jsonData); return data; } @@ -67,10 +69,10 @@ public class PackageManager { */ public List<PackageData> queryPackageByCsarId(String csarId) throws MarketplaceResourceException { - LOGGER.info("start query package info by csarid." + csarId); + LOGGER.info("start query package info by csarid.{}" , csarId); List<PackageData> data = handler.queryByID(csarId); - LOGGER.info("query package info end.size:" + data.size() + "detail:" - + MarketplaceDbUtil.objectToString(data)); + String jsonData = MarketplaceDbUtil.objectToString(data); + LOGGER.info("query package info end.size:{} detail:{}", data.size(), jsonData); return data; } @@ -86,8 +88,7 @@ public class PackageManager { */ public List<PackageData> queryPackage(String name, String provider, String version, String deletionPending, String type) throws MarketplaceResourceException { - LOGGER.info("start query package info.name:" + name + " provider:" + provider + " version:" - + version + " type:" + type); + LOGGER.info("start query package info.name:{} provider:{} version:{} type:{}", name , provider , version, type); Map<String, String> queryParam = new HashMap<>(); if (MarketplaceDbUtil.isNotEmpty(name)) { queryParam.put(Parameters.NAME.name(), name); @@ -105,8 +106,8 @@ public class PackageManager { queryParam.put(Parameters.PROVIDER.name(), provider); } List<PackageData> data = handler.query(queryParam); - LOGGER.info("query package info end.size:" + data.size() + "detail:" - + MarketplaceDbUtil.objectToString(data)); + String jsonData = MarketplaceDbUtil.objectToString(data); + LOGGER.info("query package info end.size:{} detail:{}", data.size(), jsonData); return data; } @@ -116,9 +117,9 @@ public class PackageManager { * @throws MarketplaceResourceException e */ public void deletePackage(String packageId) throws MarketplaceResourceException { - LOGGER.info("start delete package info by id." + packageId); + LOGGER.info("start delete package info by id.{}" , packageId); handler.delete(packageId); - LOGGER.info(" delete package info end id." + packageId); + LOGGER.info(" delete package info end id.{}" , packageId); } /** @@ -128,14 +129,14 @@ public class PackageManager { */ public void updateDownloadCount(String packageId) throws MarketplaceResourceException { - LOGGER.info("Request received for Updating down load count for ID:" + packageId); + LOGGER.info("Request received for Updating down load count for ID:{}" , packageId); //STEP 1: Get the Existing download count from DB //------------------------------------------------- List<PackageData> data = handler.queryByID(packageId); if(data.isEmpty()) { - LOGGER.info("Package Info not foun for ID:" + packageId); + LOGGER.info("Package Info not foun for ID:{}" , packageId); return; } @@ -147,7 +148,7 @@ public class PackageManager { handler.update(oPackageData); - LOGGER.info("Download count updated to :" + idownloadcount); + LOGGER.info("Download count updated to :{}" , idownloadcount); } } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/BaseHandler.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/BaseHandler.java index 4e3e117c..aa836439 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/BaseHandler.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/BaseHandler.java @@ -48,15 +48,16 @@ public abstract class BaseHandler<T extends BaseData> { @SuppressWarnings({"unchecked", "rawtypes"}) public PackageData create(PackageData data, String resouceType) throws MarketplaceResourceException { PackageData rtnData = null; - logger.info("BaseHandler:start create data.info:" + MarketplaceDbUtil.objectToString(data)); + String jsonData = MarketplaceDbUtil.objectToString(data); + logger.info("BaseHandler:start create data.info:{}" , jsonData); try { IMarketplaceDao dao = new MarketplaceDaoImpl(); dao.savePackageData(data); rtnData = data; } catch (Exception e1) { - logger.error("BaseHandler:error while creating " + resouceType, e1); + logger.error("BaseHandler:error while creating {} {}" , resouceType, e1); } - logger.info("BaseHandler:create data end.info:" + MarketplaceDbUtil.objectToString(data)); + logger.info("BaseHandler:create data end.info:{}" , jsonData); return rtnData; } @@ -68,7 +69,8 @@ public abstract class BaseHandler<T extends BaseData> { */ @SuppressWarnings({"rawtypes", "unchecked"}) public void delete(T data) throws MarketplaceResourceException { - logger.info("BaseHandler:start delete data.info:" + MarketplaceDbUtil.objectToString(data)); + String jsonData = MarketplaceDbUtil.objectToString(data); + logger.info("BaseHandler:start delete data.info:{}" , jsonData); IMarketplaceDao dao = new MarketplaceDaoImpl(); dao.deletePackageData(((PackageData)data).getCsarId()); logger.info("BaseHandler:delete data end"); @@ -84,18 +86,21 @@ public abstract class BaseHandler<T extends BaseData> { @SuppressWarnings({"rawtypes", "unchecked"}) public List<PackageData> query(Map<String, String> queryParam) throws MarketplaceResourceException { - logger.info("BaseHandler:start query data .info:" + MarketplaceDbUtil.objectToString(queryParam)); + String jsonQueryParam = MarketplaceDbUtil.objectToString(queryParam); + logger.info("BaseHandler:start query data .info:{}" , jsonQueryParam); IMarketplaceDao dao = new MarketplaceDaoImpl(); List<PackageData> datas = dao.getPackageDataSubset(queryParam); - logger.info("BaseHandler: query data end .info:" + MarketplaceDbUtil.objectToString(datas)); + String jsonData = MarketplaceDbUtil.objectToString(datas); + logger.info("BaseHandler: query data end .info:{}" , jsonData); return datas; } @SuppressWarnings({"rawtypes", "unchecked"}) - public void update(T data) throws MarketplaceResourceException { - logger.info("BaseHandler:start update data.info:" + MarketplaceDbUtil.objectToString(data)); + public void update(T data) { + String jsonData = MarketplaceDbUtil.objectToString(data); + logger.info("BaseHandler:start update data.info:{}" , jsonData); IMarketplaceDao dao = new MarketplaceDaoImpl(); dao.updatePackageData((PackageData)data); logger.info("update data end"); diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/PackageHandler.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/PackageHandler.java index 21db6f91..5fb41dde 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/PackageHandler.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/PackageHandler.java @@ -78,7 +78,7 @@ public class PackageHandler extends BaseHandler<PackageData> { throws MarketplaceResourceException { logger.info("packageHandler:start query package info."); List<PackageData> data = new ArrayList<>(); - logger.info("packageHandler:start query data .info:" + csarID); + logger.info("packageHandler:start query data .info:{}" , csarID); IMarketplaceDao dao = new MarketplaceDaoImpl(); Object result = dao.getPackageData(csarID); if (result != null) { @@ -86,7 +86,8 @@ public class PackageHandler extends BaseHandler<PackageData> { } else { logger.info("packageHandler: query package info is null."); } - logger.info("packageHandler: query data end .info:" + MarketplaceDbUtil.objectToString(data)); + String jsonData = MarketplaceDbUtil.objectToString(data); + logger.info("packageHandler: query data end .info:{}" , jsonData); return data; } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/FileManagerFactory.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/FileManagerFactory.java index 91b64cb7..aa864e6d 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/FileManagerFactory.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/FileManagerFactory.java @@ -47,7 +47,7 @@ public class FileManagerFactory { private static FileManagerType getType() { String type = System.getenv("useFtp"); - logger.info("read environment varibale uesFtp:" + type); + logger.info("read environment varibale uesFtp:{}" , type); if ((type != null) && "true".equals(type)) { return FileManagerType.FTP; } else { diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/http/HttpFileManagerImpl.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/http/HttpFileManagerImpl.java index 403c52ac..cffbe018 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/http/HttpFileManagerImpl.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/http/HttpFileManagerImpl.java @@ -29,7 +29,7 @@ public class HttpFileManagerImpl implements FileManager { @Override public boolean upload(String srcPath, String dstPath) { boolean flag = true; - LOGGER.info("start upload file.srcPath:" + srcPath + " dstPath" + dstPath); + LOGGER.info("start upload file.srcPath:{} dstPath{}" , srcPath , dstPath); File srcFile = new File(srcPath); if (!srcFile.exists()) { LOGGER.error("src file not exist!"); @@ -55,9 +55,9 @@ public class HttpFileManagerImpl implements FileManager { @Override public boolean delete(String srcPath) { - LOGGER.info("start delete file from http server.srcPath:" + srcPath); + LOGGER.info("start delete file from http server.srcPath:{}" , srcPath); boolean flag = ToolUtil.deleteDir(new File(ToolUtil.getHttpServerAbsolutePath() + srcPath)); - LOGGER.info("delete file from http server end.flag:" + flag); + LOGGER.info("delete file from http server end.flag:{}" , flag); return flag; } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestExceutor.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestExceutor.java index 25ca4edc..181495c0 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestExceutor.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestExceutor.java @@ -54,7 +54,7 @@ public class FunctionTestExceutor { String funcTestId = null; String packagePath = onBoradFuncTestReq.getPackagePath() + File.separator + onBoradFuncTestReq.getPackageName(); - logger.info("Package file path Function test:" + packagePath); + logger.info("Package file path Function test:{}" , packagePath); // Validate package path if (!FileUtil.validatePath(packagePath)) { @@ -87,13 +87,13 @@ public class FunctionTestExceutor { } funcTestId = rsp.getResult(); - logger.info("Response for Function Test :", funcTestId); + logger.info("Response for Function Test :{}", funcTestId); return funcTestId.replaceAll("\"", ""); } catch (NumberFormatException e) { - logger.error("Invalid port number :", oMsbDetails.getDefaultServer().getPort()); + logger.error("Invalid port number :{}", oMsbDetails.getDefaultServer().getPort()); } catch (FileNotFoundException exp) { - logger.error("File not found Exception for file:", onBoradFuncTestReq.getPackagePath()); + logger.error("File not found Exception for file:{}", onBoradFuncTestReq.getPackagePath()); logger.error("File not found Exception for :", exp); } catch (IOException e) { logger.error("IOException:", e); @@ -119,17 +119,17 @@ public class FunctionTestExceutor { return result; } - logger.info("GetTestResultsByFuncTestKey for Function Test Results for :" + key); + logger.info("GetTestResultsByFuncTestKey for Function Test Results for :{}" , key); RestResponse rspGet = RestfulClient.get(oMsbDetails.getDefaultServer().getHost(), Integer.parseInt(oMsbDetails.getDefaultServer().getPort()), CommonConstant.FunctionTest.FUNCTEST_RESULT_URL + key); if (!checkValidResponse(rspGet)) { - logger.error("Failed to convert String Json Response to TestResults list:" + rspGet.getResult()); + logger.error("Failed to convert String Json Response to TestResults list:{}" , rspGet.getResult()); return result; } result = rspGet.getResult(); - logger.info("Function Test Results for Key:" + key + "Response:" + rspGet.getResult()); + logger.info("Function Test Results for Key:{} Response:{}" , key , rspGet.getResult()); return result; } @@ -147,7 +147,7 @@ public class FunctionTestExceutor { return result; } - logger.info("ExecuteFunctionTest Test request Received:" + strJsonRequest); + logger.info("ExecuteFunctionTest Test request Received:{}" , strJsonRequest); MsbDetails oMsbDetails = MsbDetailsHolder.getMsbDetails(); if (null == oMsbDetails) { @@ -155,17 +155,17 @@ public class FunctionTestExceutor { return result; } - logger.info("GetTestResultsByFuncTestKey for Function Test Results for :" + strJsonRequest); + logger.info("GetTestResultsByFuncTestKey for Function Test Results for :{}" , strJsonRequest); RestResponse rspGet = RestfulClient.sendPostRequest(oMsbDetails.getDefaultServer().getHost(), oMsbDetails.getDefaultServer().getPort(), CommonConstant.FunctionTest.FUNCTEST_RESULT_URL, strJsonRequest); if (!checkValidResponse(rspGet)) { - logger.error("Failed to convert String Json Response to TestResults list:" + rspGet.getResult()); + logger.error("Failed to convert String Json Response to TestResults list:{}" , rspGet.getResult()); return result; } result = rspGet.getResult(); - logger.info("ExecuteFunctionTest Function Test Result: " + rspGet.getResult()); + logger.info("ExecuteFunctionTest Function Test Result: {}" , rspGet.getResult()); return result; } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestHook.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestHook.java index 3ffb1bab..c48b3887 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestHook.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestHook.java @@ -48,8 +48,8 @@ public class FunctionTestHook { */ public int exec(OnBoradingRequest onBoradingReq) { - logger.info("OnboradingRequest received for Package:" + onBoradingReq.getCsarId() + " Path:" - + onBoradingReq.getPackagePath()); + logger.info("OnboradingRequest received for Package:{} Path:{}", onBoradingReq.getCsarId() + , onBoradingReq.getPackagePath()); buildResultPath(onBoradingReq); @@ -60,8 +60,8 @@ public class FunctionTestHook { // STEP 1:Check Package Exists // --------------------------- if (!FileUtil.checkFileExists(onBoradingReq.getPackagePath())) { - logger.error("Package Not Found at Path:" + onBoradingReq.getPackagePath() + ", Package Id:" - + onBoradingReq.getCsarId()); + logger.error("Package Not Found at Path:{} Package Id:{}" , onBoradingReq.getPackagePath() + , onBoradingReq.getCsarId()); oFuncTestResult.setOperFinished(true); oFuncTestResult.setOperStatus(EnumResult.FAIL.getIndex()); buildFuncTestResponse(oFuncTestResult, CommonConstant.FunctionTest.FUNCTEST_PACKAGE_EXISTS, @@ -123,10 +123,10 @@ public class FunctionTestHook { return null; } - logger.info("Function Test results request for Package:" + packageData.getCsarId()); + logger.info("Function Test results request for Package:{}" , packageData.getCsarId()); ResultKey keydata = getFuncTestResultKey(packageData); if ((null == keydata) || (keydata.getKey().isEmpty())) { - logger.error("Function Test key Not Found for Package Id:", packageData.getCsarId()); + logger.error("Function Test key Not Found for Package Id:{}", packageData.getCsarId()); return null; } return FunctionTestExceutor.getTestResultsByFuncTestKey(keydata.getKey()); @@ -147,8 +147,8 @@ public class FunctionTestHook { filePath.append(File.separator); filePath.append("functestResultKey.json"); - logger.debug("Function test Results Key for Package Id:" + onBoradingReq.getCsarId() + ", Key:" + resultKey - + " Path" + filePath.toString()); + logger.debug("Function test Results Key for Package Id:{} Key:{} Path{}" , onBoradingReq.getCsarId(), resultKey + , filePath); ResultKey oResultKey = new ResultKey(); oResultKey.setCsarId(onBoradingReq.getCsarId()); @@ -167,8 +167,9 @@ public class FunctionTestHook { // STore Results to DB(Currently we will make JSON and Store JSON to // Package Path) // ------------------------------------------------------------------------------- - logger.debug("Function test Status for Package Id:" + oFuncTestResult.getCsarId() + ", Result:" - + ToolUtil.objectToString(oFuncTestResult)); + String jsonoFuncTestResult = ToolUtil.objectToString(oFuncTestResult); + logger.debug("Function test Status for Package Id:{} Result:{}" ,oFuncTestResult.getCsarId() + , jsonoFuncTestResult); StringBuilder filePath = new StringBuilder(getResultStorePath()); filePath.append(File.separator); @@ -218,7 +219,7 @@ public class FunctionTestHook { filePath.append(File.separator); filePath.append("functionTest.json"); - logger.info("On Boarding Status for Package Id:" + packageData.getCsarId() + ", Result Path:" + filePath); + logger.info("On Boarding Status for Package Id:{} Result Path:{}" ,packageData.getCsarId(), filePath); return (OnBoardingResult) FileUtil.readJsonDatafFromFile(filePath.toString(), OnBoardingResult.class); } @@ -230,7 +231,7 @@ public class FunctionTestHook { fileName.append(File.separator); fileName.append("functestResultKey.json"); - logger.info("Func Test Result key for Package Id:" + packageData.getCsarId() + ", Result Path:" + fileName); + logger.info("Func Test Result key for Package Id:{} Result Path:{}" , packageData.getCsarId(),fileName); return (ResultKey) FileUtil.readJsonDatafFromFile(fileName.toString(), ResultKey.class); } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java index bf6d2879..4d2e074b 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java @@ -16,7 +16,6 @@ package org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle; import java.io.File; -import java.io.IOException; import java.util.Map; import org.apache.http.entity.ContentType; @@ -55,7 +54,7 @@ public class LifecycleTestExceutor { @SuppressWarnings("unchecked") public static String uploadPackageToCatalouge(OnBoradingRequest onBoradFuncTestReq) { String packagePath = onBoradFuncTestReq.getPackagePath() + File.separator + onBoradFuncTestReq.getPackageName(); - logger.info("Package file path uploadPackageToCatalouge:" + packagePath); + logger.info("Package file path uploadPackageToCatalouge:{}" , packagePath); String catalougeCsarId = null; @@ -87,14 +86,14 @@ public class LifecycleTestExceutor { Integer.parseInt(oMsbDetails.getDefaultServer().getPort()), CommonConstant.CATALOUGE_UPLOAD_URL, builder.build()); if (!checkValidResponse(rsp)) { - logger.error("Failed to upload package to catalouge:" + rsp.getStatusCode()); + logger.error("Failed to upload package to catalouge:{}" , rsp.getStatusCode()); return catalougeCsarId; } - logger.info("Response for uploadPackageToCatalouge :" + rsp.getResult()); + logger.info("Response for uploadPackageToCatalouge :{}" , rsp.getResult()); catalougeCsarId = getCsarIdValue(rsp.getResult()); - logger.info("CSARID for uploadPackageToCatalouge :" + catalougeCsarId); + logger.info("CSARID for uploadPackageToCatalouge :{}" , catalougeCsarId); return catalougeCsarId; } @@ -105,7 +104,7 @@ public class LifecycleTestExceutor { * oLifeCycleTestReq * @return result of the test or null (in case of failure) */ - public static String execlifecycleTest(OnBoradingRequest onBoradFuncTestReq, LifeCycleTestReq oLifeCycleTestReq) { + public static String execlifecycleTest(OnBoradingRequest onBoradFuncTestReq, LifeCycleTestReq oLifeCycleTestReq) { //NOSONAR String result = null; if ((null == onBoradFuncTestReq.getPackagePath()) || (null == onBoradFuncTestReq.getPackageName())) { @@ -114,7 +113,7 @@ public class LifecycleTestExceutor { } String packagePath = onBoradFuncTestReq.getPackagePath() + File.separator + onBoradFuncTestReq.getPackageName(); - logger.info("Package file path Function test:" + packagePath); + logger.info("Package file path Function test:{}" , packagePath); // Validate package path if (!FileUtil.validatePath(packagePath)) { @@ -135,12 +134,12 @@ public class LifecycleTestExceutor { oMsbDetails.getDefaultServer().getPort(), CommonConstant.LifeCycleTest.LIFECYCLE_TEST_URL, rawDataJson); if (!checkValidResponse(oResponse)) { - logger.error("execlifecycleTest response is faliure :" + oResponse.getStatusCode()); + logger.error("execlifecycleTest response is faliure :{}" , oResponse.getStatusCode()); return result; } result = oResponse.getResult(); - logger.info("Response execlifecycleTest :" + oResponse.getResult()); + logger.info("Response execlifecycleTest :{}" , oResponse.getResult()); return result; } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHook.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHook.java index 5526d380..7fe8d12d 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHook.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHook.java @@ -46,8 +46,8 @@ public class LifecycleTestHook { * @return */ public int exec(OnBoradingRequest onBoradingReq) { - logger.info("OnboardingRequest Lifecycle Request received for Package:" + onBoradingReq.getCsarId() + " Path:" - + onBoradingReq.getPackagePath()); + logger.info("OnboardingRequest Lifecycle Request received for Package:{} Path:{}" , onBoradingReq.getCsarId() + , onBoradingReq.getPackagePath()); // STEP 1: Validate Input and Build result // --------------------------------------------------------- @@ -126,8 +126,9 @@ public class LifecycleTestHook { // STore Results to DB(Currently we will make JSON and Store JSON to // Package Path) // ------------------------------------------------------------------------------- - logger.info("Lifecycle test Status for Package Id:" + oFuncTestResult.getCsarId() + ", Result:" - + ToolUtil.objectToString(oFuncTestResult)); + String jsonoFuncTestResult = ToolUtil.objectToString(oFuncTestResult); + logger.info("Lifecycle test Status for Package Id:{} Result:{}" , oFuncTestResult.getCsarId() + , jsonoFuncTestResult); String filePath = getResultStorePath() + File.separator + oFuncTestResult.getCsarId() + File.separator + "lifecycleTest.json"; FileUtil.writeJsonDatatoFile(filePath, oFuncTestResult); @@ -166,8 +167,8 @@ public class LifecycleTestHook { String filePath = getResultStorePath() + File.separator + onBoradingReq.getCsarId() + File.separator + "lifecycleTestResultKey.json"; - logger.debug("Function test Results Key for Package Id:" + onBoradingReq.getCsarId() + ", Key:" + resultKey - + " Path" + filePath); + logger.debug("Function test Results Key for Package Id:{} Key:{} Path{}" , onBoradingReq.getCsarId(), resultKey + , filePath); ResultKey oResultKey = new ResultKey(); oResultKey.setCsarId(onBoradingReq.getCsarId()); diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandler.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandler.java index b7cfdc1c..c79e7b6b 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandler.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandler.java @@ -53,7 +53,7 @@ public final class OnBoardingHandler { LifecycleTestHook oLifecycleTestHook = new LifecycleTestHook(); int iLifeCycleResponse = oLifecycleTestHook.exec(onBoardingReq); if (EnumResult.SUCCESS.getIndex() != iLifeCycleResponse) { - logger.error("Onboarding failed for Package Id during Lifecycle Test:" + onBoardingReq.getCsarId()); + logger.error("Onboarding failed for Package Id during Lifecycle Test:{}" , onBoardingReq.getCsarId()); // Note: We need to continue even if life cycle test fails as this // test is not mandatory } @@ -63,7 +63,7 @@ public final class OnBoardingHandler { FunctionTestHook oFunctionTestHook = new FunctionTestHook(); int iFuncTestResponse = oFunctionTestHook.exec(onBoardingReq); if (EnumResult.SUCCESS.getIndex() != iFuncTestResponse) { - logger.error("Onboarding failed for Package Id during Function Test:" + onBoardingReq.getCsarId()); + logger.error("Onboarding failed for Package Id during Function Test:{}" , onBoardingReq.getCsarId()); // Note: We need to continue even if function test fails as this // test is not mandatory } @@ -72,7 +72,7 @@ public final class OnBoardingHandler { try { PackageManager.getInstance().updateDownloadCount(onBoardingReq.getCsarId()); } catch (Exception e) { - logger.error("Download count update failed for Package:" + onBoardingReq.getPackagePath(), e); + logger.error("Download count update failed for Package:{}" , onBoardingReq.getPackagePath(), e); } } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/rest/RestfulClient.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/rest/RestfulClient.java index 9a530479..92754cf6 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/rest/RestfulClient.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/rest/RestfulClient.java @@ -115,8 +115,8 @@ public class RestfulClient { try { String urlPost = "http://" + ip + ":" + port + url; - logger.info("URL formed for Post, URL :" + urlPost); - logger.info("URL formed for Post, JSON :" + strJson); + logger.info("URL formed for Post, URL :{}" , urlPost); + logger.info("URL formed for Post, JSON :{}" , strJson); HttpPost request = new HttpPost(urlPost); diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java index ad5034e3..1fc37427 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java @@ -88,7 +88,7 @@ public class PackageWrapper { public Response updateValidateStatus(InputStream inputStream) throws IOException { String reqParam = IOUtils.toString(inputStream); - LOG.info("updateValidateStatus request param:" + reqParam); + LOG.info("updateValidateStatus request param:{}" , reqParam); if(StringUtils.isBlank(reqParam)) { LOG.error("The updateValidateStatus request params can't be null"); return Response.status(Status.EXPECTATION_FAILED).build(); @@ -121,8 +121,8 @@ public class PackageWrapper { } if(lyfValidateResp.getLifecycleStatus().equalsIgnoreCase(CommonConstant.SUCCESS_STR) && lyfValidateResp.getValidateStatus().equalsIgnoreCase(CommonConstant.SUCCESS_STR)) { - LOG.error("Lifecycle/Validation Response failed :" + lyfValidateResp.getLifecycleStatus() + File.separator - + lyfValidateResp.getValidateStatus()); + String lyfValidateResponse = lyfValidateResp.getLifecycleStatus() + File.separator+lyfValidateResp.getValidateStatus(); + LOG.error("Lifecycle/Validation Response failed :{}" , lyfValidateResponse); bOperStatus = true; } return bOperStatus; @@ -142,8 +142,8 @@ public class PackageWrapper { String type) { List<PackageData> dbresult = new ArrayList<>(); List<PackageMeta> result = new ArrayList<>(); - LOG.info("query package info.name:" + name + " provider:" + provider + " version" + version + " deletionPending" - + deletionPending + " type:" + type); + LOG.info("query package info.name:{} provider:{} version{} deletionPending{} type:{}" , name , provider , version + , deletionPending , type); try { dbresult = PackageManager.getInstance().queryPackage(name, provider, version, deletionPending, type); result = PackageWrapperUtil.packageDataList2PackageMetaList(dbresult); @@ -193,7 +193,7 @@ public class PackageWrapper { PackageBasicInfo basicInfo = PackageWrapperUtil.getPacageBasicInfo(fileLocation); UploadPackageResponse result = new UploadPackageResponse(); Boolean isEnd = PackageWrapperUtil.isUploadEnd(contentRange); - if(isEnd) { + if(Boolean.TRUE.equals(isEnd)) { PackageMeta packageMeta = PackageWrapperUtil.getPackageMeta(packageId, fileName, fileLocation, basicInfo, details); try { @@ -204,8 +204,9 @@ public class PackageWrapper { String dowloadUri = File.separator + path + File.separator; packageMeta.setDownloadUri(dowloadUri); - LOG.info("dest path is : " + path); - LOG.info("packageMeta = " + ToolUtil.objectToString(packageMeta)); + String jsonPackageMeta = ToolUtil.objectToString(packageMeta); + LOG.info("dest path is : {}" , path); + LOG.info("packageMeta = {}" , jsonPackageMeta); PackageData packageData = PackageWrapperUtil.getPackageData(packageMeta); @@ -228,18 +229,21 @@ public class PackageWrapper { packageData.setDownloadCount(-1); PackageData packateDbData = PackageManager.getInstance().addPackage(packageData); - LOG.info("Store package data to database succed ! packateDbData = " - + ToolUtil.objectToString(packateDbData)); - LOG.info("upload package file end, fileName:" + fileName); + String jsonPackageDbData = ToolUtil.objectToString(packateDbData); + LOG.info("Store package data to database succed ! packateDbData = {}" + , jsonPackageDbData); + LOG.info("upload package file end, fileName:{}" , fileName); result.setCsarId(packateDbData.getCsarId()); addOnBoardingRequest(oOnboradingRequest); - LOG.info("OnboradingRequest Data : " + ToolUtil.objectToString(oOnboradingRequest)); + String jsonoOnboradingRequest = ToolUtil.objectToString(oOnboradingRequest); + LOG.info("OnboradingRequest Data : {}" , jsonoOnboradingRequest); } } catch(NullPointerException e) { - LOG.error("Package basicInfo is incorrect ! basicIonfo = " + ToolUtil.objectToString(basicInfo), e); + String jsonBasicInfo = ToolUtil.objectToString(basicInfo); + LOG.error("Package basicInfo is incorrect ! basicIonfo = {} {}" , jsonBasicInfo, e); return null; } } @@ -270,7 +274,8 @@ public class PackageWrapper { String fileName = "temp_" + packageId + FILE_FORMAT; if(null != fileDetail) { - LOG.info("the fileDetail = " + ToolUtil.objectToString(fileDetail)); + String jsonFileDetail = ToolUtil.objectToString(fileDetail); + LOG.info("the fileDetail = {}" , jsonFileDetail); fileName = ToolUtil.processFileName(fileDetail.getFileName()); } @@ -281,21 +286,21 @@ public class PackageWrapper { if(head != null) { contentRange = head.getHeaderString(CommonConstant.HTTP_HEADER_CONTENT_RANGE); } - LOG.info("store package chunk file, fileName:" + fileName + ",contentRange:" + contentRange); + LOG.info("store package chunk file, fileName:{} contentRange:{}", fileName , contentRange); if(ToolUtil.isEmptyString(contentRange)) { int fileSize = uploadedInputStream.available(); contentRange = "0-" + fileSize + "/" + fileSize; } String fileLocation = ToolUtil.storeChunkFileInLocal(localDirName, fileName, uploadedInputStream); - LOG.info("the fileLocation when upload package is :" + fileLocation); + LOG.info("the fileLocation when upload package is :{}" , fileLocation); uploadedInputStream.close(); if (!DISABLE_VALIDATION) { try { - Result result = OpenRemoteCli.run("localhost", 50051, null, Arrays.asList(new String[] { "--product", "onap-vtp", "csar-validate", "--csar", fileLocation, "--format", "json" })); - LOG.info("CSAR validation is successful" + result.getOutput()); + Result result = OpenRemoteCli.run("localhost", 50051, null, Arrays.asList( "--product", "onap-vtp", "csar-validate", "--csar", fileLocation, "--format", "json" )); + LOG.info("CSAR validation is successful{}" , result.getOutput()); int exitCode = result.getExitCode(); String output = result.getOutput(); @@ -349,7 +354,7 @@ public class PackageWrapper { * @return Response */ public Response delPackage(String csarId) { - LOG.info("delete package info.csarId:" + csarId); + LOG.info("delete package info.csarId:{}" , csarId); if(ToolUtil.isEmptyString(csarId)) { LOG.error("delete package fail, csarid is null"); return Response.serverError().build(); @@ -378,7 +383,8 @@ public class PackageWrapper { try { PackageManager.getInstance().deletePackage(csarId); } catch(MarketplaceResourceException e1) { - LOG.error("delete package by csarId from db error ! " + e1.getMessage(), e1); + String message = e1.getMessage(); + LOG.error("delete package by csarId from db error ! {} {}" , message, e1); } } @@ -397,14 +403,14 @@ public class PackageWrapper { + File.separatorChar + packageData.getCsarId() + File.separator + packageName + File.separatorChar + packageData.getVersion() + File.separator + packageName + FILE_FORMAT; - LOG.info("downloadCsarPackagesById path is : " + path); + LOG.info("downloadCsarPackagesById path is : {}" , path); File csarFile = new File(path); if(!csarFile.exists()) { return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } - LOG.info("downloadCsarPackagesById ABS path is : " + csarFile.getAbsolutePath()); + LOG.info("downloadCsarPackagesById ABS path is : {}" , csarFile.getAbsolutePath()); try { InputStream fis = new BufferedInputStream(new FileInputStream(csarFile.getAbsolutePath())); @@ -450,7 +456,7 @@ public class PackageWrapper { PackageManager.getInstance().updateDownloadCount(csarId); bupdateSucess = true; } catch(Exception exp) { - LOG.error("Updating Donwload count failed for Package with ID !!! : " + exp.getMessage(), exp); + LOG.error("Updating Donwload count failed for Package with ID !!! : {} {}" , exp.getMessage(), exp); } return bupdateSucess; } @@ -502,7 +508,7 @@ public class PackageWrapper { * @return */ public Response getOnBoardingResult(String csarId, String operTypeId, String operId) { - LOG.info("getOnBoardingResult request : csarId:" + csarId + " operTypeId:" + operTypeId + " operId:" + operId); + LOG.info("getOnBoardingResult request csarId:{} operTypeId:{} operId:{}", csarId , operTypeId , operId); try { PackageData packageData = PackageWrapperUtil.getPackageInfoById(csarId); if(null == packageData) { @@ -518,7 +524,7 @@ public class PackageWrapper { filterOnBoardingResultByOperId(oOnBoardingResult, operId); String strResult = ToolUtil.objectToString(oOnBoardingResult); - LOG.info("getOnBoardingResult response : " + strResult); + LOG.info("getOnBoardingResult response : {}" , strResult); return Response.ok(strResult, "application/json").build(); } catch(NullPointerException e) { LOG.error("Null param in getOnBoardingResult", e); @@ -557,14 +563,14 @@ public class PackageWrapper { * @return */ public Response getOperResultByOperTypeId(String csarId, String operTypeId) { - LOG.error("getOnBoardingResult request : csarId:" + csarId + " operTypeId:" + operTypeId); + LOG.error("getOnBoardingResult request : csarId:{} operTypeId:{}" , csarId , operTypeId); if(null == csarId || null == operTypeId || csarId.isEmpty() || operTypeId.isEmpty()) { return Response.status(Status.BAD_REQUEST).build(); } PackageData packageData = PackageWrapperUtil.getPackageInfoById(csarId); if(null == packageData) { - LOG.error("Failed to find package for PackageID:" + csarId); + LOG.error("Failed to find package for PackageID:{}" , csarId); return Response.status(Status.PRECONDITION_FAILED).build(); } @@ -572,10 +578,10 @@ public class PackageWrapper { // --------------------------------------------- String strResult = FunctionTestHook.getFuncTestResults(packageData); if(null == strResult) { - LOG.error("NULL reponse for getOperResultByOperTypeId response :" + strResult); + LOG.error("NULL reponse for getOperResultByOperTypeId response :{}" , strResult); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } - LOG.info("getOperResultByOperTypeId response :" + strResult); + LOG.info("getOperResultByOperTypeId response :{}" , strResult); return Response.ok(strResult, MediaType.APPLICATION_JSON).build(); } @@ -598,7 +604,7 @@ public class PackageWrapper { String filePath = org.onap.vnfsdk.marketplace.filemanage.http.ToolUtil.getAppDeployPath() + File.separator + "generalconfig/OnBoardingSteps.json"; - LOG.info("Onboarding Steps Json file Path :" + filePath); + LOG.info("Onboarding Steps Json file Path :{}" , filePath); OnBoardingSteps oOnBoardingSteps = (OnBoardingSteps)FileUtil.readJsonDatafFromFile(filePath, OnBoardingSteps.class); @@ -606,7 +612,7 @@ public class PackageWrapper { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } String strResult = ToolUtil.objectToString(oOnBoardingSteps); - LOG.info("getOnBoardingSteps response :" + strResult); + LOG.info("getOnBoardingSteps response :{}" , strResult); return Response.ok(strResult, MediaType.APPLICATION_JSON).build(); } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java index ac0f97cc..4baf6f81 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java @@ -39,7 +39,6 @@ import org.onap.vnfsdk.marketplace.model.parser.EnumPackageFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import com.google.gson.internal.LinkedTreeMap; @@ -116,7 +115,7 @@ public class PackageWrapperUtil { result = packageDataList.get(0); } } catch(MarketplaceResourceException e1) { - LOG.error("query package by csarId from db error ! " + e1.getMessage(), e1); + LOG.error("query package by csarId from db error ! {} {}" , e1.getMessage(), e1); } return result; } @@ -174,7 +173,7 @@ public class PackageWrapperUtil { packageList = PackageManager.getInstance().queryPackageByCsarId(csarId); downloadUri = packageList.get(0).getDownloadUri(); } catch(MarketplaceResourceException e1) { - LOG.error("Query CSAR package by ID failed ! csarId = " + csarId, e1); + LOG.error("Query CSAR package by ID failed ! csarId = {} {}" , csarId, e1); } return downloadUri; } @@ -294,7 +293,7 @@ public class PackageWrapperUtil { } } } catch(IOException e1) { - LOG.error("judge package type error ! " + e1.getMessage(), e1); + LOG.error("judge package type error ! {} {}" , e1.getMessage(), e1); } if(isXmlCsar) { basicInfo.setFormat(CommonConstant.PACKAGE_XML_FORMAT); @@ -348,9 +347,8 @@ public class PackageWrapperUtil { } } - reader.close(); } catch(IOException e) { - LOG.error("Exception while parsing manifest file" + e, e); + LOG.error("Exception while parsing manifest file {}", e); } return basicInfo; @@ -412,9 +410,8 @@ public class PackageWrapperUtil { } } - reader.close(); } catch(IOException e) { - LOG.error("Exception while parsing manifest file" + e, e); + LOG.error("Exception while parsing manifest file {}", e); } return basicInfo; diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java index 254cc6ad..0d813c74 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java @@ -107,7 +107,7 @@ public class VTPResource { return this.makeRpcAndGetJson(args, VTP_EXECUTION_GRPC_TIMEOUT); } - protected JsonElement makeRpcAndGetJson(List<String> args, int timeout) throws VTPException, IOException { + protected JsonElement makeRpcAndGetJson(List<String> args, int timeout) throws VTPException { Result result = this.makeRpc(args, timeout); JsonParser jsonParser = new JsonParser(); return jsonParser.parse(result.getOutput()); diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java index eb43b937..3bd522ff 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java @@ -16,7 +16,6 @@ package org.onap.vtp.execution; -import java.io.EOFException; import java.io.File; import java.io.IOException; import java.nio.file.StandardCopyOption; @@ -28,7 +27,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.UUID; -import java.util.logging.Logger; import javax.ws.rs.Consumes; import javax.ws.rs.DefaultValue; @@ -146,26 +144,28 @@ public class VTPExecutionResource extends VTPResource{ private Map<String, String> storeTestCaseInputFiles(List<FormDataBodyPart> bodyParts) throws IOException { Map<String, String> map = new HashMap<>(); - if (bodyParts != null) - for (FormDataBodyPart part: bodyParts) { - String name = part.getContentDisposition().getFileName(); - String path = VTP_EXECUTION_TEMP_STORE + "/" + name; - - File f = new File(path); - if (f.exists()) { - FileUtils.forceDelete(f); - } - FileUtils.forceMkdir(f.getParentFile()); + if (bodyParts != null) { + for (FormDataBodyPart part: bodyParts) { + String name = part.getContentDisposition().getFileName(); + String path = VTP_EXECUTION_TEMP_STORE + "/" + name; //NOSONAR + + File f = new File(path); + if (f.exists()) { + FileUtils.forceDelete(f); + } + FileUtils.forceMkdir(f.getParentFile()); - BodyPartEntity fileEntity = (BodyPartEntity) part.getEntity(); - java.nio.file.Files.copy( - fileEntity.getInputStream(), - f.toPath(), - StandardCopyOption.REPLACE_EXISTING); + BodyPartEntity fileEntity = (BodyPartEntity) part.getEntity(); + java.nio.file.Files.copy( + fileEntity.getInputStream(), + f.toPath(), + StandardCopyOption.REPLACE_EXISTING); - IOUtils.closeQuietly(fileEntity.getInputStream()); + IOUtils.closeQuietly(fileEntity.getInputStream()); + + map.put(name, path); + } - map.put(name, path); } return map; @@ -197,9 +197,11 @@ public class VTPExecutionResource extends VTPResource{ LOG.error("IOException occurs",e); } - for (Map.Entry<String, String> entry: map.entrySet()) { - if (executionsJson.contains(FILE + entry.getKey())) { - executionsJson = executionsJson.replaceAll(FILE + entry.getKey(), entry.getValue()); + if (map != null) { + for (Map.Entry<String, String> entry: map.entrySet()) { + if (executionsJson.contains(FILE + entry.getKey())) { + executionsJson = executionsJson.replaceAll(FILE + entry.getKey(), entry.getValue()); + } } } @@ -220,11 +222,13 @@ public class VTPExecutionResource extends VTPResource{ executions = this.executeHandler(executions, requestId); - for (Map.Entry<String, String> entry: map.entrySet()) { - try { - FileUtils.forceDelete(new File(entry.getValue())); - } catch (IOException e) { - LOG.error("IOException occurs",e); + if (map != null) { + for (Map.Entry<String, String> entry: map.entrySet()) { + try { + FileUtils.forceDelete(new File(entry.getValue())); + } catch (IOException e) { + LOG.error("IOException occurs",e); + } } } @@ -236,13 +240,13 @@ public class VTPExecutionResource extends VTPResource{ String scenario, String testSuiteName, String testCaseName, - String profile, + String profile, //NOSONAR String startTime, - String endTime) throws Exception{ + String endTime) throws VTPException, IOException { List<String> args = new ArrayList<>(); - args.addAll(Arrays.asList(new String[] { + args.addAll(Arrays.asList( PRODUCT_ARG, OPEN_CLI, "execution-list", FORMAT, "json" - })); + )); if (startTime != null && !startTime.isEmpty()) { args.add("--start-time"); @@ -337,18 +341,18 @@ public class VTPExecutionResource extends VTPResource{ @ApiParam("Test profile name") @QueryParam("profileName") String profileName, @ApiParam("Test execution start time") @QueryParam("startTime") String startTime, @ApiParam("Test execution end time") @QueryParam("endTime") String endTime - ) throws Exception { + ) throws VTPException, IOException { return Response.ok(this.listTestExecutionsHandler( requestId, scenario, testsuiteName, testcaseName, profileName, startTime, endTime).getExecutions().toString(), MediaType.APPLICATION_JSON).build(); } public VTPTestExecution getTestExecutionHandler( - String executionId) throws Exception{ + String executionId) throws VTPException, IOException { List<String> args = new ArrayList<>(); - args.addAll(Arrays.asList(new String[] { + args.addAll(Arrays.asList( PRODUCT_ARG, OPEN_CLI, "execution-show", "--execution-id", executionId, FORMAT, "json" - })); + )); JsonElement result = this.makeRpcAndGetJson(args); @@ -418,7 +422,7 @@ public class VTPExecutionResource extends VTPResource{ response = VTPError.class) }) public Response getTestExecution( @ApiParam("Test execution Id") @PathParam("executionId") String executionId - ) throws Exception { + ) throws VTPException, IOException { return Response.ok(this.getTestExecutionHandler(executionId).toString(), MediaType.APPLICATION_JSON).build(); } @@ -426,9 +430,9 @@ public class VTPExecutionResource extends VTPResource{ public String getTestExecutionLogsHandler( String executionId, String action) throws VTPException { List<String> args = new ArrayList<>(); - args.addAll(Arrays.asList(new String[] { + args.addAll(Arrays.asList( PRODUCT_ARG, OPEN_CLI, "execution-show-" + action, "--execution-id", executionId, FORMAT, "text" - })); + )); Result result = this.makeRpc(args); diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/VTPScenarioResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/VTPScenarioResource.java index 29cb8f6a..4b319328 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/VTPScenarioResource.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/VTPScenarioResource.java @@ -65,9 +65,10 @@ public class VTPScenarioResource extends VTPResource{ public VTPTestScenarioList listTestScenariosHandler() throws VTPException { List<String> args = new ArrayList<>(); - args.addAll(Arrays.asList(new String[] { + args.addAll(Arrays.asList( PRODUCT_ARG, OPEN_CLI, "product-list", FORMAT, "json" - })); + )); + JsonElement results = null; try { @@ -113,9 +114,9 @@ public class VTPScenarioResource extends VTPResource{ public VTPTestSuiteList listTestSutiesHandler(String scenario) throws VTPException { List<String> args = new ArrayList<>(); - args.addAll(Arrays.asList(new String[] { + args.addAll(Arrays.asList( PRODUCT_ARG, OPEN_CLI, "service-list", PRODUCT_ARG, scenario, FORMAT, "json" - })); + )); JsonElement results = null; try { @@ -158,9 +159,9 @@ public class VTPScenarioResource extends VTPResource{ public VTPTestCaseList listTestcasesHandler(String testSuiteName, String scenario) throws VTPException { List<String> args = new ArrayList<>(); - args.addAll(Arrays.asList(new String[] { + args.addAll(Arrays.asList( PRODUCT_ARG, OPEN_CLI, "schema-list", PRODUCT_ARG, scenario, FORMAT, "json" - })); + )); if (testSuiteName != null) { args.add("--service"); args.add(testSuiteName); @@ -209,9 +210,9 @@ public class VTPScenarioResource extends VTPResource{ public VTPTestCase getTestcaseHandler(String scenario, String testSuiteName, String testCaseName) throws VTPException { List<String> args = new ArrayList<>(); - args.addAll(Arrays.asList(new String[] { + args.addAll(Arrays.asList( PRODUCT_ARG, OPEN_CLI, "schema-show", PRODUCT_ARG, scenario, "--service", testSuiteName, "--command", testCaseName , FORMAT, "json" - })); + )); JsonElement results = null; try { results = this.makeRpcAndGetJson(args); diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/common/MarketplaceResourceTypeTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/common/MarketplaceResourceTypeTest.java index 24c20eb1..f352820c 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/common/MarketplaceResourceTypeTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/common/MarketplaceResourceTypeTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.*; public class MarketplaceResourceTypeTest { @Test public void testEnum() { - MarketplaceResourceType.getType("SERVICETEMPLATE"); + assertNotNull(MarketplaceResourceType.getType("SERVICETEMPLATE")); } }
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeExceptionTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeExceptionTest.java index 01bd7c31..b9a82845 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeExceptionTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeExceptionTest.java @@ -32,11 +32,12 @@ public class ErrorCodeExceptionTest { public void testConstructor() { ErrorCodeException e2 = new ErrorCodeException(0, null); + assertNotNull(e2); } @Test public void testGet() { - e1.getErrorCode(); + assertEquals(0, e1.getErrorCode()); } }
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/MarketplaceResourceExceptionTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/MarketplaceResourceExceptionTest.java index df386060..9e235815 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/MarketplaceResourceExceptionTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/MarketplaceResourceExceptionTest.java @@ -29,6 +29,6 @@ public class MarketplaceResourceExceptionTest { @Test public void testGetter() { - marketplaceResourceException.getErrcode(); + assertEquals(0, marketplaceResourceException.getErrcode()); } }
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbDetailsTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbDetailsTest.java index a1544778..e002bdcc 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbDetailsTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbDetailsTest.java @@ -24,7 +24,7 @@ public class MsbDetailsTest { @Test public void testGetDefaultServer() { - msbDetails.getDefaultServer(); + assertNull(msbDetails.getDefaultServer()); } }
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutorTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutorTest.java index 0732b3f7..21535f67 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutorTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutorTest.java @@ -29,6 +29,7 @@ import org.onap.vnfsdk.marketplace.rest.RestResponse; import org.onap.vnfsdk.marketplace.rest.RestfulClient; import static org.mockito.Mockito.mock; +import static org.junit.Assert.assertNotNull; public class LifecycleTestExceutorTest { private LifecycleTestExceutor lifecycleTestExceutor; @@ -102,7 +103,7 @@ public class LifecycleTestExceutorTest { onBoradingRequest.setPackagePath(""); onBoradingRequest.setPackageName("huawei"); onBoradingRequest.setCsarIdCatalouge("catalog"); - LifecycleTestExceutor.uploadPackageToCatalouge(onBoradingRequest); + assertNotNull(LifecycleTestExceutor.uploadPackageToCatalouge(onBoradingRequest)); } public void testExeclifecycleTest() { diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHookTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHookTest.java index 64dc19ca..2e238f8f 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHookTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHookTest.java @@ -31,10 +31,11 @@ public class LifecycleTestHookTest { lifecycleTestHook= new LifecycleTestHook(); onBoradingRequest = mock(OnBoradingRequest.class); } - @Test + + @Test(expected = NullPointerException.class) public void testExec() { - // lifecycleTestHook.exec(onBoradingRequest); + lifecycleTestHook.exec(onBoradingRequest); } }
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandlerTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandlerTest.java index 9377e367..9a79e8f8 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandlerTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandlerTest.java @@ -36,7 +36,7 @@ public class OnBoardingHandlerTest { onboardinghandler = new OnBoardingHandler(); } @Test - public void testhandleOnBoardingReq() { + public void testhandleOnBoardingReq() { //NOSONAR onboardinghandler.handleOnBoardingReq(null); onboardinghandler.handleOnBoardingReq(onBoardingReq); when(onBoardingReq.getPackageName()).thenReturn("abc"); diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java index bf71dfea..99439563 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java @@ -680,6 +680,7 @@ public class PackageResourceTest { try { response = PackageWrapper.getInstance().getOperResultByOperTypeId(csarID, operTypeId); + assertNotNull(response); } catch(Exception e) { e.printStackTrace(); } @@ -1012,6 +1013,7 @@ public class PackageResourceTest { public void testGetOOprStatusSuccess() { try { response = packageResource.getOperStatus(null, null); + assertNotNull(response); } catch(Exception e) { e.printStackTrace(); } @@ -1050,6 +1052,7 @@ public class PackageResourceTest { }; try { response = packageResource.updateValidateStatus(request, null); + assertNotNull(response); } catch(Exception e) { e.printStackTrace(); } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestfulClientTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestfulClientTest.java index 177baa93..4be3120c 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestfulClientTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestfulClientTest.java @@ -44,17 +44,17 @@ public class RestfulClientTest { @Test public void testGet() { - RestfulClient.get("172.11.10.22,1212", 1211, "http://localhost"); + assertNotNull(RestfulClient.get("172.11.10.22,1212", 1211, "http://localhost")); } @Test public void testPost() { - RestfulClient.post("172.11.10.22,1212", 1211, "http://localhost", null); + assertNotNull(RestfulClient.post("172.11.10.22,1212", 1211, "http://localhost", null)); } @Test public void testDelete() { - RestfulClient.delete("172.11.10.22,1212", 1211, "http://localhost"); + assertNotNull(RestfulClient.delete("172.11.10.22,1212", 1211, "http://localhost")); } @Test @@ -69,7 +69,7 @@ public class RestfulClientTest { @Test public void testExecuteHttp() throws Exception{ - RestfulClient.executeHttp(PUT, "172.11.10.22,1212", 1211, "http://localhost", null); + assertNotNull(RestfulClient.executeHttp(PUT, "172.11.10.22,1212", 1211, "http://localhost", null)); /*HttpResponse httpResponse = mock(HttpResponse.class); CloseableHttpClient httpclient= mock(CloseableHttpClient.class); HttpEntity httpEntity= mock(HttpEntity.class); diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/VTPExecutionResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/VTPExecutionResourceTest.java index 74f2d515..c1a28303 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/VTPExecutionResourceTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/VTPExecutionResourceTest.java @@ -125,4 +125,9 @@ public class VTPExecutionResourceTest { bodyParts.add(formDataBodyPart); vtpExecutionResource.executeTestcases(requestId,bodyParts,"exeJson") ; } + + @Test(expected = Exception.class) + public void testGetTestExecutionLogsHandler() throws Exception { + assertNotNull(vtpExecutionResource.getTestExecutionLogsHandler("1234", "action")); + } }
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/execution/VTPExecutionResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/execution/VTPExecutionResourceTest.java index 9dfb7567..661f51a1 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/execution/VTPExecutionResourceTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/execution/VTPExecutionResourceTest.java @@ -319,6 +319,6 @@ public class VTPExecutionResourceTest { vtpExecutionResource = new VTPExecutionResource(); String execJson = "[{\"scenario\":\"tutorial\",\"testCaseName\":\"list-users\",\"testSuiteName\":\"ut\"," + "\"requestId\":\"1234567890\",\"executionId\":\"123\",\"profile\":\"http\"}]"; - vtpExecutionResource.executeTestcases(requestId,null,"exeJson") ; + assertEquals(200, vtpExecutionResource.executeTestcases(requestId,null,"exeJson").getStatus()); } } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java index 1da85f4d..2a749f12 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.util.List; import static org.junit.Assert.*; +import org.onap.vtp.scenario.model.VTPTestCase; public class VTPScenarioResourceTest { @@ -78,7 +79,8 @@ public class VTPScenarioResourceTest { } }; - vtpScenarioResource.listTestcasesHandler("testsuite", "open-cli"); + VTPTestCase vtpTestCases = vtpScenarioResource.listTestcasesHandler("testsuite", "open-cli").getTestCases().get(0); + assertEquals("list-users", vtpTestCases.getTestCaseName()); } public void testListTestcases() throws Exception { |