diff options
author | Joanna Jeremicz <joanna.jeremicz@nokia.com> | 2021-04-21 13:59:12 +0200 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2021-05-14 14:58:14 +0000 |
commit | e3de4c9d214983d38a7d66e89dae5d4bba170ca3 (patch) | |
tree | 9f92e5fc15d06051ffff254588bbcc1e85214d3f /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main | |
parent | df353be353e1ec25ac2a0e64a9eb617dcbc87703 (diff) |
Integrate helm validator with SDC-BE
- Read helm validator configuration
- Add call to helm validator during Helm validation
- Add JUnit tests
- Fix display message when CNF upload is unsuccessful
- Show warning messages from validation after CNF upload
Issue-ID: SDC-3185
Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
Change-Id: If197d557e6ddef4a07bef986d7cf133aedcb2cc5
Signed-off-by: Piotr Marcinkiewicz <piotr.marcinkiewicz@nokia.com>
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main')
2 files changed, 15 insertions, 11 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java index 640a15735f..0446103491 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java @@ -75,10 +75,11 @@ public class OnboardingPackageProcessor { private final CnfPackageValidator cnfPackageValidator; private FileContentHandler packageContent; - public OnboardingPackageProcessor(final String packageFileName, final byte[] packageFileContent) { + public OnboardingPackageProcessor(final String packageFileName, final byte[] packageFileContent, + final CnfPackageValidator cnfPackageValidator) { this.packageFileName = packageFileName; this.packageFileContent = packageFileContent; - this.cnfPackageValidator = new CnfPackageValidator(); + this.cnfPackageValidator = cnfPackageValidator; onboardPackageInfo = processPackage(); } @@ -87,11 +88,13 @@ public class OnboardingPackageProcessor { } public boolean hasErrors() { - return !errorMessages.isEmpty(); + return errorMessages.stream() + .anyMatch(error -> error.getLevel() == ErrorLevel.ERROR); } public boolean hasNoErrors() { - return errorMessages.isEmpty(); + return errorMessages.stream() + .noneMatch(error -> error.getLevel() == ErrorLevel.ERROR); } public Set<ErrorMessage> getErrorMessages() { diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/validation/CnfPackageValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/validation/CnfPackageValidator.java index 50f1fd8d06..6c886f8e74 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/validation/CnfPackageValidator.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/validation/CnfPackageValidator.java @@ -42,7 +42,7 @@ public class CnfPackageValidator { Stats stats = new Stats(); for (FileData mod : modules) { if (mod.getBase() == null) { - stats.without++; + stats.withoutBase++; } else if (mod.getBase()) { stats.base++; } @@ -50,14 +50,14 @@ public class CnfPackageValidator { return stats; } - private List<String> createErrorMessages(Stats stats) { + private List<String> createErrorMessages(Stats result) { List<String> messages = new ArrayList<>(); - if (stats.without > 0) { - messages.add(MANIFEST_VALIDATION_HELM_IS_BASE_MISSING.formatMessage(stats.without)); + if (result.withoutBase > 0) { + messages.add(MANIFEST_VALIDATION_HELM_IS_BASE_MISSING.formatMessage(result.withoutBase)); } - if (stats.base == 0) { + if (result.base == 0) { messages.add(MANIFEST_VALIDATION_HELM_IS_BASE_NOT_SET.getErrorMessage()); - } else if (stats.base > 1) { + } else if (result.base > 1) { messages.add(MANIFEST_VALIDATION_HELM_IS_BASE_NOT_UNIQUE.getErrorMessage()); } return messages; @@ -66,6 +66,7 @@ public class CnfPackageValidator { private static class Stats { private int base = 0; - private int without = 0; + private int withoutBase = 0; } + } |