diff options
Diffstat (limited to 'csarvalidation/src/main')
4 files changed, 7 insertions, 28 deletions
diff --git a/csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlDocument.java b/csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlDocument.java index 7f80d1c..11582d1 100644 --- a/csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlDocument.java +++ b/csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlDocument.java @@ -39,8 +39,7 @@ public class YamlDocument { return yaml.get(key).toString(); } - public YamlParametersList getListOfValues(String key) - throws YamlParameterListFactory.YamlParameterListParsingException { + public YamlParametersList getListOfValues(String key) { return new YamlParameterListFactory().createYamlParameterList( yaml.get(key) ); diff --git a/csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlParameterListFactory.java b/csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlParameterListFactory.java index 4ea5ca2..5f41c5c 100644 --- a/csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlParameterListFactory.java +++ b/csarvalidation/src/main/java/org/onap/validation/yaml/model/YamlParameterListFactory.java @@ -17,8 +17,6 @@ package org.onap.validation.yaml.model; -import org.onap.validation.yaml.exception.YamlProcessingException; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -29,18 +27,7 @@ public class YamlParameterListFactory { return new YamlParametersList(Collections.emptyList()); } - public YamlParametersList createYamlParameterList(Object yaml) - throws YamlParameterListParsingException { - try { - return parseYamlToListOfPossibleValues(yaml); - } catch (ClassCastException e) { - throw new YamlParameterListParsingException( - String.format("Fail to parse given objects: %s as list.",yaml), e - ); - } - } - - private YamlParametersList parseYamlToListOfPossibleValues(Object yaml) { + public YamlParametersList createYamlParameterList(Object yaml) { List<String> parametersList = new ArrayList<>(); if( yaml instanceof List) { for (Object element : (List) yaml) { @@ -52,11 +39,4 @@ public class YamlParameterListFactory { return new YamlParametersList(parametersList); } - - public static class YamlParameterListParsingException extends YamlProcessingException { - YamlParameterListParsingException(String message, Throwable throwable) { - super(message, throwable); - } - } - } diff --git a/csarvalidation/src/main/java/org/onap/validation/yaml/process/YamlValidationProcess.java b/csarvalidation/src/main/java/org/onap/validation/yaml/process/YamlValidationProcess.java index e3fadb6..273014b 100644 --- a/csarvalidation/src/main/java/org/onap/validation/yaml/process/YamlValidationProcess.java +++ b/csarvalidation/src/main/java/org/onap/validation/yaml/process/YamlValidationProcess.java @@ -74,7 +74,9 @@ public class YamlValidationProcess { private boolean isValueOfNodeInAcceptedValuesList(YamlDocument document, YamlSchemaNode node) { return node.getAcceptedValues().isEmpty() || - node.getAcceptedValues().contains(document.getValue(node.getName())); + node.getAcceptedValues().containsAll( + document.getListOfValues(node.getName()).getParameters() + ); } private void addNextLevelNodeToValidationNodesQueue(YamlDocument document, YamlSchemaNode node) @@ -101,7 +103,7 @@ public class YamlValidationProcess { new SchemaValidationError( node.getPath() + node.getName(), String.format( - "Value is not in array of accepted values.%n value: %s%n accepted values: %s", + "Value(s) is/are not in array of accepted values.%n value(s): %s%n accepted value(s): %s", document.getValue(node.getName()), node.getAcceptedValues()) ) ); diff --git a/csarvalidation/src/main/java/org/onap/validation/yaml/schema/node/YamlSchemaNodeFactory.java b/csarvalidation/src/main/java/org/onap/validation/yaml/schema/node/YamlSchemaNodeFactory.java index a07935a..79a8f14 100644 --- a/csarvalidation/src/main/java/org/onap/validation/yaml/schema/node/YamlSchemaNodeFactory.java +++ b/csarvalidation/src/main/java/org/onap/validation/yaml/schema/node/YamlSchemaNodeFactory.java @@ -24,7 +24,6 @@ import org.onap.validation.yaml.model.YamlParameterListFactory; import org.onap.validation.yaml.model.YamlParametersList; import static org.onap.validation.yaml.model.YamlDocumentFactory.YamlDocumentParsingException; -import static org.onap.validation.yaml.model.YamlParameterListFactory.YamlParameterListParsingException; public class YamlSchemaNodeFactory { @@ -65,8 +64,7 @@ public class YamlSchemaNodeFactory { : EMPTY_COMMENT; } - private YamlParametersList getAcceptedValues(YamlDocument yamlDocument) - throws YamlParameterListParsingException { + private YamlParametersList getAcceptedValues(YamlDocument yamlDocument) { return isYamlContainingKey(yamlDocument, VALUE_KET) ? new YamlParameterListFactory().createYamlParameterList(yamlDocument.getYaml().get(VALUE_KET)) |