summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPriyank Maheshwari <priyank.maheshwari@est.tech>2023-02-21 09:37:05 +0000
committerGerrit Code Review <gerrit@onap.org>2023-02-21 09:37:05 +0000
commit1450fd0687433278ce61ae56dfcbf42e0edddce3 (patch)
tree0d8dcbce774ace231e62e8b5e1220e472756bb12
parentde8116f521f5be6b817e0c86bfe7909dcd13b475 (diff)
parente59d6068616ea32d9c8074ea11241def2de34588 (diff)
Merge "Fix sonar code smell"
-rw-r--r--cps-rest/src/main/java/org/onap/cps/rest/utils/ZipFileSizeValidator.java6
-rw-r--r--cps-rest/src/test/groovy/org/onap/cps/rest/utils/MultipartFileUtilSpec.groovy2
-rw-r--r--cps-rest/src/test/groovy/org/onap/cps/rest/utils/ZipFileSizeValidatorSpec.groovy2
3 files changed, 5 insertions, 5 deletions
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/utils/ZipFileSizeValidator.java b/cps-rest/src/main/java/org/onap/cps/rest/utils/ZipFileSizeValidator.java
index 2e303d1d4..e514b93af 100644
--- a/cps-rest/src/main/java/org/onap/cps/rest/utils/ZipFileSizeValidator.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/utils/ZipFileSizeValidator.java
@@ -29,7 +29,7 @@ import org.onap.cps.spi.exceptions.ModelValidationException;
public class ZipFileSizeValidator {
private static final int THRESHOLD_ENTRIES = 10000;
- private static int THRESHOLD_SIZE = 100000000;
+ private static int thresholdSize = 100000000;
private static final double THRESHOLD_RATIO = 40;
private static final String INVALID_ZIP = "Invalid ZIP archive content.";
@@ -71,10 +71,10 @@ public class ZipFileSizeValidator {
* Validate the total Size and number of entries in the zip.
*/
public void validateSizeAndEntries() {
- if (totalUncompressedSizeOfYangFilesInArchive > THRESHOLD_SIZE) {
+ if (totalUncompressedSizeOfYangFilesInArchive > thresholdSize) {
throw new ModelValidationException(INVALID_ZIP,
String.format("The total size of uncompressed yang files exceeds the CPS limit of %s bytes.",
- THRESHOLD_SIZE));
+ thresholdSize));
}
if (totalYangFileEntriesInArchive > THRESHOLD_ENTRIES) {
throw new ModelValidationException(INVALID_ZIP,
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/utils/MultipartFileUtilSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/utils/MultipartFileUtilSpec.groovy
index 67ee50e89..572db005b 100644
--- a/cps-rest/src/test/groovy/org/onap/cps/rest/utils/MultipartFileUtilSpec.groovy
+++ b/cps-rest/src/test/groovy/org/onap/cps/rest/utils/MultipartFileUtilSpec.groovy
@@ -63,7 +63,7 @@ class MultipartFileUtilSpec extends Specification {
def 'Yang file limits in zip archive: #scenario for the bug reported in CPS-1477'() {
given: 'a yang file size (uncompressed) limit of #threshold bytes'
- ZipFileSizeValidator.THRESHOLD_SIZE = threshold
+ ZipFileSizeValidator.thresholdSize = threshold
and: 'an archive with a yang file of 1083 bytes'
def multipartFile = multipartZipFileFromResource('/yang-files-set-total-1083-bytes.zip')
when: 'attempt to extract yang files'
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/utils/ZipFileSizeValidatorSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/utils/ZipFileSizeValidatorSpec.groovy
index 60ecb2e3b..b4a6a6ab1 100644
--- a/cps-rest/src/test/groovy/org/onap/cps/rest/utils/ZipFileSizeValidatorSpec.groovy
+++ b/cps-rest/src/test/groovy/org/onap/cps/rest/utils/ZipFileSizeValidatorSpec.groovy
@@ -25,7 +25,7 @@ import spock.lang.Specification
class ZipFileSizeValidatorSpec extends Specification {
- def static thresholdSize = ZipFileSizeValidator.THRESHOLD_SIZE
+ def static thresholdSize = ZipFileSizeValidator.thresholdSize
def static thresholdEntries = ZipFileSizeValidator.THRESHOLD_ENTRIES
def static thresholdRatio = ZipFileSizeValidator.THRESHOLD_RATIO