diff options
author | JulienBe <julien.bertozzi@intl.att.com> | 2020-10-28 11:50:25 -0400 |
---|---|---|
committer | JulienBe <julien.bertozzi@intl.att.com> | 2021-02-23 10:57:28 +0100 |
commit | b485c37b36ddb3ab5e8085c009b26e97c8e62d74 (patch) | |
tree | dcea5bd91cf72076295d46f430c725d13b42f275 /openecomp-be | |
parent | 72b29baac0c1f08b610fd4daf2078b43ee74b3d8 (diff) |
Upgrade Vulnerable Direct Dependencies [snakeyaml]
Change-Id: I84417ab3d4f18634be519b837a34d1f1e774ceff
Signed-off-by: amohamad <a.mohamad@queensu.ca>
Issue-ID: SDC-3051
Updated MVN dependencies in the respective pom.xml files
Updated the signature of some methods to match new version 1.26
Modified test cases to match the new wording of exceptions
Still working on troublshooting other failing test cases
Change-Id: Ifc796574e6d8d4e4fc707db04944d83427b5dbe6
Signed-off-by: amohamad <a.mohamad@queensu.ca>
Signed-off-by: JulienBe <julien.bertozzi@intl.att.com>
Diffstat (limited to 'openecomp-be')
101 files changed, 816 insertions, 945 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml index e41cc0b24f..0b8fa751bc 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml @@ -11,7 +11,6 @@ <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>action-library-rest</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../</relativePath> </parent> <dependencies> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml index a37680796f..a8973c8798 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml @@ -12,7 +12,6 @@ <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-rest-webapp</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../</relativePath> </parent> <modules> <module>/action-library-rest-services</module> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml index 9f3c3e7d12..3cc19ab554 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml @@ -10,8 +10,7 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc</artifactId> - <relativePath>../../..</relativePath> + <artifactId>openecomp-sdc-rest-webapp</artifactId> <version>1.8.1-SNAPSHOT</version> </parent> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml index 487378bf13..48ef4287b8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml @@ -13,14 +13,14 @@ </parent> <modules> - <module>/openecomp-sdc-common-rest</module> - <module>/vendor-license-rest</module> - <module>/onboarding-rest-war</module> - <module>/vendor-software-products-rest</module> - <module>/validation-rest</module> - <module>/action-library-rest</module> - <module>/application-config-rest</module> - <module>/healthcheck-rest</module> + <module>openecomp-sdc-common-rest</module> + <module>vendor-license-rest</module> + <module>onboarding-rest-war</module> + <module>vendor-software-products-rest</module> + <module>validation-rest</module> + <module>action-library-rest</module> + <module>application-config-rest</module> + <module>healthcheck-rest</module> <module>conflict-rest</module> <module>item-permissions-rest</module> <module>item-rest</module> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml index be8480f48e..5af20dab24 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml @@ -11,7 +11,6 @@ <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>validation-rest</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../</relativePath> </parent> <dependencies> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml index f00b8daa79..a3e7435837 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml @@ -11,7 +11,6 @@ <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-rest-webapp</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../</relativePath> </parent> <modules> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml index 25e403119a..1700e9553a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml @@ -26,7 +26,6 @@ <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>vendor-license-rest</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../</relativePath> </parent> <properties> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml index f9b76c7664..1df2e81616 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml @@ -10,7 +10,6 @@ <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>vendor-license-rest</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../</relativePath> </parent> <dependencies> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml index 721a83986b..fd030a920d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml @@ -27,7 +27,6 @@ <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>vendor-software-products-rest</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../</relativePath> </parent> <dependencies> diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java index 2053373dce..33a558ea75 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java @@ -24,10 +24,10 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validati import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.anEmptyMap; -import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -63,10 +63,8 @@ import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.va import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.commons.collections.CollectionUtils; @@ -963,27 +961,12 @@ public class SOL004MetaDirectoryValidatorTest { final List<ErrorMessage> expectedErrorList = new ArrayList<>(); expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR - , Messages.INVALID_YAML_FORMAT_1.formatMessage(nonManoPmEventsSource, "while scanning a simple key\n" - + " in 'reader', line 2, column 1:\n" - + " key {}\n" - + " ^\n" - + "could not find expected ':'\n" - + " in 'reader', line 2, column 7:\n" - + " {}\n" - + " ^\n")) + , Messages.INVALID_YAML_FORMAT_1.formatMessage(nonManoPmEventsSource, "while scanning a simple key in 'reader', line 2, column 1: key {} ^could not find expected ':' in 'reader', line 2, column 7: key {} ^")) ); - expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR, "while scanning a simple key\n" + - " in 'reader', line 2, column 1:\n" + - " key {}\n" + - " ^\n" + - "could not find expected ':'\n" + - " in 'reader', line 2, column 7:\n" + - " {}\n" + - " ^\n") + expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR, "while scanning a simple key in 'reader', line 2, column 1: key {} ^could not find expected ':' in 'reader', line 2, column 7: key {} ^") ); - final Map<String, List<ErrorMessage>> actualErrorMap = sol004MetaDirectoryValidator - .validateContent(handler); + final Map<String, List<ErrorMessage>> actualErrorMap = sol004MetaDirectoryValidator.validateContent(handler); assertExpectedErrors(actualErrorMap.get(SdcCommon.UPLOAD_FILE), expectedErrorList); } @@ -1253,22 +1236,6 @@ public class SOL004MetaDirectoryValidatorTest { assertExpectedErrors(actualErrorMap.get(SdcCommon.UPLOAD_FILE), expectedErrorList); } - protected void assertExpectedErrors(List<ErrorMessage> actualErrorList, final List<ErrorMessage> expectedErrorList) { - if (actualErrorList == null) { - actualErrorList = new ArrayList<>(); - } - - printErrorMessages(actualErrorList); - - assertThat("The actual error list should have the same size as the expected error list " + actualErrorList.toString() - , actualErrorList, hasSize(expectedErrorList.size()) - ); - - assertThat("The actual error and expected error lists should be the same" - , actualErrorList, containsInAnyOrder(expectedErrorList.toArray(new ErrorMessage[0])) - ); - } - protected void assertExpectedErrors(final String testCase, final Map<String, List<ErrorMessage>> errors, final int expectedErrors){ final List<ErrorMessage> errorMessages = errors.get(SdcCommon.UPLOAD_FILE); printErrorMessages(errorMessages); @@ -1287,4 +1254,25 @@ public class SOL004MetaDirectoryValidatorTest { } } + private void assertExpectedErrors(List<ErrorMessage> actualErrorList, final List<ErrorMessage> expectedErrorList) { + if (actualErrorList == null) { + actualErrorList = new ArrayList<>(); + } + + printErrorMessages(actualErrorList); + + assertThat("The actual error list should have the same size as the expected error list" + , actualErrorList, hasSize(expectedErrorList.size()) + ); + + actualErrorList.forEach(error -> { + Predicate<ErrorMessage> matching = e -> e.getLevel() == error.getLevel() && sanitize(e.getMessage()).equalsIgnoreCase(sanitize(error.getMessage())); + assertTrue("The actual error and expected error lists should be the same", expectedErrorList.stream().anyMatch(matching)); + }); + } + + private static String sanitize(String s) { + return s.trim().replaceAll("\n", "").replaceAll("\r", "").replaceAll("\\s{2,}", " ").trim(); + } + } diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-api/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-api/pom.xml index ae6ea775ed..9fa74e637d 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-api/pom.xml +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-api/pom.xml @@ -4,17 +4,14 @@ <name>openecomp-facade-api</name> <artifactId>openecomp-facade-api</artifactId> - <groupId>org.openecomp.sdc.core</groupId> <parent> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <groupId>org.openecomp.sdc.core</groupId> + <artifactId>openecomp-facade-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../../../</relativePath> </parent> <dependencies> - <dependency> <groupId>org.openecomp.sdc.core</groupId> <artifactId>openecomp-utilities-lib</artifactId> diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/pom.xml index b45af106cc..25b682a16b 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/pom.xml +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/pom.xml @@ -4,13 +4,11 @@ <artifactId>openecomp-facade-core</artifactId> <name>openecomp-facade-core</name> - <groupId>org.openecomp.sdc.core</groupId> <parent> - <artifactId>openecomp-sdc-lib</artifactId> - <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-facade-lib</artifactId> + <groupId>org.openecomp.sdc.core</groupId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../../..</relativePath> </parent> diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/pom.xml index f892ddb15c..3d3e35aca1 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/pom.xml +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/pom.xml @@ -4,8 +4,8 @@ <name>openecomp-facade-lib</name> <artifactId>openecomp-facade-lib</artifactId> - <packaging>pom</packaging> + <parent> <artifactId>openecomp-core-lib</artifactId> <groupId>org.openecomp.sdc.core</groupId> @@ -17,18 +17,4 @@ <module>openecomp-facade-core</module> </modules> - <dependencies> - <dependency> - <groupId>org.openecomp.sdc.core</groupId> - <artifactId>openecomp-facade-api</artifactId> - <version>${project.version}</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.openecomp.sdc.core</groupId> - <artifactId>openecomp-facade-core</artifactId> - <version>${project.version}</version> - <scope>runtime</scope> - </dependency> - </dependencies> </project>
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/pom.xml index 3a48db6c92..bd3f421798 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/pom.xml +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/pom.xml @@ -16,5 +16,4 @@ <module>openecomp-nosqldb-api</module> <module>openecomp-nosqldb-core</module> </modules> - </project>
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-core-lib/pom.xml b/openecomp-be/lib/openecomp-core-lib/pom.xml index 6329060226..48a4ef1ba3 100644 --- a/openecomp-be/lib/openecomp-core-lib/pom.xml +++ b/openecomp-be/lib/openecomp-core-lib/pom.xml @@ -14,11 +14,11 @@ </parent> <modules> - <module>/openecomp-facade-lib</module> - <module>/openecomp-nosqldb-lib</module> - <module>/openecomp-utilities-lib</module> - <module>/openecomp-config-lib</module> - <module>/openecomp-zusammen-lib</module> - <module>/openecomp-session-lib</module> + <module>openecomp-facade-lib</module> + <module>openecomp-nosqldb-lib</module> + <module>openecomp-utilities-lib</module> + <module>openecomp-config-lib</module> + <module>openecomp-zusammen-lib</module> + <module>openecomp-session-lib</module> </modules> </project> diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/pom.xml b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/pom.xml index a96fe631df..0dc9aa1202 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/pom.xml @@ -24,9 +24,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-enrichment-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/pom.xml b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/pom.xml index 639f8f5bb1..a0d7937049 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/pom.xml @@ -24,9 +24,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-enrichment-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/pom.xml b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/pom.xml index 351e163336..c35bbc1f0f 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/pom.xml @@ -24,9 +24,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-enrichment-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java index a34f6913c3..cf9ec3c49d 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java @@ -174,8 +174,8 @@ public class BaseToscaEnrichmentTest { name = entry.getName() .substring(entry.getName().lastIndexOf(File.separator) + 1, entry.getName().length()); if (expectedResultFileNameSet.contains(name)) { - expected = new String(expectedResultMap.get(name)).trim().replace("\r", ""); - actual = new String(FileUtils.toByteArray(zis)).trim().replace("\r", ""); + expected = sanitize(new String(expectedResultMap.get(name))); + actual = sanitize(new String(FileUtils.toByteArray(zis))); assertEquals("difference in file: " + name, expected, actual); expectedResultFileNameSet.remove(name); @@ -187,4 +187,8 @@ public class BaseToscaEnrichmentTest { } assertEquals(0, expectedResultFileNameSet.size()); } + + private static String sanitize(String s) { + return s.trim().replaceAll("\n", "").replaceAll("\r", "").replaceAll("\\s{2,}", " ").trim(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/pom.xml b/openecomp-be/lib/openecomp-sdc-enrichment-lib/pom.xml index b1158dced1..a8ca19937b 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/pom.xml @@ -18,27 +18,4 @@ <module>openecomp-sdc-enrichment-core</module> <module>openecomp-sdc-enrichment-impl</module> </modules> - - <dependencies> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-enrichment-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-enrichment-core</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-vendor-software-product-core</artifactId> - <version>${project.version}</version> - </dependency> - <!--dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-validation-impl</artifactId> - <version>${project.version}</version> - </dependency--> - </dependencies> </project> diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/pom.xml b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/pom.xml index 30dc51c4a7..8215b1c672 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/pom.xml @@ -9,9 +9,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-externaltesting-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/pom.xml b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/pom.xml index a4b0b3790e..c5df0fc9c5 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/pom.xml @@ -25,9 +25,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-externaltesting-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/pom.xml b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/pom.xml index 2facd82726..9860f0b01d 100644 --- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/pom.xml @@ -6,12 +6,10 @@ <name>openecomp-sdc-model-api</name> <artifactId>openecomp-sdc-model-api</artifactId> - - <parent> + <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-model-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> @@ -22,11 +20,6 @@ </dependency> <dependency> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-validation-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-versioning-core</artifactId> <version>${project.version}</version> </dependency> diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml index 2b9394dee4..b4e50cbf4f 100644 --- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml @@ -25,9 +25,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-model-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/pom.xml b/openecomp-be/lib/openecomp-sdc-model-lib/pom.xml index 05a0ea2622..b25336f26d 100644 --- a/openecomp-be/lib/openecomp-sdc-model-lib/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-model-lib/pom.xml @@ -17,17 +17,4 @@ <module>openecomp-sdc-model-api</module> <module>openecomp-sdc-model-impl</module> </modules> - - <dependencies> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-model-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-model-impl</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> </project> diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/pom.xml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/pom.xml index b49317c015..dd48be3f4f 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/pom.xml @@ -22,9 +22,8 @@ <artifactId>openecomp-sdc-notification-api</artifactId> <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-notification-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../../pom.xml</relativePath> </parent> <dependencies> <dependency> diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/pom.xml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/pom.xml index c9eede942a..05654aaaa1 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/pom.xml @@ -25,9 +25,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-notification-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> <dependency> diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/pom.xml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/pom.xml index b0c4a49101..ab0f6b0cf7 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/pom.xml @@ -8,9 +8,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-notification-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/pom.xml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/pom.xml index f569d9eef3..a4f7566d47 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/pom.xml @@ -8,9 +8,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-notification-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/pom.xml b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/pom.xml index dde93524ce..2468b2b8d6 100644 --- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/pom.xml @@ -9,9 +9,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-tosca-generator-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/pom.xml b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/pom.xml index 8840c4659e..ff17a1a184 100644 --- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/pom.xml @@ -25,9 +25,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-tosca-generator-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-api/pom.xml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-api/pom.xml index 8229262e81..b8d348b818 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-api/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-api/pom.xml @@ -25,9 +25,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-translator-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/pom.xml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/pom.xml index f523b7eeb1..94abe98c63 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/pom.xml @@ -25,9 +25,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-translator-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java index 703fa0d924..f65b0bb113 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java @@ -695,10 +695,10 @@ public class TestUtils { while ((entry = zis.getNextEntry()) != null) { name = entry.getName() - .substring(entry.getName().lastIndexOf(File.separator) + 1, entry.getName().length()); + .substring(entry.getName().lastIndexOf(File.separator) + 1); if (expectedResultFileNameSet.contains(name)) { - expected = new String(expectedResultMap.get(name)).trim().replace("\r", ""); - actual = new String(FileUtils.toByteArray(zis)).trim().replace("\r", ""); + expected = sanitize(new String(expectedResultMap.get(name))); + actual = sanitize(new String(FileUtils.toByteArray(zis))); assertEquals("difference in file: " + name, expected, actual); expectedResultFileNameSet.remove(name); @@ -709,6 +709,10 @@ public class TestUtils { } } + private static String sanitize(String s) { + return s.trim().replaceAll("\n", "").replaceAll("\r", "").replaceAll("\\s{2,}", " ").trim(); + } + public static String getErrorAsString(Map<String, List<ErrorMessage>> errorMessages) { StringBuilder sb = new StringBuilder(); errorMessages.forEach((file, errorList) -> sb.append("File:").append(file).append(System.lineSeparator()) diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_exCP_naming_diff/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_exCP_naming_diff/MainServiceTemplate.yaml index d73bbef97b..2ebfeaff01 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_exCP_naming_diff/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_exCP_naming_diff/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_fixed_ips_diff/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_fixed_ips_diff/MainServiceTemplate.yaml index 8a3eb21523..ea29e3d150 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_fixed_ips_diff/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_fixed_ips_diff/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_flavor_name_diff/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_flavor_name_diff/MainServiceTemplate.yaml index d006cc9771..16aa48645f 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_flavor_name_diff/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_flavor_name_diff/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_image_missing/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_image_missing/MainServiceTemplate.yaml index 9e3d82dd27..314f49de98 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_image_missing/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_image_missing/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_image_name_diff/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_image_name_diff/MainServiceTemplate.yaml index 0e58aeb0c1..b2273d1244 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_image_name_diff/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_image_name_diff/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_port_without_allowed_address_pairs/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_port_without_allowed_address_pairs/MainServiceTemplate.yaml index dd5a477d16..bdb212a8d9 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_port_without_allowed_address_pairs/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_port_without_allowed_address_pairs/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_port_without_fixed_ips/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_port_without_fixed_ips/MainServiceTemplate.yaml index a4e58144de..f28ddc5c4b 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_port_without_fixed_ips/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_port_without_fixed_ips/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_port_without_mac_address/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_port_without_mac_address/MainServiceTemplate.yaml index 1ddd292cf3..6caa016e1f 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_port_without_mac_address/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_port_without_mac_address/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/ports_with_none_of_the_properties/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/ports_with_none_of_the_properties/MainServiceTemplate.yaml index 2a5fcb139c..c46e8e1f12 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/ports_with_none_of_the_properties/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/ports_with_none_of_the_properties/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/three_compute_valid/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/three_compute_valid/MainServiceTemplate.yaml index 8095b88d19..54be7c315c 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/three_compute_valid/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/three_compute_valid/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/three_compute_with_same_relations/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/three_compute_with_same_relations/MainServiceTemplate.yaml index 3561f35391..1213eb8467 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/three_compute_with_same_relations/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/three_compute_with_same_relations/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/three_ports_similar_relations/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/three_ports_similar_relations/MainServiceTemplate.yaml index cf09f4b3ef..4ec4072cd7 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/three_ports_similar_relations/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/three_ports_similar_relations/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_port_types/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_port_types/MainServiceTemplate.yaml index ea845e8260..39490da79f 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_port_types/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_port_types/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types/MainServiceTemplate.yaml index d575e26ff9..2efbf7467e 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/more_than_one_port/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/more_than_one_port/MainServiceTemplate.yaml index 1086507058..afe89ba695 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/more_than_one_port/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/more_than_one_port/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/one_compute_node/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/one_compute_node/MainServiceTemplate.yaml index 22a9564cc1..39e53605cc 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/one_compute_node/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/one_compute_node/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/one_instance_for_two_types/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/one_instance_for_two_types/MainServiceTemplate.yaml index d9fb652110..8e317f88d3 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/one_instance_for_two_types/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/one_instance_for_two_types/MainServiceTemplate.yaml @@ -80,7 +80,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/three_compute_two_similar_one_diff/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/three_compute_two_similar_one_diff/MainServiceTemplate.yaml index 43335d6812..409d682444 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/three_compute_two_similar_one_diff/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/three_compute_two_similar_one_diff/MainServiceTemplate.yaml @@ -80,7 +80,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/three_compute_valid/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/three_compute_valid/MainServiceTemplate.yaml index d85021332a..e1e59f5129 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/three_compute_valid/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/three_compute_valid/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/valid_pre_condition/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/valid_pre_condition/MainServiceTemplate.yaml index b2c73f9c92..240a6845d2 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/valid_pre_condition/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/valid_pre_condition/MainServiceTemplate.yaml @@ -78,7 +78,6 @@ topology_template: - 107.250.172.217 entry_schema: type: string - default: 169.254.1.4 ps_server_names: label: PS server names hidden: false diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/pom.xml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/pom.xml index 79665dfe0b..ab5c35aba7 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/pom.xml @@ -9,9 +9,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-validation-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/pom.xml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/pom.xml index 0d69912efd..b25581fa7c 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/pom.xml @@ -25,9 +25,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-validation-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java index 2f5a8ce399..a25b8ae88f 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java @@ -25,8 +25,6 @@ import org.openecomp.core.validation.api.ValidationManager; import org.openecomp.core.validation.types.GlobalValidationContext; import org.openecomp.core.validation.types.MessageContainer; import org.openecomp.sdc.datatypes.error.ErrorMessage; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.validation.Validator; import org.openecomp.sdc.validation.services.ValidationFactory; @@ -37,8 +35,6 @@ import java.util.Objects; public class ValidationManagerImpl implements ValidationManager { - private static Logger logger = (Logger) LoggerFactory.getLogger(ValidationManagerImpl.class); - private GlobalValidationContext globalContext; private List<Validator> validators; diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/pom.xml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/pom.xml index 8dfea9e422..abf4fb3e67 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/pom.xml @@ -26,9 +26,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-validation-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java index b11ff5e341..c433c3e7d4 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java @@ -17,7 +17,8 @@ package org.openecomp.sdc.validation.impl.validators; -import org.onap.sdc.tosca.services.YamlUtil; +import org.onap.sdc.tosca.services.MyPropertyUtils; +import org.onap.sdc.tosca.services.StrictMapAppenderConstructor; import org.openecomp.core.validation.ErrorMessageCode; import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; import org.openecomp.core.validation.types.GlobalValidationContext; @@ -25,6 +26,12 @@ import org.openecomp.sdc.common.errors.Messages; import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.validation.Validator; import org.openecomp.sdc.validation.impl.util.YamlValidatorUtil; +import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.LoaderOptions; +import org.yaml.snakeyaml.TypeDescription; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.constructor.Constructor; +import org.yaml.snakeyaml.representer.Representer; import java.io.InputStream; import java.util.Collection; @@ -33,42 +40,50 @@ import java.util.Optional; import java.util.Set; public class YamlValidator implements Validator { - private static final ErrorMessageCode ERROR_CODE_YML_1 = new ErrorMessageCode("YML1"); - private static final ErrorMessageCode ERROR_CODE_YML_2 = new ErrorMessageCode("YML2"); + private static final ErrorMessageCode ERROR_CODE_YML_1 = new ErrorMessageCode("YML1"); + private static final ErrorMessageCode ERROR_CODE_YML_2 = new ErrorMessageCode("YML2"); - @Override - public void validate(GlobalValidationContext globalContext) { - Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext); + @Override + public void validate(GlobalValidationContext globalContext) { + Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext); - Collection<String> files = globalContext.files( - (fileName, globalValidationContext) -> FileExtensionUtils.isYaml(fileName) - && !pmDictionaryFiles.contains(fileName)); + Collection<String> files = globalContext.files( + (fileName, globalValidationContext) -> FileExtensionUtils.isYaml(fileName) + && !pmDictionaryFiles.contains(fileName)); - files.forEach(fileName -> validate(fileName, globalContext)); - } - - private void validate(String fileName, GlobalValidationContext globalContext) { - Optional<InputStream> rowContent = globalContext.getFileContent(fileName); - if (rowContent.isEmpty()) { - globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder - .getErrorWithParameters(ERROR_CODE_YML_1, Messages - .INVALID_YAML_FORMAT_REASON.getErrorMessage(), - Messages.EMPTY_YAML_FILE.getErrorMessage())); - return; /* no need to continue validation */ + files.forEach(fileName -> validate(fileName, globalContext)); } - try { - convert(rowContent.get(), Map.class); - } catch (Exception exception) { + private void validate(String fileName, GlobalValidationContext globalContext) { + Optional<InputStream> rowContent = globalContext.getFileContent(fileName); + if (rowContent.isEmpty()) { + globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder + .getErrorWithParameters(ERROR_CODE_YML_1, Messages + .INVALID_YAML_FORMAT_REASON.getErrorMessage(), + Messages.EMPTY_YAML_FILE.getErrorMessage())); + return; /* no need to continue validation */ + } + + try (var yamlContent = rowContent.get()) { + Constructor constructor = new StrictMapAppenderConstructor(Map.class); + constructor.setAllowDuplicateKeys(false); + constructor.setPropertyUtils(new MyPropertyUtils()); + TypeDescription yamlFileDescription = new TypeDescription(Map.class); + constructor.addTypeDescription(yamlFileDescription); + LoaderOptions options = new LoaderOptions(); + options.setAllowDuplicateKeys(false); + //No Yaml Constructor takes only Constructor and LoaderOptions, that is why I had to pass anonymous Representer and DumperOptions objects + Object yamlObj = new Yaml(constructor, new Representer(), new DumperOptions(), options).load(yamlContent); - globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder - .getErrorWithParameters(ERROR_CODE_YML_2, Messages - .INVALID_YAML_FORMAT_REASON.getErrorMessage(), - YamlValidatorUtil.getParserExceptionReason(exception))); + if (yamlObj == null) { + throw new Exception(); + } + } catch (Exception exception) { + globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder + .getErrorWithParameters(ERROR_CODE_YML_2, Messages + .INVALID_YAML_FORMAT_REASON.getErrorMessage(), + YamlValidatorUtil.getParserExceptionReason(exception))); + } } - } - private <T> T convert(InputStream content, Class<T> type) { - return new YamlUtil().yamlToObject(content, type); - } } diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidator.java index b3d346177b..760c73a52b 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidator.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidator.java @@ -30,146 +30,114 @@ import org.openecomp.sdc.validation.ValidationContext; import org.openecomp.sdc.validation.type.NamingConventionValidationContext; import org.openecomp.sdc.validation.util.ValidationUtil; +import java.util.Arrays; import java.util.List; import java.util.Map; import static java.util.Objects.nonNull; public class NeutronPortNamingConventionValidator implements ResourceValidator { - private static final ErrorMessageCode ERROR_CODE_NNP1 = new ErrorMessageCode("NNP1"); - private static final ErrorMessageCode ERROR_CODE_NNP2 = new ErrorMessageCode("NNP2"); - private static final ErrorMessageCode ERROR_CODE_NNP3 = new ErrorMessageCode("NNP3"); - - @Override - public void validate(String fileName, Map.Entry<String, Resource> resourceEntry, - GlobalValidationContext globalContext, ValidationContext validationContext) { - - NamingConventionValidationContext namingConventionValidationContext = - (NamingConventionValidationContext)validationContext; - validatePortNetworkNamingConvention(fileName, namingConventionValidationContext.getHeatOrchestrationTemplate(), - globalContext); - validateFixedIpsNamingConvention(fileName, namingConventionValidationContext.getHeatOrchestrationTemplate(), - globalContext); - } - - private void validatePortNetworkNamingConvention(String fileName, - HeatOrchestrationTemplate heatOrchestrationTemplate, - GlobalValidationContext globalContext) { - if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources())) { - return; + private static final ErrorMessageCode ERROR_CODE_NNP1 = new ErrorMessageCode("NNP1"); + private static final ErrorMessageCode ERROR_CODE_NNP2 = new ErrorMessageCode("NNP2"); + private static final ErrorMessageCode ERROR_CODE_NNP3 = new ErrorMessageCode("NNP3"); + + @Override + public void validate(String fileName, Map.Entry<String, Resource> resourceEntry, + GlobalValidationContext globalContext, ValidationContext validationContext) { + NamingConventionValidationContext namingConventionValidationContext = (NamingConventionValidationContext) validationContext; + validatePortNetworkNamingConvention(fileName, namingConventionValidationContext.getHeatOrchestrationTemplate(), globalContext); + validateFixedIpsNamingConvention(fileName, namingConventionValidationContext.getHeatOrchestrationTemplate(), globalContext); } - String[] regexList = {".*_net_id", ".*_net_name", ".*_net_fqdn"}; - - heatOrchestrationTemplate - .getResources() - .entrySet() - .stream() - .filter(entry -> entry.getValue().getType() - .equals(HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource())) - .forEach(entry -> entry.getValue() - .getProperties() - .entrySet() - .stream() - .filter(propertyEntry -> - ("network").equalsIgnoreCase(propertyEntry.getKey()) - || ("network_id").equals(propertyEntry.getKey())) - .forEach(propertyEntry -> validateParamNamingConvention(fileName, entry.getKey(), - propertyEntry.getValue(), regexList, - Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES, globalContext))); - } - private void validateFixedIpsNamingConvention(String fileName, - HeatOrchestrationTemplate heatOrchestrationTemplate, - GlobalValidationContext globalContext) { - if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources())) { - return; + private void validatePortNetworkNamingConvention(String fileName, + HeatOrchestrationTemplate heatOrchestrationTemplate, + GlobalValidationContext globalContext) { + if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources())) { + return; + } + String[] regexList = {".*_net_id", ".*_net_name", ".*_net_fqdn"}; + + heatOrchestrationTemplate + .getResources() + .entrySet() + .stream() + .filter(entry -> entry.getValue().getType().equals(HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource())) + .forEach(entry -> entry.getValue() + .getProperties() + .entrySet() + .stream() + .filter(propertyEntry -> ("network").equalsIgnoreCase(propertyEntry.getKey()) || ("network_id").equals(propertyEntry.getKey())) + .forEach(propertyEntry -> validateParamNamingConvention(fileName, entry.getKey(), + propertyEntry.getValue(), regexList, + Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES, globalContext))); } - heatOrchestrationTemplate.getResources() - .entrySet() - .stream() - .filter(entry -> HeatResourcesTypes.findByHeatResource(entry.getValue().getType()) != null) - .filter(entry -> HeatResourcesTypes.findByHeatResource(entry.getValue().getType()) - .equals(HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE)) - .forEach(entry -> checkNeutronPortFixedIpsName(fileName, entry, globalContext)); - } - - private void checkNeutronPortFixedIpsName(String fileName, - Map.Entry<String, Resource> resourceEntry, - GlobalValidationContext globalContext) { - String[] regexList = {"[^_]+_[^_]+_ips", "[^_]+_[^_]+_v6_ips", "[^_]+_[^_]+_ip_(\\d+)", - "[^_]+_[^_]+_v6_ip_(\\d+)", "[^_]+_[^_]+_[^_]+_ips", "[^_]+_[^_]+_[^_]+_v6_ips", - "[^_]+_[^_]+_[^_]+_ip_(\\d+)", "[^_]+_[^_]+_[^_]+_v6_ip_(\\d+)"}; + private void validateFixedIpsNamingConvention(String fileName, + HeatOrchestrationTemplate heatOrchestrationTemplate, + GlobalValidationContext globalContext) { + if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources())) { + return; + } - if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) { - return; + heatOrchestrationTemplate.getResources() + .entrySet() + .stream() + .filter(entry -> HeatResourcesTypes.findByHeatResource(entry.getValue().getType()) != null) + .filter(entry -> HeatResourcesTypes.findByHeatResource(entry.getValue().getType()) + .equals(HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE)) + .forEach(entry -> checkNeutronPortFixedIpsName(fileName, entry, globalContext)); } - Map<String, Object> propertiesMap = resourceEntry.getValue().getProperties(); - Object fixedIps = propertiesMap.get("fixed_ips"); - if (nonNull(fixedIps) && fixedIps instanceof List) { - List<Object> fixedIpsList = (List<Object>) fixedIps; - for (Object fixedIpsObject : fixedIpsList) { - Map.Entry<String, Object> fixedIpsEntry = - ((Map<String, Object>) fixedIpsObject).entrySet().iterator().next(); - - validateFixedIpsName(fileName, resourceEntry, globalContext, regexList, fixedIpsEntry); + private void checkNeutronPortFixedIpsName(String fileName, + Map.Entry<String, Resource> resourceEntry, + GlobalValidationContext globalContext) { + String[] regexList = {"[^_]+_[^_]+_ips", "[^_]+_[^_]+_v6_ips", "[^_]+_[^_]+_ip_(\\d+)", + "[^_]+_[^_]+_v6_ip_(\\d+)", "[^_]+_[^_]+_[^_]+_ips", "[^_]+_[^_]+_[^_]+_v6_ips", + "[^_]+_[^_]+_[^_]+_ip_(\\d+)", "[^_]+_[^_]+_[^_]+_v6_ip_(\\d+)"}; + if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) { + return; + } - } + Map<String, Object> propertiesMap = resourceEntry.getValue().getProperties(); + Object fixedIps = propertiesMap.get("fixed_ips"); + if (nonNull(fixedIps) && fixedIps instanceof List) { + List<Object> fixedIpsList = (List<Object>) fixedIps; + for (Object fixedIpsObject : fixedIpsList) { + Map.Entry<String, Object> fixedIpsEntry = ((Map<String, Object>) fixedIpsObject).entrySet().iterator().next(); + validateFixedIpsName(fileName, resourceEntry, globalContext, regexList, fixedIpsEntry); + } + } } - } - - private void validateFixedIpsName(String fileName, Map.Entry<String, Resource> resourceEntry, - GlobalValidationContext globalContext, - String[] regexList, Map.Entry<String, Object> fixedIpsEntry) { - if (nonNull(fixedIpsEntry)) { - if (fixedIpsEntry.getValue() instanceof Map) { - - String fixedIpsName = ValidationUtil - .getWantedNameFromPropertyValueGetParam(fixedIpsEntry.getValue()); - if (nonNull(fixedIpsName) && !ValidationUtil.evalPattern(fixedIpsName, regexList)) { - globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters(ERROR_CODE_NNP1, Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES.getErrorMessage(), - "Port", "Fixed_IPS", fixedIpsName, resourceEntry.getKey())); - } - - - } else { - globalContext.addMessage( - fileName, - ErrorLevel.WARNING, ErrorMessagesFormatBuilder - .getErrorWithParameters( - ERROR_CODE_NNP2, Messages.MISSING_GET_PARAM.getErrorMessage(), - "fixed_ips", resourceEntry.getKey())); - } + private void validateFixedIpsName(String fileName, Map.Entry<String, Resource> resourceEntry, GlobalValidationContext globalContext, + String[] regexList, Map.Entry<String, Object> fixedIpsEntry) { + if (nonNull(fixedIpsEntry)) { + if (fixedIpsEntry.getValue() instanceof Map) { + String fixedIpsName = ValidationUtil.getWantedNameFromPropertyValueGetParam(fixedIpsEntry.getValue()); + if (nonNull(fixedIpsName) && !ValidationUtil.evalPattern(fixedIpsName, regexList)) { + globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder + .getErrorWithParameters(ERROR_CODE_NNP1, Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES.getErrorMessage(), + "Port", "Fixed_IPS", fixedIpsName, resourceEntry.getKey())); + } + } else { + globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder. + getErrorWithParameters(ERROR_CODE_NNP2, Messages.MISSING_GET_PARAM.getErrorMessage(), "fixed_ips", resourceEntry.getKey())); + } + } } - } - private void validateParamNamingConvention(String fileName, String resourceId, - Object propertyValue, - String[] regexList, - Messages message, - GlobalValidationContext globalContext) { - Object paramName; - if (propertyValue instanceof Map) { - paramName = ((Map) propertyValue).get("get_param"); - if (paramName instanceof String && !ValidationUtil.evalPattern(paramName, regexList)) { - globalContext.addMessage( - fileName, - ErrorLevel.WARNING, ErrorMessagesFormatBuilder - .getErrorWithParameters(ERROR_CODE_NNP3, message.getErrorMessage(), "Port", - "Network", (String) paramName, resourceId)); + private void validateParamNamingConvention(String fileName, String resourceId, Object propertyValue, String[] regexList, + Messages message, GlobalValidationContext globalContext) { + if (propertyValue instanceof Map) { + Object paramName = ((Map) propertyValue).get("get_param"); + if (paramName instanceof String && !ValidationUtil.evalPattern(paramName, regexList)) { + globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder + .getErrorWithParameters(ERROR_CODE_NNP3, message.getErrorMessage(), "Port", "Network", (String) paramName, resourceId)); + } + } else { + globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder + .getErrorWithParameters(ERROR_CODE_NNP2, Messages.MISSING_GET_PARAM.getErrorMessage(), "network or network_id", resourceId)); } - - } else { - globalContext.addMessage( - fileName, - ErrorLevel.WARNING, - ErrorMessagesFormatBuilder - .getErrorWithParameters( - ERROR_CODE_NNP2, Messages.MISSING_GET_PARAM.getErrorMessage(), - "network or network_id", resourceId)); } - } } diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java index c0a84b5f9d..da861dc3e1 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java @@ -40,7 +40,7 @@ public class ContrailValidatorTest { @Test public void testWarningMessageExistWhenConrailV1AndV2ResourcesCollidesInSameHeatFile() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/collidesinsameheatfile/"); validateMessage(messages, "WARNING: [CTL2]: HEAT Package includes both Contrail 2 and Contrail 3 " + @@ -52,7 +52,7 @@ public class ContrailValidatorTest { @Test public void testParseException(){ - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/parseException/"); validateMessage(messages, "ERROR: [CTL4]: Invalid HEAT format problem - [while scanning for the next " + @@ -68,7 +68,7 @@ public class ContrailValidatorTest { @Test public void testWarningMessageExistWhenConrailV1AndV2ResourcesCollidesInDifferentHeatFiles() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/collidesindifferentheatfiles/"); validateMessage(messages, "WARNING: [CTL2]: HEAT Package includes both Contrail 2 and Contrail 3 " + @@ -80,7 +80,7 @@ public class ContrailValidatorTest { @Test public void testWarningMessageNotExistWhenConrailV1AndV2ResourcesCollidesInNonHeatFile() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/collidesinnontheatfiles/"); validateMessage(messages, "WARNING: [CTL2]: HEAT Package includes both Contrail 2 and Contrail 3 " + @@ -93,7 +93,7 @@ public class ContrailValidatorTest { @Test public void testWarningMessageNotExistWhenOnlyConrailV1Resources() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/notcollides/"); validateMessage(messages, "WARNING: [CTL3]: Contrail 2.x deprecated resource is in use, " + @@ -104,7 +104,7 @@ public class ContrailValidatorTest { @Test public void testWarningMessageOnResourceWithContrailType() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/validatenocontrailresource/"); validateMessage(messages, "WARNING: [CTL3]: Contrail 2.x deprecated resource is in use, " + @@ -114,7 +114,7 @@ public class ContrailValidatorTest { @Test public void testInvalidHeatStructure(){ - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/invalidHeatStructure/"); validateMessage(messages, "ERROR: [CTL1]: Invalid HEAT format problem - [The file 'first.yaml' " + @@ -124,7 +124,7 @@ public class ContrailValidatorTest { @Test public void testInvalidHeatStructuredueToParsingError(){ - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/invalidHeatStructure/"); validateMessage(messages, "ERROR: [CTL1]: Invalid HEAT format problem - [The file 'first.yaml' " + diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java index a6e3d11cf3..64ddd61696 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java @@ -39,7 +39,7 @@ public class ForbiddenResourceGuideLineValidatorTest { @BeforeClass public static void init() throws IOException { - Map<String, Object> resourcesMap = ValidationTestUtil.getResourceMap(mockConfigFileName); + Map<String, Object> resourcesMap = new ValidationTestUtil().getResourceMap(mockConfigFileName); Map<String, Object> resourceBaseValidatorMap = (Map<String, Object>) resourcesMap.get("forbiddenResourceGuideLineValidator"); @@ -51,13 +51,13 @@ public class ForbiddenResourceGuideLineValidatorTest { @Test public void testFloatingIpResourceType() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator( + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator( forbiddenResourceGuideLineValidator, RESOURCE_PATH + "/positive"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(forbiddenResourceGuideLineValidator, + messages = new ValidationTestUtil().testValidator(forbiddenResourceGuideLineValidator, RESOURCE_PATH + "/negative"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); @@ -67,7 +67,7 @@ public class ForbiddenResourceGuideLineValidatorTest { } @Test public void testParseException(){ - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator( + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator( forbiddenResourceGuideLineValidator, RESOURCE_PATH + "/parseException"); Assert.assertEquals(messages.size(), 1); Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1); @@ -82,7 +82,7 @@ public class ForbiddenResourceGuideLineValidatorTest { @Test public void testInvalidResourceType(){ - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator( + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator( forbiddenResourceGuideLineValidator, RESOURCE_PATH + "/TestInvalidResourceType"); Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(), "WARNING: [FRG1]: A resource has an invalid or unsupported type - null, " + diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java index 5856b3f322..df6fa0676f 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java @@ -34,7 +34,7 @@ class GlobalContextUtilTest { @Test void shouldReturnOnlyFilesWithPmDictionaryType() { // given - GlobalValidationContext globalContext = ValidationTestUtil.createGlobalContextFromPath(TEST_MANIFEST_PATH); + GlobalValidationContext globalContext = new ValidationTestUtil().createGlobalContextFromPath(TEST_MANIFEST_PATH); // when Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidatorTest.java index d687e5e512..4492eac8e5 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidatorTest.java @@ -29,7 +29,7 @@ public class HeatResourceValidatorTest { @Test public void testParseException(){ - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, "/org/openecomp/validation/validators/guideLineValidator/baseHeatDoesNotExposeNetwork/parseException/"); Assert.assertEquals(messages.size(), 1); Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(), diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java index ffcedbbbc8..a528985909 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java @@ -41,7 +41,7 @@ public class HeatValidatorTest { @Test public void testInvalidHeatFormat() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/invalid_heat_format/negative_test/input"); Assert.assertNotNull(messages); @@ -61,7 +61,7 @@ public class HeatValidatorTest { @Test public void testDependsOn() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/depends_on_points_to_existing_resource/input"); Assert.assertNotNull(messages); @@ -79,7 +79,7 @@ public class HeatValidatorTest { @Test public void testResourcesReferencesExistInHeat() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/resource_references_exist_in_heat/negative_test/input"); Assert.assertNotNull(messages); @@ -98,7 +98,7 @@ public class HeatValidatorTest { @Test public void testGetResourceValueIsValid() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/get_resource_value_valid/negative_test/input"); Assert.assertNotNull(messages); @@ -121,7 +121,7 @@ public class HeatValidatorTest { @Test public void testTwoResourcesDoesNotHoldSameId() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/two_resources_does_not_hold_same_id/positive_test/input"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); @@ -129,7 +129,7 @@ public class HeatValidatorTest { @Test public void testWithWrongFileExtension(){ - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/wrongFileExtension"); Assert.assertNotNull(messages); Assert.assertEquals(messages.get("single.aad").getErrorMessageList().get(0).getMessage(), @@ -140,7 +140,7 @@ public class HeatValidatorTest { @Test public void testWithMissingManifestContent(){ - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/missingManifestContent"); Assert.assertNotNull(messages); Assert.assertEquals(messages.get("single.yaml").getErrorMessageList().get(0).getMessage(), @@ -152,7 +152,7 @@ public class HeatValidatorTest { @Test public void testWithInvalidHeatContent(){ - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/invalidHeatContent"); Assert.assertNotNull(messages); Assert.assertEquals(messages.get("single.yaml").getErrorMessageList().get(0).getMessage(), @@ -167,7 +167,7 @@ public class HeatValidatorTest { @Test public void testGeneratedArtifactExistInHeat() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/generated_artifact_exist/negative_test/input"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 3); @@ -188,7 +188,7 @@ public class HeatValidatorTest { @Test public void negativeTestGetParamPointToExistingParameter() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/get_param_points_to_existing_parameter/negative_test/input"); Assert.assertNotNull(messages); @@ -203,7 +203,7 @@ public class HeatValidatorTest { @Test public void testGetAttrFromNested() throws IOException { - Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/get_attr_from_nested/negative_test/input"); Assert.assertNotNull(messages); @@ -218,7 +218,7 @@ public class HeatValidatorTest { @Test public void testDefaultValueAlignWithType() throws IOException { - Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/default_value_align_with_type/negative_test/input"); Assert.assertNotNull(messages); @@ -234,7 +234,7 @@ public class HeatValidatorTest { @Test public void testEnvParametersMatchDefinedHeatParameterTypes() throws IOException { - Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/env_parameters_match_defined_types/negative_test/input"); Assert.assertNotNull(messages); @@ -249,7 +249,7 @@ public class HeatValidatorTest { @Test public void testReferencedArtifactsExist() throws IOException { - Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/referenced_artifacts_exist/negative_test/input"); Assert.assertNotNull(messages); @@ -264,7 +264,7 @@ public class HeatValidatorTest { @Test public void testEnvContentIsSubSetOfHeatParameters() throws IOException { - Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/env_content_is_subset_of_heat/negative_test/input"); Assert.assertNotNull(messages); @@ -279,7 +279,7 @@ public class HeatValidatorTest { @Test public void testGetParamPseudoParameters() { - Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(), + Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(new HeatValidator(), RESOURCE_PATH + "/pseudo_parameters/input"); Assert.assertNotNull(messages); @@ -288,7 +288,7 @@ public class HeatValidatorTest { } @Test public void testNoErrorWhenEmptyValueForParameterInEnv() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/env_empty_value/input"); Assert.assertNotNull(messages); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java index 9e860ef2b3..778213dea8 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java @@ -39,7 +39,7 @@ public class ManifestValidatorTest { @Test public void testValidManifest() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/validFiles"); Assert.assertNotNull(messages); Assert.assertNotNull(messages); @@ -48,25 +48,25 @@ public class ManifestValidatorTest { @Test public void testManifestMissingFileInZip() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(), RESOURCE_PATH + "/missingFileInZip"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); Assert.assertTrue(messages.containsKey("singleVol.yaml")); - ValidationTestUtil.validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList() + new ValidationTestUtil().validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList() .get(0).getMessage(), "ERROR: " + "[MNF4]: " + Messages.MISSING_FILE_IN_ZIP.getErrorMessage()); } @Test public void testInvalidManifest() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(), RESOURCE_PATH + "/invalidManifest"); Assert.assertNotNull(messages); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); Assert.assertTrue(messages.containsKey(SdcCommon.MANIFEST_NAME)); - ValidationTestUtil.validateErrorMessage( + new ValidationTestUtil().validateErrorMessage( messages.get(SdcCommon.MANIFEST_NAME).getErrorMessageList().get(0).getMessage(), "ERROR: " +"[MNF6]: " + Messages.INVALID_MANIFEST_FILE.getErrorMessage()); @@ -74,28 +74,28 @@ public class ManifestValidatorTest { @Test public void testMissingFileInManifest() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(), RESOURCE_PATH + "/missingFileInManifest"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); Assert.assertTrue(messages.containsKey("extraFile.env")); - ValidationTestUtil.validateErrorMessage(messages.get("extraFile.env").getErrorMessageList() + new ValidationTestUtil().validateErrorMessage(messages.get("extraFile.env").getErrorMessageList() .get(0).getMessage(), "WARNING: " + "[MNF5]: " + Messages.MISSING_FILE_IN_MANIFEST.getErrorMessage()); } @Test public void testMissingFileTypeInManifest() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(), RESOURCE_PATH + "/missingFileTypeInManifest"); - ValidationTestUtil.validateErrorMessage( + new ValidationTestUtil().validateErrorMessage( messages.get("MANIFEST.json").getErrorMessageList().get(0).getMessage(), "ERROR: " + "[MNF7]: Missing file name in manifest"); } @Test public void testInvalidFileTypeInManifest() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(), RESOURCE_PATH + "/invalidFileTypeInManifest"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 4); @@ -103,19 +103,19 @@ public class ManifestValidatorTest { Assert.assertTrue(messages.containsKey("illegalTypeFile.yaml")); Assert.assertTrue(messages.containsKey("single.yaml.illegalSuffix")); Assert.assertTrue(messages.containsKey("singleVol.yaml.illegalSuffix")); - ValidationTestUtil.validateErrorMessage( + new ValidationTestUtil().validateErrorMessage( messages.get("single.env.illegalSuffix").getErrorMessageList().get(0).getMessage(), "ERROR: "+"[MNF3]: " + Messages.WRONG_ENV_FILE_EXTENSION.getErrorMessage(), "single.env.illegalSuffix"); - ValidationTestUtil.validateErrorMessage( + new ValidationTestUtil().validateErrorMessage( messages.get("illegalTypeFile.yaml").getErrorMessageList().get(0).getMessage(), "ERROR: "+"[MNF8]: " + Messages.INVALID_FILE_TYPE.getErrorMessage(), "illegalTypeFile.yaml"); - ValidationTestUtil.validateErrorMessage( + new ValidationTestUtil().validateErrorMessage( messages.get("single.yaml.illegalSuffix").getErrorMessageList().get(0).getMessage(), "ERROR: "+"[MNF2]: " + Messages.WRONG_HEAT_FILE_EXTENSION.getErrorMessage(), "single.yaml.illegalSuffix"); - ValidationTestUtil.validateErrorMessage( + new ValidationTestUtil().validateErrorMessage( messages.get("singleVol.yaml.illegalSuffix").getErrorMessageList().get(0).getMessage(), "ERROR: "+"[MNF2]: " + Messages.WRONG_HEAT_FILE_EXTENSION.getErrorMessage(), "singleVol.yaml.illegalSuffix"); @@ -126,16 +126,16 @@ public class ManifestValidatorTest { @Test public void testMissingFileInManifestAndInZip() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(), RESOURCE_PATH + "/missingFileInManifestAndInZip"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 2); Assert.assertTrue(messages.containsKey("extraFile.env")); Assert.assertTrue(messages.containsKey("singleVol.yaml")); - ValidationTestUtil.validateErrorMessage(messages.get("extraFile.env").getErrorMessageList() + new ValidationTestUtil().validateErrorMessage(messages.get("extraFile.env").getErrorMessageList() .get(0).getMessage(), "WARNING: " + "[MNF5]: "+ Messages.MISSING_FILE_IN_MANIFEST .getErrorMessage()); - ValidationTestUtil.validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList() + new ValidationTestUtil().validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList() .get(0).getMessage(), "ERROR: " + "[MNF4]: " + Messages.MISSING_FILE_IN_ZIP .getErrorMessage()); @@ -143,12 +143,12 @@ public class ManifestValidatorTest { @Test public void testEnvInRoot() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(), RESOURCE_PATH + "/envInRoot"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); Assert.assertTrue(messages.containsKey("second.env")); - ValidationTestUtil.validateErrorMessage(messages.get("second.env").getErrorMessageList() + new ValidationTestUtil().validateErrorMessage(messages.get("second.env").getErrorMessageList() .get(0).getMessage(), "ERROR: [MNF1]: ENV file must be associated to a HEAT file"); } diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java index b510eeb26a..210bdd3504 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java @@ -73,6 +73,6 @@ public class PmDictionaryValidatorTest { private Map<String, MessageContainer> runValidation(String path) { PmDictionaryValidator validator = new PmDictionaryValidator(); - return ValidationTestUtil.testValidator(validator, path); + return new ValidationTestUtil().testValidator(validator, path); } } diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java index dde43e7808..a0b18b2922 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java @@ -33,12 +33,12 @@ public class SharedResourceGuideLineValidatorTest { @Test public void testBaseHeatExposeNetwork() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatDoesNotExposeNetwork/positive/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(validator, + messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatDoesNotExposeNetwork/negative/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); @@ -49,7 +49,7 @@ public class SharedResourceGuideLineValidatorTest { @Test public void testParseException(){ - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatDoesNotExposeNetwork/parseException/"); Assert.assertEquals(messages.size(), 1); Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1); @@ -64,7 +64,7 @@ public class SharedResourceGuideLineValidatorTest { @Test public void testInvalidGetResource(){ - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/" + "baseHeatDoesNotExposeNetworkInvalidGetResource"); Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(), @@ -74,12 +74,12 @@ public class SharedResourceGuideLineValidatorTest { @Test public void testBaseHeatExposeNetworkAndVolume() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatDoesNotExposeNetworkAndVolume/positive/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(validator, + messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatDoesNotExposeNetworkAndVolume/negative/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); @@ -92,12 +92,12 @@ public class SharedResourceGuideLineValidatorTest { @Test public void testBaseHeatExposeServerGroup() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatDoesNotExposeServerGroup/positive/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(validator, + messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatDoesNotExposeServerGroup/negative/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); @@ -108,12 +108,12 @@ public class SharedResourceGuideLineValidatorTest { @Test public void testBaseHeatExposeSecurityGroup() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatDoesNotExposeSecurityGroup/positive/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(validator, + messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatDoesNotExposeSecurityGroup/negative/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); @@ -124,12 +124,12 @@ public class SharedResourceGuideLineValidatorTest { @Test public void testBaseHeatExposeVolume() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatDoesNotExposeVolume/positive/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(validator, + messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatDoesNotExposeVolume/negative/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); @@ -140,12 +140,12 @@ public class SharedResourceGuideLineValidatorTest { @Test public void testHeatVolumeExpose() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/heatVolumeExpose/positive/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(validator, + messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/heatVolumeExpose/negative/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); @@ -157,13 +157,13 @@ public class SharedResourceGuideLineValidatorTest { @Test public void testResourceIsExposedByCallingGetResourceNotFromOutput() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatExposeResourceUsingGetResource/positive"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(validator, + messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/baseHeatExposeResourceUsingGetResource/negative"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); @@ -174,7 +174,7 @@ public class SharedResourceGuideLineValidatorTest { @Test public void testMissingBaseHeat() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/missingBaseHeat/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); @@ -185,7 +185,7 @@ public class SharedResourceGuideLineValidatorTest { @Test public void testMultiBaseHeat() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator, RESOURCE_PATH + "/multiBaseHeat/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/YamlValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/YamlValidatorTest.java index 637510abba..77e2f2a837 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/YamlValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/YamlValidatorTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,82 +31,67 @@ import org.openecomp.sdc.validation.util.ValidationTestUtil; public class YamlValidatorTest { - private static final String RESOURCE_PATH = "/org/openecomp/validation/validators/yaml_validator"; - - public Map<String, MessageContainer> runValidation(String path) { - YamlValidator validator = new YamlValidator(); - return ValidationTestUtil.testValidator(validator, path); - - } - - @Test - public void testValidYaml() { - - Map<String, MessageContainer> messages = runValidation( - RESOURCE_PATH + "/valid_yaml/input/validHeat.yaml"); - Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 0); - } - - @Test - public void testInvalidTabYaml() { - - Map<String, MessageContainer> messages = runValidation( - RESOURCE_PATH + "/invalid_valid_yaml_structure/input/invalidYamlTab.yaml"); - Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 1); - ValidationTestUtil.validateErrorMessage( - messages.get("invalidYamlTab.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: " +"[YML2]: "+ Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(), - "while scanning for the next tokenfound character '\\t(TAB)' that cannot start " + - "any token. (Do not use \\t(TAB) for indentation) in 'reader', line 14, " + - "column 5: \tadmin_state_up: true ^"); - } - - @Test - public void testDuplicateKeyInYaml() { - - Map<String, MessageContainer> messages = - runValidation(RESOURCE_PATH + "/duplicateKey.yaml"); - Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 1); - Assert.assertTrue(messages.containsKey("duplicateKey.yaml")); - ValidationTestUtil.validateErrorMessage( - messages.get("duplicateKey.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: " +"[YML2]: "+ Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(), - "while parsing MappingNode in 'reader', line 6, column 3: " + - "Key_1_unique: ^duplicate key: Key_2_not_unique in 'reader', line 31, " + - "column 1: ^"); - } - - @Test - public void testInvalidYamlStructure() { - - Map<String, MessageContainer> messages = runValidation( - RESOURCE_PATH + "/invalidYamlStructure.yaml"); - Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 1); - Assert.assertTrue(messages.containsKey("invalidYamlStructure.yaml")); - ValidationTestUtil.validateErrorMessage( - messages.get("invalidYamlStructure.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: " +"[YML2]: "+ Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(), - "while parsing a block mapping in 'reader', line 8, column 7: " + - "admin_state_up: true ^expected <block end>, but found BlockEntry in 'reader', " + - "line 10, column 7: - shared: true ^"); - } - - @Test - public void testEmptyYaml() { - - Map<String, MessageContainer> messages = - runValidation(RESOURCE_PATH + "/emptyYaml.yaml"); - Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 1); - Assert.assertTrue(messages.containsKey("emptyYaml.yaml")); - ValidationTestUtil.validateErrorMessage(messages.get("emptyYaml.yaml").getErrorMessageList() - .get(0).getMessage(), - "ERROR: " +"[YML1]: "+ Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(), - Messages.EMPTY_YAML_FILE.getErrorMessage()); - } + private static final String RESOURCE_PATH = "/org/openecomp/validation/validators/yaml_validator"; + + public Map<String, MessageContainer> runValidation(String path) { + return new ValidationTestUtil().testValidator(new YamlValidator(), path); + } + + @Test + public void testValidYaml() { + Map<String, MessageContainer> messages = runValidation(RESOURCE_PATH + "/valid_yaml/input/validHeat.yaml"); + Assert.assertNotNull(messages); + Assert.assertEquals(0, messages.size()); + } + + @Test + public void testInvalidTabYaml() { + + Map<String, MessageContainer> messages = runValidation( + RESOURCE_PATH + "/invalid_valid_yaml_structure/input/invalidYamlTab.yaml"); + Assert.assertNotNull(messages); + Assert.assertEquals(1, messages.size()); + new ValidationTestUtil().validateErrorMessage( + messages.get("invalidYamlTab.yaml").getErrorMessageList().get(0).getMessage(), + "ERROR: " + "[YML2]: " + Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(), + "while scanning for the next tokenfound character '\\t(TAB)' that cannot start " + + "any token. (Do not use \\t(TAB) for indentation) in 'reader', line 14, " + + "column 5: \tadmin_state_up: true ^"); + } + + @Test + public void testDuplicateKeyInYaml() { + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new YamlValidator(), RESOURCE_PATH + "/duplicateKey.yaml"); + Assert.assertNotNull(messages); + Assert.assertEquals(1, messages.size()); + Assert.assertTrue(messages.containsKey("duplicateKey.yaml")); + Assert.assertTrue(messages.get("duplicateKey.yaml").getErrorMessageList().get(0).getMessage().contains("Key_2_not_unique")); + } + + @Test + public void testInvalidYamlStructure() { + Map<String, MessageContainer> messages = runValidation(RESOURCE_PATH + "/invalidYamlStructure.yaml"); + Assert.assertNotNull(messages); + Assert.assertEquals(1, messages.size()); + Assert.assertTrue(messages.containsKey("invalidYamlStructure.yaml")); + new ValidationTestUtil().validateErrorMessage( + messages.get("invalidYamlStructure.yaml").getErrorMessageList().get(0).getMessage(), + "ERROR: " + "[YML2]: " + Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(), + "while parsing a block mapping in 'reader', line 8, column 7: " + + "admin_state_up: true ^expected <block end>, but found '-' in 'reader', " + + "line 10, column 7: - shared: true ^"); + } + + @Test + public void testEmptyYaml() { + Map<String, MessageContainer> messages = runValidation(RESOURCE_PATH + "/emptyYaml.yaml"); + Assert.assertNotNull(messages); + Assert.assertEquals(1, messages.size()); + Assert.assertTrue(messages.containsKey("emptyYaml.yaml")); + new ValidationTestUtil().validateErrorMessage(messages.get("emptyYaml.yaml").getErrorMessageList() + .get(0).getMessage(), + "ERROR: " + "[YML1]: " + Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(), + Messages.EMPTY_YAML_FILE.getErrorMessage()); + } } diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java index 43041140a3..707848f1bd 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java @@ -37,7 +37,7 @@ public class ContrailNetworkPolicyResourceValidatorTest { private static final String PATH = "/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/"; @Test public void testNetworkPolicyAssociatedWithAttachPolicy() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, resourceValidator + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator , HeatResourcesTypes.CONTRAIL_NETWORK_RULE_RESOURCE_TYPE.getHeatResource(), PATH + "positive"); @@ -52,7 +52,7 @@ public class ContrailNetworkPolicyResourceValidatorTest { @Test public void testNonNetworkPolicyResource() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, resourceValidator + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator , HeatResourcesTypes.CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE.getHeatResource(), PATH + "negative"); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java index b864a2d557..d8cecc9ca1 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java @@ -38,7 +38,7 @@ public class NestedResourceValidatorTest { @Test public void testNoLoopsNesting() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, null, PATH + "no_loops_nesting/negative_test/input"); @@ -74,7 +74,7 @@ public class NestedResourceValidatorTest { @Test public void testPropertiesMatchNestedParameters() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, null, PATH + "properties_match_nested_parameters/negative_test/input"); @@ -89,7 +89,7 @@ public class NestedResourceValidatorTest { @Test public void testWrongValueTypeAssigned() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, null, PATH + "properties_match_nested_parameters/wrong_value_type_assigned/input"); @@ -107,7 +107,7 @@ public class NestedResourceValidatorTest { final Resource resource = new Resource(); resource.setType("nested-pps_v1.0.yaml"); - final GlobalValidationContext globalValidationContext = ValidationTestUtil.createGlobalContextFromPath(PATH + "missing_nested_file/input"); + final GlobalValidationContext globalValidationContext = new ValidationTestUtil().createGlobalContextFromPath(PATH + "missing_nested_file/input"); NestedResourceValidator.validateAllPropertiesMatchNestedParameters(null, null, resource, Optional.empty(), globalValidationContext); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java index 10c70b64d4..0e02a1d6ee 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java @@ -36,7 +36,7 @@ public class NeutronPortResourceValidatorTest { private static final String PATH = "/org/openecomp/validation/validators/heat_validator/"; @Test public void testMoreThanOneBindFromNovaToPort() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(), PATH + "one_nova_points_to_one_port/negative_test/input"); @@ -51,7 +51,7 @@ public class NeutronPortResourceValidatorTest { @Test public void testPortNotBindToAnyNovaServerHPR1() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "no_neutron_port/input"); @@ -66,7 +66,7 @@ public class NeutronPortResourceValidatorTest { @Test public void testPortNotBindToAnyNovaServerHPR3() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "port_no_bind_to_any_nova_server/input"); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java index fabc833106..10de81350d 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java @@ -37,7 +37,7 @@ public class NeutronSecurityGroupResourceValidatorTest { @Test public void testSecurityGroupBaseFileNoPorts() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource(), PATH + "security_group_base_file_no_ports/input"); @@ -52,7 +52,7 @@ public class NeutronSecurityGroupResourceValidatorTest { @Test public void testSecurityGroupsCalledByPort() throws IOException { - Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource(), PATH + "security_group_called_by_port/input"); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java index e9c70b0251..b22dd4df4a 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java @@ -35,7 +35,7 @@ public class NovaServerGroupResourceValidatorTest { private static final String PATH = "/org/openecomp/validation/validators/heat_validator/"; @Test public void testPolicyIsAffinityOrAntiAffinity() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource(), PATH + "policy_is_affinity_or_anti_affinity/negative_test/input"); @@ -50,7 +50,7 @@ public class NovaServerGroupResourceValidatorTest { @Test public void testServerGroupCalledByServer() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource(), PATH + "server_group_called_by_nova_server/input"); @@ -66,7 +66,7 @@ public class NovaServerGroupResourceValidatorTest { @Test public void testNonServerGroup() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "server_group_called_by_nova_server_negative/input"); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java index 63523329cc..d56a5eaf2b 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java @@ -35,7 +35,7 @@ public class NovaServerResourceValidatorTest { private static final String PATH = "/org/openecomp/validation/validators/heat_validator/"; @Test public void testNovaPropertiesHasAssignedValue() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "nova_properties_has_assigned_value/negative_test/input"); @@ -50,7 +50,7 @@ public class NovaServerResourceValidatorTest { @Test public void testServerGroupsPointedByServersDefinedCorrectly() throws IOException { - Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "server_groups_defined_correctly/negative_test/input"); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java index 07cfaf7481..b80788a9c3 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java @@ -35,7 +35,7 @@ public class ResourceGroupResourceValidatorTest { private static final String PATH = "/org/openecomp/validation/validators/heat_validator/"; @Test public void testResourceGroupWithInvalidIndexVar() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(), PATH + "resource_group_invalid_indexvar/negative_test/input"); @@ -89,7 +89,7 @@ public class ResourceGroupResourceValidatorTest { @Test public void testResourceGroupWithInvalidType() { - Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(), PATH + "resource_group_invalid_type/negative_test/input"); @@ -110,7 +110,7 @@ public class ResourceGroupResourceValidatorTest { @Test public void testResourcesGroupWithNested() { - Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(), PATH + "resources_group_with_nested/negative_test/input"); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/VirtualMachineInterfaceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/VirtualMachineInterfaceValidatorTest.java index 9fcef284a9..4a8e7970b5 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/VirtualMachineInterfaceValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/VirtualMachineInterfaceValidatorTest.java @@ -17,6 +17,7 @@ package org.openecomp.sdc.validation.impl.validators.heatresource; import java.util.Map; + import org.junit.Assert; import org.junit.Test; import org.openecomp.core.validation.types.MessageContainer; @@ -30,128 +31,121 @@ import org.openecomp.sdc.validation.util.ValidationTestUtil; */ public class VirtualMachineInterfaceValidatorTest { - private static final String PATH = - "/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/"; - - - @Test - public void hasSingleParentPortNegative() { - HeatResourceValidator baseValidator = new HeatResourceValidator(); - VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, - HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), - PATH + "vlan_multiple_parent_ports/negative_test/input"); - - Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 1); - - Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1); - Assert.assertEquals( - messages.get("nested.yml").getErrorMessageList().get(0).getMessage(), - "ERROR: [VLAN1]: More than one parent port found, " + - "there should be only one parent port for a VLAN sub-interface ID [template_Vlan_2]"); - } - - @Test - public void hasSingleParentPortNegativeWithGetResource() { - HeatResourceValidator baseValidator = new HeatResourceValidator(); - VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, - HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), - PATH + "vlan_multiple_parent_ports/negative_get_resource/input"); - - Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 0); - } - - - @Test - public void hasSingleParentPortPositive() { - HeatResourceValidator baseValidator = new HeatResourceValidator(); - VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, - HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), - PATH + "vlan_multiple_parent_ports/positive_test/input"); - - Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 0); - - - } - - - @Test - public void hasBothPropertiesNegativeMissingVlanTag() { - HeatResourceValidator baseValidator = new HeatResourceValidator(); - VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, - HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), - PATH + "vlan_has_two_properties/negative_tag_missing/input"); - - Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 1); - - Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1); - Assert.assertEquals( - messages.get("nested.yml").getErrorMessageList().get(0).getMessage(), - "WARNING: [VLAN2]: VLAN Tag property " + - "virtual_machine_interface_properties_sub_interface_vlan_tag " + - "is missing in VLAN Resource ID [template_Vlan_2]"); - } - - @Test - public void hasBothPropertiesNegativeMissingRefs() { - HeatResourceValidator baseValidator = new HeatResourceValidator(); - VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, - HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), - PATH + "vlan_has_two_properties/negative_refs_missing/input"); - - Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 1); - - Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1); - Assert.assertEquals( - messages.get("nested.yml").getErrorMessageList().get(0).getMessage(), - "WARNING: [VLAN2]: Parent port property virtual_machine_interface_refs is " + - "missing in VLAN Resource ID [template_Vlan_2]"); - } - - @Test - public void hasBothPropertiesBothMissingWhichMeansPositive() { - HeatResourceValidator baseValidator = new HeatResourceValidator(); - VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, - HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), - PATH + "vlan_has_two_properties/negative_both_missing/input"); - - Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 0); - - } - - - @Test - public void hasBothPropertiesPositive() { - HeatResourceValidator baseValidator = new HeatResourceValidator(); - VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, - HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), - PATH + "vlan_has_two_properties/positive_test/input"); - - Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 0); - - - } - - - + private static final String PATH = + "/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/"; + + + @Test + public void hasSingleParentPortNegative() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_multiple_parent_ports/negative_test/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(1, messages.size()); + + Assert.assertEquals(1, messages.get("nested.yml").getErrorMessageList().size()); + Assert.assertEquals( + messages.get("nested.yml").getErrorMessageList().get(0).getMessage(), + "ERROR: [VLAN1]: More than one parent port found, " + + "there should be only one parent port for a VLAN sub-interface ID [template_Vlan_2]"); + } + + @Test + public void hasSingleParentPortNegativeWithGetResource() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_multiple_parent_ports/negative_get_resource/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 0); + } + + + @Test + public void hasSingleParentPortPositive() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_multiple_parent_ports/positive_test/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(0, messages.size()); + } + + + @Test + public void hasBothPropertiesNegativeMissingVlanTag() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_has_two_properties/negative_tag_missing/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + + Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1); + Assert.assertEquals( + messages.get("nested.yml").getErrorMessageList().get(0).getMessage(), + "WARNING: [VLAN2]: VLAN Tag property " + + "virtual_machine_interface_properties_sub_interface_vlan_tag " + + "is missing in VLAN Resource ID [template_Vlan_2]"); + } + + @Test + public void hasBothPropertiesNegativeMissingRefs() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_has_two_properties/negative_refs_missing/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + + Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1); + Assert.assertEquals( + messages.get("nested.yml").getErrorMessageList().get(0).getMessage(), + "WARNING: [VLAN2]: Parent port property virtual_machine_interface_refs is " + + "missing in VLAN Resource ID [template_Vlan_2]"); + } + + @Test + public void hasBothPropertiesBothMissingWhichMeansPositive() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_has_two_properties/negative_both_missing/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 0); + + } + + + @Test + public void hasBothPropertiesPositive() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_has_two_properties/positive_test/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 0); + } }
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java index d61d71839a..dd74f98ed6 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java @@ -36,7 +36,7 @@ public class ContrailServiceInstanceNamingConventionValidatorTest { @Test public void testContrailServiceInstanceAvailabilityZoneNotAlignedWithNamingConvention() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_INSTANCE.getHeatResource(), PATH + "notaligned"); Assert.assertNotNull(messages); @@ -48,7 +48,7 @@ public class ContrailServiceInstanceNamingConventionValidatorTest { @Test public void testContrailServiceInstanceAvailabilityZoneAlignedWithNamingConvention() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_INSTANCE.getHeatResource(), PATH + "aligned"); Assert.assertNotNull(messages); @@ -56,7 +56,7 @@ public class ContrailServiceInstanceNamingConventionValidatorTest { } @Test public void testContrailServiceInstanceAvailabilityZoneNotAlignedWithNamingConventionMissingParam() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_INSTANCE.getHeatResource(), PATH + "missingparam"); Assert.assertNotNull(messages); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java index f9e0765158..f04778c1b0 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java @@ -36,7 +36,7 @@ public class ContrailServiceTemplateNamingConventionValidatorTest { @Test public void testContrailServiceTemplateImageAndFlavorNamesAlignedWithNamingConventionButDifferentVmType() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(), PATH + "imageandflavordifferentvmtype"); Assert.assertNotNull(messages); @@ -49,7 +49,7 @@ public class ContrailServiceTemplateNamingConventionValidatorTest { @Test public void testContrailServiceTemplateImageAndFlavorNamesNotAlignedWithNamingConvention() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(), PATH + "/notaligned"); Assert.assertNotNull(messages); @@ -63,7 +63,7 @@ public class ContrailServiceTemplateNamingConventionValidatorTest { @Test public void testContrailServiceTemplateImageAndFlavorNamesAlignedWithNamingConvention() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(), PATH + "aligned"); Assert.assertNotNull(messages); @@ -72,7 +72,7 @@ public class ContrailServiceTemplateNamingConventionValidatorTest { @Test public void testContrailServiceTemplateMissingParam() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(), PATH + "missingparam"); Assert.assertNotNull(messages); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java index 00f95ef383..8dad17bcd1 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java @@ -30,18 +30,17 @@ import org.openecomp.sdc.validation.util.ValidationTestUtil; public class NeutronPortNamingConventionValidatorTest { NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); - NeutronPortNamingConventionValidator resourceValidator = new - NeutronPortNamingConventionValidator(); - private static final String PATH = "/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/"; + NeutronPortNamingConventionValidator resourceValidator = new NeutronPortNamingConventionValidator(); + private static final String PATH = "/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/"; @Test public void testHeatPortNetworkNamingConvention() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(), PATH + "positive/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(baseValidator, + messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(), PATH + "negative/"); Assert.assertNotNull(messages); @@ -53,13 +52,13 @@ public class NeutronPortNamingConventionValidatorTest { @Test public void testNeutronFixedIpName() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(), PATH + "positiveFixedIP"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(baseValidator, + messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(), PATH + "negativeFixedIP/"); Assert.assertNotNull(messages); @@ -76,13 +75,13 @@ public class NeutronPortNamingConventionValidatorTest { @Test public void testMissingParam() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(), + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new NamingConventionGuideLineValidator(), + new NeutronPortNamingConventionValidator(), HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(), PATH + "missingparam/"); Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 1); - Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1); - Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(), - "WARNING: [NNP2]: Missing get_param in network or network_id, Resource Id [port_resource_2]"); + Assert.assertEquals(1, messages.size()); + Assert.assertEquals(1, messages.get("first.yaml").getErrorMessageList().size()); + Assert.assertEquals("WARNING: [NNP2]: Missing get_param in network or network_id, Resource Id [port_resource_2]", + messages.get("first.yaml").getErrorMessageList().get(0).getMessage()); } } diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java index 01750c5f54..cfa3a86325 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java @@ -36,13 +36,13 @@ public class NovaServerNamingConventionGuideLineValidatorTest { private static final String PATH = "/org/openecomp/validation/validators/guideLineValidator/novaserverValidation/"; @Test public void testHeatNovaServerMetaDataValidation() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaServerMetaDataValidation/positive/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(baseValidator, + messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaServerMetaDataValidation/negative/"); Assert.assertNotNull(messages); @@ -54,13 +54,13 @@ public class NovaServerNamingConventionGuideLineValidatorTest { @Test public void testNovaServerAvailabilityZoneName() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaServerAvailabilityZoneName/positive"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(baseValidator, + messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaServerAvailabilityZoneName/negative"); Assert.assertNotNull(messages); @@ -74,7 +74,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest { @Test public void testNovaImageAndFlavorNamesEmptyProperties() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaServerImageAndFlavor/negativeEmptyProperties"); Assert.assertNotNull(messages); @@ -86,13 +86,13 @@ public class NovaServerNamingConventionGuideLineValidatorTest { @Test public void testNovaImageAndFlavorNames() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaServerImageAndFlavor/positive"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(baseValidator, + messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaServerImageAndFlavor/negative"); Assert.assertNotNull(messages); @@ -106,12 +106,12 @@ public class NovaServerNamingConventionGuideLineValidatorTest { @Test public void testNovaResourceNetworkUniqueRole() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaNetworkUniqueRoleConvention/positive/"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(baseValidator, + messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaNetworkUniqueRoleConvention/negative/"); Assert.assertNotNull(messages); @@ -123,13 +123,13 @@ public class NovaServerNamingConventionGuideLineValidatorTest { @Test public void testNovaServerName() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaServerNameValidation/positive"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); - messages = ValidationTestUtil.testValidator(baseValidator, + messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaServerNameValidation/negative/"); Assert.assertNotNull(messages); @@ -141,7 +141,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest { @Test public void testVMNameSyncInNova() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "input"); @@ -161,7 +161,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest { @Test public void testAvailabilityZoneName() throws IOException { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "availability_zone_name/input"); @@ -179,7 +179,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest { @Test public void testHeatNovaServerVnfIDValidation() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), "/org/openecomp/validation/validators/guideLineValidator/novaserverValidation/heatNovaServerMetaDataValidation/negativemissingvnfid/"); Assert.assertNotNull(messages); @@ -190,7 +190,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest { @Test public void testHeatNovaServerVfModuleValidation() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), "/org/openecomp/validation/validators/guideLineValidator/novaserverValidation/heatNovaServerMetaDataValidation/negativemisningvfmodule/"); Assert.assertNotNull(messages); @@ -200,7 +200,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest { @Test public void testMissingParam() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaNetworkUniqueRoleConvention/missingportNetwork/"); Assert.assertNotNull(messages); @@ -217,7 +217,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest { @Test public void testNovaResource() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaNetworkUniqueRoleConvention/invalidresource/"); Assert.assertNotNull(messages); @@ -227,7 +227,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest { @Test public void testEnvFileContent() { - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaNetworkUniqueRoleConvention/input/"); Assert.assertNotNull(messages); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/VirtualMachineInterfaceGuidelineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/VirtualMachineInterfaceGuidelineValidatorTest.java index e660fbffd5..21b5ca6f5f 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/VirtualMachineInterfaceGuidelineValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/VirtualMachineInterfaceGuidelineValidatorTest.java @@ -34,7 +34,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest { NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); VirtualMachineInterfaceGuidelineValidator resourceValidator = new VirtualMachineInterfaceGuidelineValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), PATH + "modeled_through_resource_group/positive_test/input"); @@ -50,7 +50,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest { NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); VirtualMachineInterfaceGuidelineValidator resourceValidator = new VirtualMachineInterfaceGuidelineValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), PATH + "modeled_through_resource_group/negative_test/input"); @@ -71,7 +71,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest { NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); VirtualMachineInterfaceGuidelineValidator resourceValidator = new VirtualMachineInterfaceGuidelineValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), PATH + "modeled_through_resource_group/negative_test_non_string/input"); @@ -92,7 +92,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest { NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); VirtualMachineInterfaceGuidelineValidator resourceValidator = new VirtualMachineInterfaceGuidelineValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), PATH + "modeled_through_resource_group/negative_get_resource/input"); @@ -114,7 +114,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest { NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); VirtualMachineInterfaceGuidelineValidator resourceValidator = new VirtualMachineInterfaceGuidelineValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), PATH + "single_vlan_resource/positive_test/input"); @@ -130,7 +130,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest { NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); VirtualMachineInterfaceGuidelineValidator resourceValidator = new VirtualMachineInterfaceGuidelineValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), PATH + "single_vlan_resource/negative_test/two_vlans"); @@ -151,7 +151,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest { NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); VirtualMachineInterfaceGuidelineValidator resourceValidator = new VirtualMachineInterfaceGuidelineValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), PATH + "single_vlan_resource/negative_test/vlan_and_nova"); @@ -171,7 +171,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest { NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); VirtualMachineInterfaceGuidelineValidator resourceValidator = new VirtualMachineInterfaceGuidelineValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), PATH + "naming_convention/negative_test/input"); @@ -192,7 +192,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest { NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); VirtualMachineInterfaceGuidelineValidator resourceValidator = new VirtualMachineInterfaceGuidelineValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator, HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), PATH + "naming_convention/positive_test/input"); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java index 68ba5c911d..11ed22966c 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java @@ -49,9 +49,9 @@ import org.openecomp.sdc.validation.base.ResourceBaseValidator; */ public class ValidationTestUtil { - private ValidationTestUtil(){} + public ValidationTestUtil(){} - public static GlobalValidationContext createGlobalContextFromPath(String path) { + public GlobalValidationContext createGlobalContextFromPath(String path) { GlobalValidationContext globalValidationContext = new GlobalValidationContext(); Map<String, byte[]> contentMap = getContentMapByPath(path); if (contentMap == null) { @@ -62,7 +62,7 @@ public class ValidationTestUtil { return globalValidationContext; } - private static Map<String, byte[]> getContentMapByPath(String path) { + private Map<String, byte[]> getContentMapByPath(String path) { Map<String, byte[]> contentMap = new HashMap<>(); URL url = ValidationTestUtil.class.getResource(path); File pathFile = new File(url.getFile()); @@ -89,8 +89,7 @@ public class ValidationTestUtil { return contentMap; } - public static Map<String, MessageContainer> testValidator(Validator validator, String path) { - + public Map<String, MessageContainer> testValidator(Validator validator, String path) { GlobalValidationContext globalValidationContext = createGlobalContextFromPath(path); validator.validate(globalValidationContext); @@ -100,7 +99,7 @@ public class ValidationTestUtil { } - public static Map<String, MessageContainer> testValidator(ResourceBaseValidator baseValidator, + public Map<String, MessageContainer> testValidator(ResourceBaseValidator baseValidator, ResourceValidator resourceValidator, String resourceTypeToValidate, String path) { @@ -117,7 +116,7 @@ public class ValidationTestUtil { return globalContext.getContextMessageContainers(); } - private static void validateFiles(ResourceBaseValidator baseValidator, + private void validateFiles(ResourceBaseValidator baseValidator, ResourceValidator resourceValidator, GlobalValidationContext globalContext, Map<String, FileData> fileEnvMap, @@ -144,7 +143,7 @@ public class ValidationTestUtil { } } - private static void validateResources(String fileName, ResourceValidator resourceValidator, + private void validateResources(String fileName, ResourceValidator resourceValidator, String resourceTypeToValidate, ValidationContext validationContext, GlobalValidationContext globalValidationContext){ @@ -166,7 +165,7 @@ public class ValidationTestUtil { (fileName, resourceEntry, globalValidationContext, validationContext)); } - private static boolean isResourceNeedToBeTested(String currResource, String resourceToTest){ + private boolean isResourceNeedToBeTested(String currResource, String resourceToTest){ if(Objects.isNull(resourceToTest)){ return HeatStructureUtil.isNestedResource(currResource); } @@ -174,14 +173,13 @@ public class ValidationTestUtil { return currResource.equals(resourceToTest); } - public static void validateErrorMessage(String actualMessage, String expected, String... params) { - + public void validateErrorMessage(String actualMessage, String expected, String... params) { Assert.assertEquals(actualMessage.replace("\n", "").replace("\r", ""), ErrorMessagesFormatBuilder.getErrorWithParameters(expected, params).replace("\n", "") .replace("\r", "")); } - public static Map<String, Object> getResourceMap(String configFileName) throws IOException { + public Map<String, Object> getResourceMap(String configFileName) throws IOException { URL mockResource = ValidationTestUtil.class.getResource(configFileName); String json = IOUtils.toString(mockResource.openStream(), "UTF-8"); return JsonUtil.json2Object(json, Map.class); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/missingparam/first.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/missingparam/first.yaml index 0fd281d692..b1bfd9e6e3 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/missingparam/first.yaml +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/missingparam/first.yaml @@ -3,19 +3,10 @@ heat_template_version: 2013-05-23 description: heat expose volume resource resources: - port_resource_0: - type: OS::Neutron::Port - properties: - network_id: { get_param: Internal1_net_id } -resources: - port_resource_1: - type: OS::Neutron::Port - properties: - network_id: { get_param: Internal1_net_name } -resources: port_resource_2: type: OS::Neutron::Port properties: + # required to be 'not a map' to trigger error NNP2 network_id: Internal1_net_fqdn diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/positive/first.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/positive/first.yaml index 12ee08952d..560aa61c68 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/positive/first.yaml +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/positive/first.yaml @@ -7,17 +7,6 @@ resources: type: OS::Neutron::Port properties: network_id: { get_param: Internal1_net_id } -resources: - port_resource_1: - type: OS::Neutron::Port - properties: - network_id: { get_param: Internal1_net_name } -resources: - port_resource_2: - type: OS::Neutron::Port - properties: - network_id: { get_param: Internal1_net_fqdn } - outputs: expose_resource_port_output_0: diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test/input/main.yml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test/input/main.yml index 2fc1d1614c..ea28e7fa4e 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test/input/main.yml +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test/input/main.yml @@ -65,17 +65,6 @@ resources: - port: { get_resource: template_VMInt_OAM_lb_1 } - port: { get_resource: cmaui_port_2 } - - type: OS::ContrailV2::VirtualMachineInterface - properties: - virtual_machine_interface_properties: - { - virtual_machine_interface_properties_service_interface_type: { get_param: lb_st_interface_type_oam }, - } - virtual_network_refs: [{ get_resource: test_net1 }] - port_tuple_refs: [{ get_param: template_PortTuple_LB1 }] - security_group_refs: [{ get_param: oam_sec_group_name}] - cmaui_port_2: type: OS::Neutron::Port properties: diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test_non_string/input/main.yml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test_non_string/input/main.yml index 2fc1d1614c..ea28e7fa4e 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test_non_string/input/main.yml +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test_non_string/input/main.yml @@ -65,17 +65,6 @@ resources: - port: { get_resource: template_VMInt_OAM_lb_1 } - port: { get_resource: cmaui_port_2 } - - type: OS::ContrailV2::VirtualMachineInterface - properties: - virtual_machine_interface_properties: - { - virtual_machine_interface_properties_service_interface_type: { get_param: lb_st_interface_type_oam }, - } - virtual_network_refs: [{ get_resource: test_net1 }] - port_tuple_refs: [{ get_param: template_PortTuple_LB1 }] - security_group_refs: [{ get_param: oam_sec_group_name}] - cmaui_port_2: type: OS::Neutron::Port properties: diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/negative_test/input/main.yml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/negative_test/input/main.yml index 2fc1d1614c..ea28e7fa4e 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/negative_test/input/main.yml +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/negative_test/input/main.yml @@ -65,17 +65,6 @@ resources: - port: { get_resource: template_VMInt_OAM_lb_1 } - port: { get_resource: cmaui_port_2 } - - type: OS::ContrailV2::VirtualMachineInterface - properties: - virtual_machine_interface_properties: - { - virtual_machine_interface_properties_service_interface_type: { get_param: lb_st_interface_type_oam }, - } - virtual_network_refs: [{ get_resource: test_net1 }] - port_tuple_refs: [{ get_param: template_PortTuple_LB1 }] - security_group_refs: [{ get_param: oam_sec_group_name}] - cmaui_port_2: type: OS::Neutron::Port properties: diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/positive_test/input/main.yml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/positive_test/input/main.yml index 9b0c3ec0eb..ea28e7fa4e 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/positive_test/input/main.yml +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/positive_test/input/main.yml @@ -65,17 +65,6 @@ resources: - port: { get_resource: template_VMInt_OAM_lb_1 } - port: { get_resource: cmaui_port_2 } - - type: OS::ContrailV2::VirtualMachineInterface - properties: - virtual_machine_interface_properties: - { - virtual_machine_interface_properties_service_interface_type: { get_param: lb_st_interface_type_oam }, - } - virtual_network_refs: [{ get_resource: test_net1 }] - port_tuple_refs: [{ get_param: template_PortTuple_LB1 }] - security_group_refs: [{ get_param: oam_sec_group_name}] - cmaui_port_2: type: OS::Neutron::Port properties: diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/pom.xml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/pom.xml index 54b6964bbc..4d2ec69003 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/pom.xml @@ -7,9 +7,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-validation-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java index ba23c8b649..a15c7678f7 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java @@ -56,7 +56,7 @@ public class ResourceBaseValidator implements Validator { return MapUtils.unmodifiableMap(this.resourceTypeToImpl); } -@Override + @Override public void init(Map<String, Object> properties) { if (MapUtils.isEmpty(properties)) { return; diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/test/java/org/openecomp/sdc/validation/base/ResourceBaseValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/test/java/org/openecomp/sdc/validation/base/ResourceBaseValidatorTest.java index 35a8c00ee9..095df4f859 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/test/java/org/openecomp/sdc/validation/base/ResourceBaseValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/test/java/org/openecomp/sdc/validation/base/ResourceBaseValidatorTest.java @@ -19,97 +19,228 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.Test; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; +import org.openecomp.core.validation.types.GlobalValidationContext; import org.openecomp.core.validation.types.MessageContainer; import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration; +import org.openecomp.sdc.heat.datatypes.manifest.FileData; +import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; +import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate; +import org.openecomp.sdc.heat.datatypes.model.Resource; +import org.openecomp.sdc.heat.services.HeatStructureUtil; +import org.openecomp.sdc.heat.services.manifest.ManifestUtil; +import org.openecomp.sdc.validation.ResourceValidator; +import org.openecomp.sdc.validation.ValidationContext; +import org.openecomp.sdc.validation.Validator; import org.openecomp.sdc.validation.type.ConfigConstants; -import org.openecomp.sdc.validation.util.ValidationTestUtil; +import org.openecomp.sdc.validation.util.ValidationUtil; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URL; +import java.util.*; public class ResourceBaseValidatorTest { -private String testValidator = "testValidator"; - - @Test - public void testInvalidResourceType(){ - ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator( - resourceBaseValidator, "/InvalidResourceType"); - assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(), - "WARNING: [RBV1]: A resource has an invalid or unsupported type - null, " + - "Resource ID [FSB2]"); - } - - @Test - public void testInvalidHeatStructure(){ - ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator(); - Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(resourceBaseValidator, - "/InvalidHeatStructure"); - assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: [RBV2]: Invalid HEAT format problem - [while scanning for the next " + - "token\n" + "found character '\\t(TAB)' that cannot start any token. " + - "(Do not use \\t(TAB) for indentation)\n" + - " in 'reader', line 10, column 1:\n" + - " \t\t\tresources:\n" + - " ^\n" + - "]"); - } - - @Test - public void testInitWithEmptyPropertiesMap() { - ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator(); - Map<String, Object> properties = new HashMap<>(); - resourceBaseValidator.init(properties); - - assertTrue(MapUtils.isEmpty(resourceBaseValidator.getResourceTypeToImpl())); - } - - @Test - public void testInitPropertiesMap() { - ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator(); - initProperties(resourceBaseValidator, getValidImplementationConfiguration()); - - Map<String, ImplementationConfiguration> resourceTypeToImpl = - resourceBaseValidator.getResourceTypeToImpl(); - assertTrue(MapUtils.isNotEmpty(resourceTypeToImpl)); - assertTrue(resourceTypeToImpl.containsKey(testValidator)); - } - - @Test - public void testInitPropertiesWithString() { - ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator(); - Map<String, Object> properties = new HashMap<>(); - properties.put(testValidator, "invalidValue"); - - resourceBaseValidator.init(properties); - - assertTrue(MapUtils.isEmpty(resourceBaseValidator.getResourceTypeToImpl())); - } - - @Test - public void testInitPropertiesWithoutImplClass() { - ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator(); - initProperties(resourceBaseValidator, new HashMap<>()); - - assertTrue(MapUtils.isEmpty(resourceBaseValidator.getResourceTypeToImpl())); - } - - public Map<String, Object> getValidImplementationConfiguration() { - Map<String, Object> implConfiguration = new HashMap<>(); - implConfiguration.put( - ConfigConstants.Impl_Class, "org.openecomp.sdc.validation.impl.validators.ForbiddenResourceGuideLineValidator"); - implConfiguration.put(ConfigConstants.Enable, true); - - return implConfiguration; - } - - private void initProperties(ResourceBaseValidator resourceBaseValidator, - Map<String, Object> implementationConfiguration) { - Map<String, Object> properties = - Collections.singletonMap(testValidator, implementationConfiguration); - - resourceBaseValidator.init(properties); - } + private String testValidator = "testValidator"; + + @Test + public void testInvalidResourceType() { + ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator(); + Map<String, MessageContainer> messages = testValidator(resourceBaseValidator, "/InvalidResourceType"); + assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(), + "WARNING: [RBV1]: A resource has an invalid or unsupported type - null, Resource ID [FSB2]"); + } + + @Test + public void testInvalidHeatStructure() { + ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator(); + Map<String, MessageContainer> messages = testValidator(resourceBaseValidator, "/InvalidHeatStructure"); + assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(), + "ERROR: [RBV2]: Invalid HEAT format problem - [while scanning for the next " + + "token\n" + "found character '\\t(TAB)' that cannot start any token. " + + "(Do not use \\t(TAB) for indentation)\n" + + " in 'reader', line 10, column 1:\n" + + " \t\t\tresources:\n" + + " ^\n" + + "]"); + } + + @Test + public void testInitWithEmptyPropertiesMap() { + ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator(); + Map<String, Object> properties = new HashMap<>(); + resourceBaseValidator.init(properties); + assertTrue(MapUtils.isEmpty(resourceBaseValidator.getResourceTypeToImpl())); + } + + @Test + public void testInitPropertiesMap() { + ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator(); + initProperties(resourceBaseValidator, getValidImplementationConfiguration()); + + Map<String, ImplementationConfiguration> resourceTypeToImpl = resourceBaseValidator.getResourceTypeToImpl(); + assertTrue(MapUtils.isNotEmpty(resourceTypeToImpl)); + assertTrue(resourceTypeToImpl.containsKey(testValidator)); + } + + @Test + public void testInitPropertiesWithString() { + ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator(); + Map<String, Object> properties = new HashMap<>(); + properties.put(testValidator, "invalidValue"); + resourceBaseValidator.init(properties); + assertTrue(MapUtils.isEmpty(resourceBaseValidator.getResourceTypeToImpl())); + } + + @Test + public void testInitPropertiesWithoutImplClass() { + ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator(); + initProperties(resourceBaseValidator, new HashMap<>()); + assertTrue(MapUtils.isEmpty(resourceBaseValidator.getResourceTypeToImpl())); + } + + public Map<String, Object> getValidImplementationConfiguration() { + Map<String, Object> implConfiguration = new HashMap<>(); + implConfiguration.put(ConfigConstants.Impl_Class, "org.openecomp.sdc.validation.impl.validators.ForbiddenResourceGuideLineValidator"); + implConfiguration.put(ConfigConstants.Enable, true); + + return implConfiguration; + } + + private void initProperties(ResourceBaseValidator resourceBaseValidator, Map<String, Object> implementationConfiguration) { + Map<String, Object> properties = Collections.singletonMap(testValidator, implementationConfiguration); + resourceBaseValidator.init(properties); + } + + public GlobalValidationContext createGlobalContextFromPath(String path) { + GlobalValidationContext globalValidationContext = new GlobalValidationContext(); + Map<String, byte[]> contentMap = getContentMapByPath(path); + if (contentMap == null) { + return null; + } + contentMap.forEach(globalValidationContext::addFileContext); + + return globalValidationContext; + } + + private Map<String, byte[]> getContentMapByPath(String path) { + Map<String, byte[]> contentMap = new HashMap<>(); + URL url = ResourceBaseValidator.class.getResource(path); + File pathFile = new File(url.getFile()); + File[] files; + if (pathFile.isDirectory()) { + files = pathFile.listFiles(); + } else { + files = new File[]{pathFile}; + } + + if (files == null || files.length == 0) { + return null; + } + + for (File file : files) { + + try (FileInputStream fis = new FileInputStream(file)) { + contentMap.put(file.getName(), FileUtils.toByteArray(fis)); + } catch (IOException e) { + throw new RuntimeException("Failed to read file: " + file, e); + } + + } + return contentMap; + } + + public Map<String, MessageContainer> testValidator(Validator validator, String path) { + GlobalValidationContext globalValidationContext = createGlobalContextFromPath(path); + validator.validate(globalValidationContext); + + assert globalValidationContext != null; + return globalValidationContext.getContextMessageContainers(); + } + + public Map<String, MessageContainer> testValidator(ResourceBaseValidator baseValidator, + ResourceValidator resourceValidator, + String resourceTypeToValidate, String path) { + + GlobalValidationContext globalContext = Objects.requireNonNull( + createGlobalContextFromPath(path), "Global validation context cannot be null"); + + ManifestContent manifestContent = ValidationUtil.validateManifest(globalContext); + Map<String, FileData.Type> fileTypeMap = ManifestUtil.getFileTypeMap(manifestContent); + Map<String, FileData> fileEnvMap = ManifestUtil.getFileAndItsEnv(manifestContent); + + validateFiles(baseValidator, resourceValidator, globalContext, fileEnvMap, fileTypeMap, + resourceTypeToValidate); + + return globalContext.getContextMessageContainers(); + } + + private void validateFiles(ResourceBaseValidator baseValidator, + ResourceValidator resourceValidator, + GlobalValidationContext globalContext, + Map<String, FileData> fileEnvMap, + Map<String, FileData.Type> fileTypeMap, + String resourceTypeToValidate) { + + Collection<String> files = globalContext.getFiles(); + for (String fileName : files) { + if (FileData.isHeatFile(fileTypeMap.get(fileName))) { + HeatOrchestrationTemplate heatOrchestrationTemplate = + ValidationUtil.checkHeatOrchestrationPreCondition(fileName, globalContext); + + if (Objects.isNull(heatOrchestrationTemplate)) { + continue; + } + + ValidationContext validationContext = baseValidator.createValidationContext(fileName, + fileEnvMap.get(fileName) == null ? null : fileEnvMap.get(fileName).getFile(), + heatOrchestrationTemplate, globalContext); + + validateResources(fileName, resourceValidator, resourceTypeToValidate, validationContext, + globalContext); + } + } + } + + private void validateResources(String fileName, ResourceValidator resourceValidator, + String resourceTypeToValidate, ValidationContext validationContext, + GlobalValidationContext globalValidationContext) { + + HeatOrchestrationTemplate heatOrchestrationTemplate = + ValidationUtil.checkHeatOrchestrationPreCondition(fileName, globalValidationContext); + + Map<String, Resource> resourcesMap = + Objects.requireNonNull(heatOrchestrationTemplate, "Orchestration template cannot be null").getResources(); + + if (MapUtils.isEmpty(resourcesMap)) { + return; + } + + resourcesMap.entrySet() + .stream() + .filter(resourceEntry -> isResourceNeedToBeTested(resourceEntry.getValue().getType(), resourceTypeToValidate)) + .forEach(resourceEntry -> + resourceValidator.validate + (fileName, resourceEntry, globalValidationContext, validationContext)); + } + + private boolean isResourceNeedToBeTested(String currResource, String resourceToTest) { + if (Objects.isNull(resourceToTest)) { + return HeatStructureUtil.isNestedResource(currResource); + } + + return currResource.equals(resourceToTest); + } + + public void validateErrorMessage(String actualMessage, String expected, String... params) { + assertEquals(actualMessage.replace("\n", "").replace("\r", ""), + ErrorMessagesFormatBuilder.getErrorWithParameters(expected, params).replace("\n", "") + .replace("\r", "")); + } + } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml index 69d26f9d02..54fffa0355 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml @@ -7,9 +7,8 @@ <artifactId>openecomp-sdc-vendor-license-api</artifactId> <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-vendor-license-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml index b6603df0f6..bb0c581ade 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml @@ -9,9 +9,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-vendor-license-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/pom.xml b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/pom.xml index ed629ec753..ecaea75df3 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/pom.xml @@ -12,11 +12,9 @@ <version>1.8.1-SNAPSHOT</version> </parent> - <modules> <module>openecomp-sdc-vendor-software-product-api</module> <module>openecomp-sdc-vendor-software-product-core</module> </modules> - </project> diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/pom.xml b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/pom.xml index d948c2931e..526d27adfa 100644 --- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/pom.xml @@ -23,9 +23,8 @@ <artifactId>openecomp-sdc-versioning-api</artifactId> <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-versioning-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/pom.xml b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/pom.xml index 77d4b778a7..3347fb3fc7 100644 --- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/pom.xml @@ -9,9 +9,8 @@ <parent> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-lib</artifactId> + <artifactId>openecomp-sdc-versioning-lib</artifactId> <version>1.8.1-SNAPSHOT</version> - <relativePath>../..</relativePath> </parent> <dependencies> diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml index 1292586816..1853916aab 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml @@ -9,16 +9,6 @@ <artifactId>onap-tosca-datatype</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>org.openecomp.sdc.core</groupId> - <artifactId>openecomp-tosca-lib</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc.core</groupId> - <artifactId>openecomp-facade-core</artifactId> - <version>${project.version}</version> - </dependency> </dependencies> <parent> diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml index eba914a79b..9d63529c72 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml @@ -10,16 +10,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.sdc.core</groupId> - <artifactId>openecomp-tosca-lib</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc.core</groupId> - <artifactId>openecomp-facade-core</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-translator-core</artifactId> <version>${project.version}</version> diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java index 1eb09a8b44..dfca19b96e 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java @@ -19,7 +19,13 @@ package org.openecomp.core.converter.impl.pnfd; -import static org.junit.Assert.assertEquals; +import org.junit.Test; +import org.onap.sdc.tosca.datatypes.model.ServiceTemplate; +import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil; +import org.onap.sdc.tosca.services.YamlUtil; +import org.openecomp.core.converter.ServiceTemplateReaderService; +import org.openecomp.core.converter.pnfd.PnfdTransformationEngine; +import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl; import java.io.IOException; import java.io.InputStream; @@ -31,20 +37,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.onap.sdc.tosca.datatypes.model.ServiceTemplate; -import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil; -import org.onap.sdc.tosca.services.YamlUtil; -import org.openecomp.core.converter.ServiceTemplateReaderService; -import org.openecomp.core.converter.pnfd.PnfdTransformationEngine; -import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl; -@RunWith(Parameterized.class) +import static org.junit.Assert.assertEquals; + public class PnfTransformationEngineParameterizedTest { private static final String TEST_CASES_PATH = "transformation/pnfParseEngine"; @@ -52,38 +49,9 @@ public class PnfTransformationEngineParameterizedTest { private static final String OUTPUT_FOLDER = "expectedOutput"; private static final String DEFAULT_OUTPUT_FILE_NAME = "defaultOutput.yaml"; - private final String inputFileName; - private final Path inputFilePath; - private final String outputFileName; - private final Path outputFilePath; - private final String transformationDescriptorFileName; - private final Path transformationDescriptorFilePath; private final YamlUtil yamlUtil = new YamlUtil(); private final ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); - public PnfTransformationEngineParameterizedTest(final String inputFileName, final Path inputFilePath, - final String outputFileName, final Path outputFilePath, - final String transformationDescriptorFileName, final Path transformationDescriptorFilePath) { - this.inputFileName = inputFileName; - this.inputFilePath = inputFilePath; - this.outputFileName = outputFileName; - this.outputFilePath = outputFilePath; - this.transformationDescriptorFileName = transformationDescriptorFileName; - this.transformationDescriptorFilePath = transformationDescriptorFilePath; - } - - - @Parameterized.Parameters(name = "{index}: input: {0}, descriptor: {4}, output: {2}") - public static Collection<Object> input() throws IOException, URISyntaxException { - return Files.list(getPathFromClasspath(TEST_CASES_PATH)).map(path -> { - try { - return buildTestCase(path); - } catch (final IOException e) { - return null; - } - }).filter(Objects::nonNull).flatMap(Collection::stream).collect(Collectors.toList()); - } - private static Collection<Object[]> buildTestCase(final Path testCasePath) throws IOException { final Path inputFilePath = Files.list(testCasePath) .filter(path -> path.toFile().getName().endsWith("yaml")) @@ -94,7 +62,7 @@ public class PnfTransformationEngineParameterizedTest { } final List<Path> transformationDescriptorList; try (final Stream<Path> files = Files.walk(testCasePath.resolve(TRANSFORMATION_DESCRIPTOR_FOLDER))) { - transformationDescriptorList = files.filter(path -> Files.isRegularFile(path)) + transformationDescriptorList = files.filter(Files::isRegularFile) .map(path -> Paths.get(TEST_CASES_PATH, testCasePath.getFileName().toString() , TRANSFORMATION_DESCRIPTOR_FOLDER, path.getFileName().toString())) .collect(Collectors.toList()); @@ -102,7 +70,7 @@ public class PnfTransformationEngineParameterizedTest { final List<Path> outputList; try (final Stream<Path> files = Files.walk(testCasePath.resolve(OUTPUT_FOLDER))) { - outputList = files.filter(path -> Files.isRegularFile(path)).collect(Collectors.toList()); + outputList = files.filter(Files::isRegularFile).collect(Collectors.toList()); } final Path defaultOutput = outputList.stream() .filter(path -> path.toFile().getName().equals(DEFAULT_OUTPUT_FILE_NAME)) @@ -115,29 +83,38 @@ public class PnfTransformationEngineParameterizedTest { .filter(path -> path.toFile().getName().equals(transformationDescriptorPath.toFile().getName())) .findFirst().orElse(defaultOutput); if (outputPath != null) { - testCaseList.add(new Object[] {inputFilePath.toFile().getName(), inputFilePath, - outputPath.toFile().getName(), outputPath, - transformationDescriptorPath.toFile().getName(), transformationDescriptorPath}); + testCaseList.add(new Object[]{ inputFilePath, outputPath, transformationDescriptorPath}); } } - return testCaseList; - } @Test - public void testTopologyTemplateConversions() throws IOException { - final byte[] descriptor = Files.readAllBytes(inputFilePath); - final ServiceTemplateReaderService serviceTemplateReaderService = new ServiceTemplateReaderServiceImpl(descriptor); - final ServiceTemplate serviceTemplate = new ServiceTemplate(); - - final PnfdTransformationEngine pnfdTransformationEngine = new PnfdNodeTemplateTransformationEngine( - serviceTemplateReaderService, serviceTemplate, transformationDescriptorFilePath.toString()); - pnfdTransformationEngine.transform(); - - final String result = yamlUtil.objectToYaml(serviceTemplate); - final String expectedResult = parseToYaml(outputFilePath); - assertEquals(expectedResult, result); + public void testTopologyTemplateConversions() throws IOException, URISyntaxException { + Files.list(getPathFromClasspath()).forEach(testCasePath -> { + try { + var paths = buildTestCase(testCasePath); + paths.forEach(p -> { + try { + final ServiceTemplateReaderService serviceTemplateReaderService = new ServiceTemplateReaderServiceImpl(Files.readAllBytes((Path) p[0])); + final ServiceTemplate serviceTemplate = new ServiceTemplate(); + + final PnfdTransformationEngine pnfdTransformationEngine = new PnfdNodeTemplateTransformationEngine( + serviceTemplateReaderService, serviceTemplate, p[2].toString()); + pnfdTransformationEngine.transform(); + + final String result = yamlUtil.objectToYaml(serviceTemplate); + final String expectedResult = parseToYaml((Path) p[1]); + assertEquals(expectedResult, result); + } catch (IOException e) { + e.printStackTrace(); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + } + ); } private String parseToYaml(final Path filePath) throws IOException { @@ -147,7 +124,7 @@ public class PnfTransformationEngineParameterizedTest { } } - private static Path getPathFromClasspath(final String location) throws URISyntaxException { - return Paths.get(PnfTransformationEngineParameterizedTest.class.getClassLoader().getResource(location).toURI()); + private static Path getPathFromClasspath() throws URISyntaxException { + return Paths.get(PnfTransformationEngineParameterizedTest.class.getClassLoader().getResource(PnfTransformationEngineParameterizedTest.TEST_CASES_PATH).toURI()); } }
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml b/openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml index 843923aa12..24a0866208 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml @@ -18,5 +18,16 @@ <module>openecomp-tosca-converter-core</module> </modules> - + <dependencies> + <dependency> + <groupId>org.openecomp.sdc.core</groupId> + <artifactId>openecomp-tosca-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.core</groupId> + <artifactId>openecomp-facade-core</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> </project>
\ No newline at end of file |