summaryrefslogtreecommitdiffstats
path: root/vnfmarket-be
diff options
context:
space:
mode:
authorjitendra007 <jitendra.sharma1@huawei.com>2020-07-01 18:10:28 +0530
committerjitendra007 <jitendra.sharma1@huawei.com>2020-07-31 12:23:10 +0530
commit8632400327b5fc7a5ca5b1b989e79c0afbb63686 (patch)
treef567be4c8e3431e5638a48d1ee75a745f2db175c /vnfmarket-be
parent5d0772d1fe1ec0e704008f668456491b897e4414 (diff)
Fix sonar issues for vnfsdk
Issue-ID: VNFSDK-608 Signed-off-by: jitendra007 <jitendra.sharma1@huawei.com> Change-Id: I7a64c18fb9889f06dcd52a1baaf91c7b312657bb
Diffstat (limited to 'vnfmarket-be')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/http/ToolUtil.java10
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java28
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java21
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/VTPScenarioResource.java29
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfigTest.java2
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/filemanage/FileManageTest.java6
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbServerTest.java4
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReqTest.java6
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java12
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java140
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestResponseTest.java2
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPErrorTest.java6
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestCaseTest.java24
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestScenarioTest.java8
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestSuiteTest.java4
15 files changed, 161 insertions, 141 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/http/ToolUtil.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/http/ToolUtil.java
index 48a7d0ca..c199a0e1 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/http/ToolUtil.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/http/ToolUtil.java
@@ -74,7 +74,9 @@ public class ToolUtil {
{
File destDir = new File(destDirName);
if (destDir.exists() && overlay) {
- new File(destDirName).delete();
+ if (!new File(destDirName).delete()) {
+ LOGGER.error("failed to delete file in createDestDir()");
+ }
} else if (destDir.exists() && !overlay) {
return false;
}
@@ -154,7 +156,8 @@ public class ToolUtil {
File destFile = new File(destFileName);
if (destFile.exists() && overlay) {
- new File(destFileName).delete();
+ if(!new File(destFileName).delete())
+ LOGGER.error("failed to delete file in copyFile()");
} else if (!destFile.exists() && !destFile.getParentFile().exists() && !destFile.getParentFile().mkdirs()) {
return false;
}
@@ -174,7 +177,8 @@ public class ToolUtil {
}
File dir = new File(useDestDirName);
if (dir.exists()) {
- dir.delete();
+ if(!dir.delete())
+ LOGGER.error("failed to delete file in createDir()");
}
return dir.mkdirs();
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 9f9974e0..ac0f97cc 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
@@ -93,8 +93,8 @@ public class PackageWrapperUtil {
public static boolean isUploadEnd(String contentRange) {
String range = contentRange;
range = range.replace("bytes", "").trim();
- range = range.substring(0, range.indexOf("/"));
- String size = contentRange.substring(contentRange.indexOf("/") + 1, contentRange.length()).trim();
+ range = range.substring(0, range.indexOf('/'));
+ String size = contentRange.substring(contentRange.indexOf('/') + 1, contentRange.length()).trim();
int fileSize = Integer.parseInt(size);
String[] ranges = range.split("-");
int endPosition = Integer.parseInt(ranges[1]) + 1;
@@ -186,7 +186,7 @@ public class PackageWrapperUtil {
* @return package name
*/
public static String getPackageName(String ftpUrl) {
- int index = ftpUrl.lastIndexOf("/");
+ int index = ftpUrl.lastIndexOf('/');
return ftpUrl.substring(index);
}
@@ -325,18 +325,18 @@ public class PackageWrapperUtil {
continue;
}
- int count1 = tempString.indexOf(":");
+ int count1 = tempString.indexOf(':');
String meta = tempString.substring(0, count1).trim();
// Check for the package provider name
if(meta.equalsIgnoreCase(CommonConstant.CSAR_PROVIDER_META)) {
- int count = tempString.indexOf(":") + 1;
+ int count = tempString.indexOf(':') + 1;
basicInfo.setProvider(tempString.substring(count).trim());
}
// Check for package version
if(meta.equalsIgnoreCase(CommonConstant.CSAR_VERSION_META)) {
- int count = tempString.indexOf(":") + 1;
+ int count = tempString.indexOf(':') + 1;
basicInfo.setVersion(tempString.substring(count).trim());
}
@@ -358,23 +358,23 @@ public class PackageWrapperUtil {
private static EnumType getEnumType(String type) {
EnumType vnfType = EnumType.CSAR;
- if(type == "CSAR") {
+ if("CSAR".equals(type)) {
vnfType = EnumType.CSAR;
}
- if(type == "GSAR") {
+ if("GSAR".equals(type)) {
vnfType = EnumType.GSAR;
}
- if(type == "NSAR") {
+ if("NSAR".equals(type)) {
vnfType = EnumType.NSAR;
}
- if(type == "SSAR") {
+ if("SSAR".equals(type)) {
vnfType = EnumType.SSAR;
}
- if(type == "NFAR") {
+ if("NFAR".equals(type)) {
vnfType = EnumType.NFAR;
}
@@ -396,18 +396,18 @@ public class PackageWrapperUtil {
continue;
}
- int count1 = tempString.indexOf(":");
+ int count1 = tempString.indexOf(':');
String meta = tempString.substring(0, count1).trim();
// Check for the package provider name
if(meta.equalsIgnoreCase(CommonConstant.MF_PROVIDER_META)) {
- int count = tempString.indexOf(":") + 1;
+ int count = tempString.indexOf(':') + 1;
basicInfo.setProvider(tempString.substring(count).trim());
}
// Check for package version
if(meta.equalsIgnoreCase(CommonConstant.MF_VERSION_META)) {
- int count = tempString.indexOf(":") + 1;
+ int count = tempString.indexOf(':') + 1;
basicInfo.setVersion(tempString.substring(count).trim());
}
}
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 77888c27..eb43b937 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
@@ -85,6 +85,11 @@ public class VTPExecutionResource extends VTPResource{
private static final String INPUT = "input";
private static final String ERROR = "error";
private static final String FILE = "file://";
+ private static final String EXCEPTION_OCCURS ="Exception occurs";
+ private static final String PRODUCT_ARG="--product";
+ private static final String OPEN_CLI="open-cli";
+ private static final String FORMAT="--format";
+
private static Gson gson = new Gson();
public VTPTestExecutionList executeHandler(VTPTestExecutionList executions, String requestId) throws VTPException {
@@ -124,14 +129,14 @@ public class VTPExecutionResource extends VTPResource{
try {
execution.setResults(jsonParser.parse(m.get(ERROR)));
} catch (Exception e) { //NOSONAR
- LOG.error("Exception occurs",e);
+ LOG.error(EXCEPTION_OCCURS,e);
}
}
else if (m.containsKey("results")) {
try {
execution.setResults(jsonParser.parse(m.get("results")));
} catch (Exception e) { //NOSONAR
- LOG.error("Exception occurs",e);
+ LOG.error(EXCEPTION_OCCURS,e);
}
}
}
@@ -210,7 +215,7 @@ public class VTPExecutionResource extends VTPResource{
executions.setExecutions(
gson.fromJson(executionsJson, new TypeToken<List<VTPTestExecution>>(){}.getType()));
} catch (Exception e) { //NOSONAR
- LOG.error("Exception occurs",e);
+ LOG.error(EXCEPTION_OCCURS,e);
}
executions = this.executeHandler(executions, requestId);
@@ -236,7 +241,7 @@ public class VTPExecutionResource extends VTPResource{
String endTime) throws Exception{
List<String> args = new ArrayList<>();
args.addAll(Arrays.asList(new String[] {
- "--product", "open-cli", "execution-list", "--format", "json"
+ PRODUCT_ARG, OPEN_CLI, "execution-list", FORMAT, "json"
}));
if (startTime != null && !startTime.isEmpty()) {
@@ -260,7 +265,7 @@ public class VTPExecutionResource extends VTPResource{
}
if (scenario != null && !scenario.isEmpty()) {
- args.add("--product");
+ args.add(PRODUCT_ARG);
args.add(scenario);
}
@@ -342,7 +347,7 @@ public class VTPExecutionResource extends VTPResource{
String executionId) throws Exception{
List<String> args = new ArrayList<>();
args.addAll(Arrays.asList(new String[] {
- "--product", "open-cli", "execution-show", "--execution-id", executionId, "--format", "json"
+ PRODUCT_ARG, OPEN_CLI, "execution-show", "--execution-id", executionId, FORMAT, "json"
}));
@@ -389,7 +394,7 @@ public class VTPExecutionResource extends VTPResource{
resultJson = jsonParser.parse(resultObj.get(OUTPUT).toString());
}
} catch (Exception e) {
- LOG.error("Exception occurs", e);
+ LOG.error(EXCEPTION_OCCURS, e);
JsonObject node = new JsonObject();
node.addProperty(ERROR, resultObj.get(OUTPUT).toString());
resultJson = node;
@@ -422,7 +427,7 @@ public class VTPExecutionResource extends VTPResource{
String executionId, String action) throws VTPException {
List<String> args = new ArrayList<>();
args.addAll(Arrays.asList(new String[] {
- "--product", "open-cli", "execution-show-" + action, "--execution-id", executionId, "--format", "text"
+ PRODUCT_ARG, OPEN_CLI, "execution-show-" + action, "--execution-id", executionId, FORMAT, "text"
}));
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 47a7696d..29cb8f6a 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
@@ -57,18 +57,23 @@ import io.swagger.annotations.ApiResponses;
@Api(tags = {"VTP Scenario"})
public class VTPScenarioResource extends VTPResource{
private static final String DESCRIPTION = "description";
+ private static final String PRODUCT_ARG="--product";
+ private static final String OPEN_CLI="open-cli";
+ private static final String FORMAT="--format";
+ private static final String IO_EXCEPTION_OCCURS ="IOException occurs";
+ private static final String SERVICE="service";
public VTPTestScenarioList listTestScenariosHandler() throws VTPException {
List<String> args = new ArrayList<>();
args.addAll(Arrays.asList(new String[] {
- "--product", "open-cli", "product-list", "--format", "json"
+ PRODUCT_ARG, OPEN_CLI, "product-list", FORMAT, "json"
}));
JsonElement results = null;
try {
results = this.makeRpcAndGetJson(args);
} catch (IOException e) {
- LOG.error("IOException occurs",e);
+ LOG.error(IO_EXCEPTION_OCCURS,e);
}
VTPTestScenarioList list = new VTPTestScenarioList();
@@ -81,7 +86,7 @@ public class VTPScenarioResource extends VTPResource{
if (n.entrySet().iterator().hasNext()) {
String name = n.get("product").getAsString();
- if ("open-cli".equalsIgnoreCase(name))
+ if (OPEN_CLI.equalsIgnoreCase(name))
continue;
list.getScenarios().add(new VTPTestScenario().setName(name).setDescription(
@@ -109,14 +114,14 @@ public class VTPScenarioResource extends VTPResource{
List<String> args = new ArrayList<>();
args.addAll(Arrays.asList(new String[] {
- "--product", "open-cli", "service-list", "--product", scenario, "--format", "json"
+ PRODUCT_ARG, OPEN_CLI, "service-list", PRODUCT_ARG, scenario, FORMAT, "json"
}));
JsonElement results = null;
try {
results = this.makeRpcAndGetJson(args);
} catch (IOException e) {
- LOG.error("IOException occurs",e);
+ LOG.error(IO_EXCEPTION_OCCURS,e);
}
VTPTestSuiteList list = new VTPTestSuiteList();
@@ -127,7 +132,7 @@ public class VTPScenarioResource extends VTPResource{
JsonElement jsonElement = it.next();
JsonObject n = jsonElement.getAsJsonObject();
if (n.entrySet().iterator().hasNext()) {
- list.getSuites().add(new VTPTestSuite().setName(n.get("service").getAsString()).setDescription(
+ list.getSuites().add(new VTPTestSuite().setName(n.get(SERVICE).getAsString()).setDescription(
n.get(DESCRIPTION).getAsString()));
}
}
@@ -154,7 +159,7 @@ public class VTPScenarioResource extends VTPResource{
List<String> args = new ArrayList<>();
args.addAll(Arrays.asList(new String[] {
- "--product", "open-cli", "schema-list", "--product", scenario, "--format", "json"
+ PRODUCT_ARG, OPEN_CLI, "schema-list", PRODUCT_ARG, scenario, FORMAT, "json"
}));
if (testSuiteName != null) {
args.add("--service");
@@ -165,7 +170,7 @@ public class VTPScenarioResource extends VTPResource{
try {
results = this.makeRpcAndGetJson(args);
} catch (IOException e) {
- LOG.error("IOException occurs",e);
+ LOG.error(IO_EXCEPTION_OCCURS,e);
}
VTPTestCaseList list = new VTPTestCaseList();
@@ -179,7 +184,7 @@ public class VTPScenarioResource extends VTPResource{
list.getTestCases().add(
new VTPTestCase().setTestCaseName(
n.get("command").getAsString()).setTestSuiteName(
- n.get("service").getAsString()));
+ n.get(SERVICE).getAsString()));
}
}
@@ -205,13 +210,13 @@ 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[] {
- "--product", "open-cli", "schema-show", "--product", scenario, "--service", testSuiteName, "--command", testCaseName , "--format", "json"
+ PRODUCT_ARG, OPEN_CLI, "schema-show", PRODUCT_ARG, scenario, "--service", testSuiteName, "--command", testCaseName , FORMAT, "json"
}));
JsonElement results = null;
try {
results = this.makeRpcAndGetJson(args);
} catch (IOException e) {
- LOG.error("IOException occurs",e);
+ LOG.error(IO_EXCEPTION_OCCURS,e);
}
JsonObject schema = results.getAsJsonObject().getAsJsonObject("schema");
@@ -219,7 +224,7 @@ public class VTPScenarioResource extends VTPResource{
VTPTestCase tc = new VTPTestCase();
tc.setTestCaseName(schema.get("name").getAsString());
tc.setDescription(schema.get(DESCRIPTION).getAsString());
- tc.setTestSuiteName(schema.get("service").getAsString());
+ tc.setTestSuiteName(schema.get(SERVICE).getAsString());
tc.setAuthor(schema.get("author").getAsString());
JsonElement inputsJson = schema.get("inputs");
if (inputsJson != null && inputsJson.isJsonArray()) {
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfigTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfigTest.java
index cd74b4aa..d8855f6a 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfigTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfigTest.java
@@ -30,6 +30,6 @@ public class HttpServerPathConfigTest {
public void testGetterSetter()
{
HttpServerPathConfig.setHttpServerPath("csi");
- assertEquals(HttpServerPathConfig.getHttpServerPath(),"csi");
+ assertEquals("csi",HttpServerPathConfig.getHttpServerPath());
}
} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/filemanage/FileManageTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/filemanage/FileManageTest.java
index 75d221c7..116e549d 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/filemanage/FileManageTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/filemanage/FileManageTest.java
@@ -90,7 +90,7 @@ public class FileManageTest {
FileManager ManagerImpl = FileManagerFactory.createFileManager();
String dstPath = "./dstPathForTest";
- assertEquals(ManagerImpl.delete(dstPath), true);
+ assertEquals(true,ManagerImpl.delete(dstPath));
}
@Test
@@ -112,7 +112,7 @@ public class FileManageTest {
String srcPath = "./srcPathForTest";
String dstPath = "./dstPathForTest";
- assertEquals(ManagerImpl.upload(srcPath, dstPath), true);
+ assertEquals(true,ManagerImpl.upload(srcPath, dstPath) );
File srcDir = new File(srcPath);
if (srcDir.exists())
@@ -120,7 +120,7 @@ public class FileManageTest {
ManagerImpl.delete(srcPath);
}
- assertEquals(ManagerImpl.upload(srcPath, dstPath), false);
+ assertEquals(false,ManagerImpl.upload(srcPath, dstPath) );
}
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbServerTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbServerTest.java
index cac8557e..a88bcf72 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbServerTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbServerTest.java
@@ -30,8 +30,8 @@ public class MsbServerTest {
public void testSetterGetter()
{
msbServer.setHost("csi");
- assertEquals(msbServer.getHost(),"csi");
+ assertEquals("csi",msbServer.getHost());
msbServer.setPort("123");
- assertEquals(msbServer.getPort(),"123");
+ assertEquals("123",msbServer.getPort());
}
} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReqTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReqTest.java
index bcbfcf29..99eb96fb 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReqTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReqTest.java
@@ -31,10 +31,10 @@ public class LifeCycleTestReqTest {
public void testEstterGetter()
{
lifeCycleTestReq.setCsarId("csi");
- assertEquals(lifeCycleTestReq.getCsarId(),"csi");
+ assertEquals("csi",lifeCycleTestReq.getCsarId());
lifeCycleTestReq.setLabVimId("csi");
- assertEquals(lifeCycleTestReq.getLabVimId(),"csi");
+ assertEquals("csi",lifeCycleTestReq.getLabVimId());
lifeCycleTestReq.setVimIds(null);
- assertEquals(lifeCycleTestReq.getVimIds(),null);
+ assertEquals(null,lifeCycleTestReq.getVimIds());
}
} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java
index a273d31b..0f04f288 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java
@@ -30,11 +30,11 @@ public class ValidateLifecycleTestResponseTest {
@Test
public void testSetterGetter()
{
- validateLifecycleTestResponse.setJobId("huawei");
- assertEquals(validateLifecycleTestResponse.getJobId(),"huawei");
- validateLifecycleTestResponse.setLifecycleStatus("huawei");
- assertEquals(validateLifecycleTestResponse.getLifecycleStatus(),"huawei");
- validateLifecycleTestResponse.setValidateStatus("huawei");
- assertEquals(validateLifecycleTestResponse.getValidateStatus(),"huawei");
+ validateLifecycleTestResponse.setJobId("abc");
+ assertEquals("abc",validateLifecycleTestResponse.getJobId());
+ validateLifecycleTestResponse.setLifecycleStatus("abc");
+ assertEquals("abc",validateLifecycleTestResponse.getLifecycleStatus());
+ validateLifecycleTestResponse.setValidateStatus("abc");
+ assertEquals("abc",validateLifecycleTestResponse.getValidateStatus());
}
} \ No newline at end of file
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 19bbe692..2ecb5a76 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
@@ -19,7 +19,6 @@ package org.onap.vnfsdk.marketplace.resource;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -79,6 +78,8 @@ import org.open.infc.grpc.client.OpenRemoteCli;
import mockit.Mock;
import mockit.MockUp;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
public class PackageResourceTest {
@@ -1145,10 +1146,10 @@ public class PackageResourceTest {
onBoardResultObj.setCsarId("csrId");
onBoardResultObj.setOperStatus(1);
boolean res = FileUtil.writeJsonDatatoFile(filePath, onBoardResultObj);
- assertEquals(res, true);
+ assertTrue(res);
String filePath1 = "src//test//resources";
res = FileUtil.writeJsonDatatoFile(filePath1, onBoardResultObj);
- assertEquals(res, false);
+ assertFalse(res);
}
@@ -1157,7 +1158,7 @@ public class PackageResourceTest {
public void testCreateDirectory() {
String dirPath = "src//test//resources//TestDirectory";
boolean res = FileUtil.createDirectory(dirPath);
- assertEquals(res, true);
+ assertTrue(res);
}
@Test
@@ -1165,10 +1166,10 @@ public class PackageResourceTest {
public void testDeleteDirectory() {
String dirPath = "src//test//resources//TestDirectory";
boolean res = FileUtil.deleteFile(dirPath);
- assertEquals(res, true);
+ assertTrue(res);
String dirPath1 = "src//test//resources11";
res = FileUtil.deleteFile(dirPath1);
- assertEquals(res, true);
+ assertTrue(res);
}
@@ -1182,9 +1183,9 @@ public class PackageResourceTest {
@Test
public void testisNotEmpty() {
boolean res = MarketplaceDbUtil.isNotEmpty(null);
- assertEquals(res, false);
+ assertFalse(res);
res = MarketplaceDbUtil.isNotEmpty("test");
- assertEquals(res, true);
+ assertTrue(res);
}
@Test
@@ -1199,43 +1200,43 @@ public class PackageResourceTest {
@Test
public void testisEmptyString() {
boolean res = ToolUtil.isEmptyString(null);
- assertEquals(res, true);
+ assertTrue(res);
res = ToolUtil.isEmptyString("huawei");
- assertEquals(res, false);
+ assertFalse(res);
}
@Test
public void testisTrimedEmptyString() {
boolean res = ToolUtil.isTrimedEmptyString(null);
- assertEquals(res, true);
+ assertTrue(res);
res = ToolUtil.isTrimedEmptyString(" huawei ");
- assertEquals(res, false);
+ assertFalse(res);
}
@Test
public void testisTrimedEmptyArray() {
boolean res = ToolUtil.isTrimedEmptyArray(null);
- assertEquals(res, true);
+ assertTrue(res);
String[] String1={"hua","wei"};
res = ToolUtil.isTrimedEmptyArray(String1);
- assertEquals(res, false);
+ assertFalse(res);
}
@Test
public void testisEmptyCollection() {
ArrayList arr1 = new ArrayList();
boolean res = ToolUtil.isEmptyCollection(arr1);
- assertEquals(res, true);
+ assertTrue(res);
arr1.add("huawei");
res = ToolUtil.isEmptyCollection(arr1);
- assertEquals(res, false);
+ assertFalse(res);
}
@Test
public void testisYamlFile() {
File fileObj = new File("test.yaml");
boolean res = ToolUtil.isYamlFile(fileObj);
- assertEquals(res, true);
+ assertTrue(res);
}
@Test
@@ -1281,13 +1282,13 @@ public class PackageResourceTest {
@Test
public void testremoveCsarSuffix() {
String res = ToolUtil.removeCsarSuffix("abc.csar");
- assertEquals(res, "abc");
+ assertEquals("abc", res);
}
@Test
public void testformatCsar() {
String res = ToolUtil.formatCsar("abc");
- assertEquals(res, "abc.csar");
+ assertEquals("abc.csar", res);
}
@Test
@@ -1301,7 +1302,7 @@ public class PackageResourceTest {
// depending
// on
// Locale
- assertEquals(res, expected);
+ assertEquals(expected, res);
}
@Test
@@ -1314,19 +1315,19 @@ public class PackageResourceTest {
@Test
public void testgetCatalogueCsarPath() {
String res = ToolUtil.getCatalogueCsarPath();
- assertEquals(res, File.separator + "csar");
+ assertEquals(File.separator + "csar", res);
}
@Test
public void testgetCatalogueImagePath() {
String res = ToolUtil.getCatalogueImagePath();
- assertEquals(res, File.separator + "image");
+ assertEquals(File.separator + "image", res);
}
@Test
public void testdeleteFile() {
boolean res = ToolUtil.deleteFile("src//test//resources", "test1.txt");
- assertEquals(res, true);
+ assertTrue(res);
}
@Test
@@ -1336,7 +1337,7 @@ public class PackageResourceTest {
String res = ToolUtil.storeChunkFileInLocal("src//test//resources", "TestOut.txt", inputStream);
File file = new File(res);
String fileName = file.getName();
- assertEquals(fileName, "TestOut.txt");
+ assertEquals("TestOut.txt", fileName);
} catch(Exception ex) {
ex.printStackTrace();
@@ -1347,7 +1348,7 @@ public class PackageResourceTest {
public void testToolUtildeleteFile() {
boolean res = ToolUtil.deleteFile("src/test/resources", "TestOut.txt");
- assertEquals(res, true);
+ assertTrue(res);
}
@@ -1375,13 +1376,13 @@ public class PackageResourceTest {
public void testvalidateFile() {
File fileData= null;
boolean res = FileUtil.validateFile(fileData);
- assertEquals(res, false);
+ assertFalse(res);
}
@Test
public void testGetPkgSize() {
long pkgSize = PackageWrapperUtil.getPacakgeSize("src/test/resources/Test.txt");
- assertNotNull(pkgSize);
+ assertTrue(pkgSize > 1);
}
@Test
@@ -1429,23 +1430,23 @@ public class PackageResourceTest {
vnfPackageObj.setDeletionPending("pending");
String res = vnfPackageObj.getVnfPackageId();
- assertEquals(res, "vnfpackageId");
+ assertEquals("vnfpackageId", res);
res = vnfPackageObj.getVnfPackageUrl();
- assertEquals(res, "vnfPackageUrl");
+ assertEquals("vnfPackageUrl", res);
res = vnfPackageObj.getVnfd();
- assertEquals(res, "vnfd");
+ assertEquals("vnfd", res);
res = vnfPackageObj.getVersion();
- assertEquals(res, "1");
+ assertEquals("1", res);
EnumUsageState state = vnfPackageObj.getUsageState();
- assertEquals(state, EnumUsageState.NOTINUSE);
+ assertEquals(EnumUsageState.NOTINUSE, state);
res = vnfPackageObj.getProvider();
- assertEquals(res, "huawei");
+ assertEquals("huawei", res);
EnumOperationalState operState = vnfPackageObj.getOperationalState();
- assertEquals(operState, EnumOperationalState.ENABLED);
+ assertEquals(EnumOperationalState.ENABLED, operState);
res = vnfPackageObj.getName();
- assertEquals(res, "vnf");
+ assertEquals("vnf", res);
res = vnfPackageObj.getDeletionPending();
- assertEquals(res, "pending");
+ assertEquals("pending", res);
}
@Test
@@ -1461,23 +1462,23 @@ public class PackageResourceTest {
csarPackageObj.setUrl("//network");
String res = csarPackageObj.getCreateTime();
- assertEquals(res, "04052017");
+ assertEquals("04052017", res);
res = csarPackageObj.getDeletionPending();
- assertEquals(res, "pending");
+ assertEquals("pending", res);
res = csarPackageObj.getFormat();
- assertEquals(res, "format");
+ assertEquals("format", res);
res = csarPackageObj.getId();
- assertEquals(res, "12");
+ assertEquals("12", res);
res = csarPackageObj.getName();
- assertEquals(res, "csartest");
+ assertEquals("csartest", res);
res = csarPackageObj.getSize();
- assertEquals(res, "10");
+ assertEquals("10", res);
res = csarPackageObj.getStatus();
- assertEquals(res, "done");
+ assertEquals("done", res);
res = csarPackageObj.getType();
- assertEquals(res, "type");
+ assertEquals("type", res);
res = csarPackageObj.getUrl();
- assertEquals(res, "//network");
+ assertEquals("//network", res);
}
@@ -1488,13 +1489,13 @@ public class PackageResourceTest {
pkgBasicInfoObj.setType(EnumType.GSAR);
pkgBasicInfoObj.setVersion("1");
String res = pkgBasicInfoObj.getFormat();
- assertEquals(res, "pdf");
+ assertEquals("pdf", res);
res = pkgBasicInfoObj.getProvider();
- assertEquals(res, "huawei");
+ assertEquals("huawei", res);
EnumType type = pkgBasicInfoObj.getType();
- assertEquals(type, EnumType.GSAR);
+ assertEquals(EnumType.GSAR, type);
res = pkgBasicInfoObj.getVersion();
- assertEquals(res, "1");
+ assertEquals("1", res);
}
@Test
@@ -1517,42 +1518,42 @@ public class PackageResourceTest {
pkgMetaObj.setVersion("1");
String res = pkgMetaObj.getCreateTime();
- assertEquals(res, "05042017");
+ assertEquals("05042017", res);
res = pkgMetaObj.getCsarId();
- assertEquals(res, "csarid");
+ assertEquals("csarid", res);
res = pkgMetaObj.getDetails();
- assertEquals(res, "details");
+ assertEquals("details", res);
res = pkgMetaObj.getDownloadCount() + "";
- assertEquals(res, "10");
+ assertEquals("10", res);
res = pkgMetaObj.getDownloadUri();
- assertEquals(res, "//network");
+ assertEquals("//network", res);
res = pkgMetaObj.getFormat();
- assertEquals(res, "pdf");
+ assertEquals("pdf", res);
res = pkgMetaObj.getModifyTime();
- assertEquals(res, "05042017");
+ assertEquals("05042017", res);
res = pkgMetaObj.getName();
- assertEquals(res, "huawei");
+ assertEquals("huawei", res);
res = pkgMetaObj.getProvider();
- assertEquals(res, "huawei");
+ assertEquals("huawei", res);
res = pkgMetaObj.getRemarks();
- assertEquals(res, "tested");
+ assertEquals("tested", res);
res = pkgMetaObj.getReport();
- assertEquals(res, "done");
+ assertEquals("done", res);
res = pkgMetaObj.getShortDesc();
- assertEquals(res, "done");
+ assertEquals("done", res);
res = pkgMetaObj.getSize();
- assertEquals(res, "1000");
+ assertEquals("1000", res);
res = pkgMetaObj.getType();
- assertEquals(res, "type");
+ assertEquals("type", res);
res = pkgMetaObj.getVersion();
- assertEquals(res, "1");
+ assertEquals("1", res);
}
@Test
public void testPackageResponseSetter() {
pkgResponseObj.setReportPath("localpath");
String res = pkgResponseObj.getReportPath();
- assertEquals(res, "localpath");
+ assertEquals("localpath", res);
}
@@ -1561,9 +1562,14 @@ public class PackageResourceTest {
csarFileUriResObj.setDownloadUri("downloaduri");
csarFileUriResObj.setLocalPath("localpath");
String res = csarFileUriResObj.getDownloadUri();
- assertEquals(res, "downloaduri");
+ assertEquals("downloaduri", res);
res = csarFileUriResObj.getLocalPath();
- assertEquals(res, "localpath");
+ assertEquals("localpath", res);
}
+ @Test
+ public void testGetPackageName() {
+ String packageName = PackageWrapperUtil.getPackageName("ftpUrl/abc");
+ assertEquals("/abc", packageName);
+ }
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestResponseTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestResponseTest.java
index 3669bbdd..e9ce22a6 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestResponseTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestResponseTest.java
@@ -34,7 +34,7 @@ public class RestResponseTest {
@Test
public void testSetterGetter() {
restResponse.setResult("{\"csarId\":\"huawei\"}");
- assertEquals(restResponse.getResult(), "{\"csarId\":\"huawei\"}");
+ assertEquals("{\"csarId\":\"huawei\"}",restResponse.getResult());
restResponse.setStatusCode(200);
assertThat(restResponse.getStatusCode(),is(200));
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPErrorTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPErrorTest.java
index 6a06a62f..f5664a7b 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPErrorTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPErrorTest.java
@@ -33,19 +33,19 @@ public class VTPErrorTest
public void testCode()
{
vtpError.setCode("0xc002");
- assertEquals(vtpError.getCode(),"0xc002");
+ assertEquals("0xc002",vtpError.getCode());
}
@Test
public void testmessage()
{
vtpError.setMessage("0xc002 ::error found");
- assertEquals(vtpError.getMessage(),"error found");
+ assertEquals("error found",vtpError.getMessage());
}
@Test
public void testHttpStatus()
{
vtpError.setHttpStatus(200);
- assertEquals(vtpError.getHttpStatus(),200);
+ assertEquals(200,vtpError.getHttpStatus());
}
@Test
public void testInnerClassMethods()
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestCaseTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestCaseTest.java
index 5e469640..d55f16b3 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestCaseTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestCaseTest.java
@@ -44,12 +44,12 @@ public class VTPTestCaseTest {
vtpTestCase.setScenario("abc");
vtpTestCase.setTestCaseName("abc");
vtpTestCase.setTestSuiteName("abc");
- assertEquals(vtpTestCase.getAuthor(),"abc");
- assertEquals(vtpTestCase.getDescription(),"abc");
+ assertEquals("abc",vtpTestCase.getAuthor());
+ assertEquals("abc",vtpTestCase.getDescription());
assertNull(vtpTestCase.getInputs());
assertNull(vtpTestCase.getOutputs());
- assertEquals(vtpTestCase.getTestCaseName(),"abc");
- assertEquals(vtpTestCase.getTestSuiteName(),"abc");
+ assertEquals("abc",vtpTestCase.getTestCaseName());
+ assertEquals("abc",vtpTestCase.getTestSuiteName());
VTPTestCase.VTPTestCaseInput vtpTestCaseInput=new VTPTestCase.VTPTestCaseInput();
vtpTestCaseInput.setDefaultValue("abc");
@@ -59,20 +59,20 @@ public class VTPTestCaseTest {
vtpTestCaseInput.setMetadata(actualObj);
vtpTestCaseInput.setName("abc");
vtpTestCaseInput.setType("abc");
- assertEquals(vtpTestCaseInput.getDefaultValue(),"abc");
- assertEquals(vtpTestCaseInput.getDescription(),"abc");
- assertEquals(vtpTestCaseInput.getIsOptional(),true);
+ assertEquals("abc",vtpTestCaseInput.getDefaultValue());
+ assertEquals("abc",vtpTestCaseInput.getDescription());
+ assertEquals(true,vtpTestCaseInput.getIsOptional());
assertEquals(vtpTestCaseInput.getMetadata(),actualObj);
- assertEquals(vtpTestCaseInput.getName(),"abc");
- assertEquals(vtpTestCaseInput.getType(),"abc");
+ assertEquals("abc",vtpTestCaseInput.getName());
+ assertEquals("abc",vtpTestCaseInput.getType());
//
VTPTestCase.VTPTestCaseOutput vtpTestCaseOutput=new VTPTestCase.VTPTestCaseOutput();
vtpTestCaseOutput.setDescription("abc");
vtpTestCaseOutput.setName("abc");
vtpTestCaseOutput.setType("abc");
- assertEquals(vtpTestCaseOutput.getDescription(),"abc");
- assertEquals(vtpTestCaseOutput.getName(),"abc");
- assertEquals(vtpTestCaseOutput.getType(),"abc");
+ assertEquals("abc",vtpTestCaseOutput.getDescription());
+ assertEquals("abc",vtpTestCaseOutput.getName());
+ assertEquals("abc",vtpTestCaseOutput.getType());
}
} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestScenarioTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestScenarioTest.java
index 6e715647..513b30a5 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestScenarioTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestScenarioTest.java
@@ -16,8 +16,8 @@
package org.onap.vtp.scenario.model;
import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
+import static org.junit.Assert.assertNull;
public class VTPTestScenarioTest {
VTPTestScenario vtpTestScenario= new VTPTestScenario();
@@ -26,11 +26,11 @@ public class VTPTestScenarioTest {
{
vtpTestScenario.setDescription("abc");
vtpTestScenario.setName("abc");
- assertEquals(vtpTestScenario.getDescription(),"abc");
- assertEquals(vtpTestScenario.getName(),"abc");
+ assertEquals("abc", vtpTestScenario.getDescription());
+ assertEquals("abc", vtpTestScenario.getName());
VTPTestScenario.VTPTestScenarioList vtpTestScenarioList= new VTPTestScenario.VTPTestScenarioList();
vtpTestScenarioList.setScenarios(null);
- assertEquals(vtpTestScenarioList.getScenarios(),null);
+ assertNull(vtpTestScenarioList.getScenarios());
}
} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestSuiteTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestSuiteTest.java
index 0fc0eeb8..452d25aa 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestSuiteTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/model/VTPTestSuiteTest.java
@@ -26,8 +26,8 @@ VTPTestSuite vtpTestSuite= new VTPTestSuite();
{
vtpTestSuite.setDescription("abc");
vtpTestSuite.setName("abc");
- assertEquals(vtpTestSuite.getDescription(),"abc");
- assertEquals(vtpTestSuite.getName(),"abc");
+ assertEquals("abc",vtpTestSuite.getDescription());
+ assertEquals("abc",vtpTestSuite.getName());
VTPTestSuite.VTPTestSuiteList vtpTestSuiteList=new VTPTestSuite.VTPTestSuiteList();
vtpTestSuiteList.setSuites(null);
assertNull(vtpTestSuiteList.getSuites());