summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082.java13
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082IntegrationTest.java16
-rw-r--r--csarvalidation/src/test/resources/pnf/r972082/fileExtensionOfArtifactIsNotYaml.csarbin0 -> 18061 bytes
3 files changed, 29 insertions, 0 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082.java
index 60bdd47..4b35328 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082.java
@@ -115,6 +115,16 @@ public class VTPValidateCSARR972082 extends VTPValidateCSARBase {
}
}
+ private static class InvalidFileExtensionError extends PnfCSARError {
+
+ private InvalidFileExtensionError(final String fileName) {
+ super(ERROR_CODE,
+ String.format("Invalid. File extension %s is invalid", fileName),
+ UNKNOWN_LINE_NUMBER,
+ fileName);
+ }
+ }
+
private static class ValidateNonManoSection {
private static final String ATTRIBUTE_NAME = "onap_pnf_sw_information";
@@ -187,6 +197,9 @@ public class VTPValidateCSARR972082 extends VTPValidateCSARBase {
if (StringUtils.isEmpty(swInformationFilePath)) {
errors.add(new MissingSourceElementUnderAttributeError("", swInformationFilePath));
return;
+ } else if (!swInformationFilePath.matches(".*\\.yaml$")) {
+ errors.add(new InvalidFileExtensionError(swInformationFilePath));
+ return;
}
final Optional<PnfSoftwareInformation> parsedYaml = parse(swInformationFilePath);
if (!parsedYaml.isPresent()) {
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082IntegrationTest.java
index 66937d4..b63705b 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082IntegrationTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082IntegrationTest.java
@@ -61,6 +61,22 @@ public class VTPValidateCSARR972082IntegrationTest {
}
@Test
+ public void shouldReturnErrorWhenFileExtensionIsNotYaml() throws Exception {
+ // given
+ configureTestCase(testCase, PNF_R_972082 + "fileExtensionOfArtifactIsNotYaml.csar", VTP_VALIDATE_CSAR_R_972082_YAML, IS_PNF);
+
+ // when
+ testCase.execute();
+
+ // then
+ final List<CSARError> errors = testCase.getErrors();
+ assertThat(errors.size()).isEqualTo(1);
+ assertThat(convertToMessagesList(errors)).contains(
+ "Invalid. File extension Files/pnf-sw-information/pnf-sw-information.json is invalid"
+ );
+ }
+
+ @Test
public void shouldReturnNoErrorWhenOptionalNonManoArtifactSetEntryIsNotPresent() throws Exception {
// given
configureTestCase(testCase, PNF_R_972082 + "missingOnapPnfSwInformationArtifactSetEntry.csar",
diff --git a/csarvalidation/src/test/resources/pnf/r972082/fileExtensionOfArtifactIsNotYaml.csar b/csarvalidation/src/test/resources/pnf/r972082/fileExtensionOfArtifactIsNotYaml.csar
new file mode 100644
index 0000000..f485172
--- /dev/null
+++ b/csarvalidation/src/test/resources/pnf/r972082/fileExtensionOfArtifactIsNotYaml.csar
Binary files differ