diff options
Diffstat (limited to 'csarvalidation')
-rw-r--r-- | csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java | 21 | ||||
-rw-r--r-- | csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java | 5 |
2 files changed, 14 insertions, 12 deletions
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java index 8263e6b..e542b65 100644 --- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java +++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java @@ -53,6 +53,8 @@ public class CsarValidator { LOG.debug("CSAR extracted sucessfully."); } } catch (Exception e1) { + + //deleteDirectory(); LOG.error("CSAR %s is not a valid CSAR/ZIP file! ", e1); } @@ -165,7 +167,7 @@ public class CsarValidator { return true; } } - } catch (IOException e) { + } catch (IOException | NullPointerException e) { LOG.error("Could not read file %s ! " + e.getMessage(), cfile); } return false; @@ -185,10 +187,10 @@ public class CsarValidator { "vnfmType"); boolean tResult = checkEntryFor(CommonConstants.MAINSERV_TEMPLATE, tListMetadata, key); - if (tResult && mfResult) { - return true; - } else { + if (!tResult || !mfResult) { return false; + } else { + return true; } } @@ -212,20 +214,23 @@ public class CsarValidator { } Yaml yaml = new Yaml(); - Map<String, ?> values = null; + Map<String, ?> values; try { values = (Map<String, ?>) yaml.load(new FileInputStream(new File(tFileWithPath))); } catch (FileNotFoundException e) { return false; } - Map<String,String> subValues = (Map<String,String>) values.get(key); + Map<? super String,? super String> subValues = (Map<? super String, ? super String>) values.get(key); //1. Check for empty values in map and if number of mandatory attributes presence - List<String> lResultNonNull = subValues.values().stream() + List<? super String> lResultNonNull = subValues.values().stream() .filter(Objects::nonNull) + .map(Object::toString) .collect(Collectors.toList()); - if (subValues.size() != attributes.size() && + + + if (subValues.size() != attributes.size() && lResultNonNull.size() != attributes.size()) { return false; } diff --git a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java b/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java index be764a1..7eccb7a 100644 --- a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java +++ b/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java @@ -35,13 +35,11 @@ public class CsarValidatorTest { String dir2 = System.getProperty("file.separator") + csarFile.substring(1); String packageId = UUID.randomUUID().toString(); - private String csarFile2 = classLoader.getResource("sample.csar").getFile(); + private String csarFile2 = classLoader.getResource("sample2.csar").getFile(); String sample2 = System.getProperty("file.separator") + csarFile2.substring(1); String packageId2 = UUID.randomUUID().toString(); - - @Test public void testAll() { CsarValidator csarValidator = new CsarValidator(packageId, dir2); @@ -49,7 +47,6 @@ public class CsarValidatorTest { CsarValidator csarValidator2 = new CsarValidator(packageId2, sample2); testValidateCsar(csarValidator2); - } @Test |