summaryrefslogtreecommitdiffstats
path: root/pmdictionaryvalidation/src/test/java/org/onap/validation/yaml/YamlFileValidatorTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'pmdictionaryvalidation/src/test/java/org/onap/validation/yaml/YamlFileValidatorTest.java')
-rw-r--r--pmdictionaryvalidation/src/test/java/org/onap/validation/yaml/YamlFileValidatorTest.java39
1 files changed, 22 insertions, 17 deletions
diff --git a/pmdictionaryvalidation/src/test/java/org/onap/validation/yaml/YamlFileValidatorTest.java b/pmdictionaryvalidation/src/test/java/org/onap/validation/yaml/YamlFileValidatorTest.java
index 089348d..5eb5dd5 100644
--- a/pmdictionaryvalidation/src/test/java/org/onap/validation/yaml/YamlFileValidatorTest.java
+++ b/pmdictionaryvalidation/src/test/java/org/onap/validation/yaml/YamlFileValidatorTest.java
@@ -17,7 +17,6 @@
package org.onap.validation.yaml;
-import org.assertj.core.util.Lists;
import org.junit.jupiter.api.Test;
import org.onap.validation.yaml.error.YamlDocumentValidationError;
import org.onap.validation.yaml.exception.YamlProcessingException;
@@ -26,32 +25,31 @@ import org.yaml.snakeyaml.parser.ParserException;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.catchThrowable;
class YamlFileValidatorTest {
@Test
void shouldReturnCorrectErrorsWhenGivenPathToValidPmDictionaryFile() throws YamlProcessingException {
- // given
+ //given
String path = getFullPathForGivenResources(YamlLoadingUtils.PATH_TO_VALID_YAML);
- // when
+ //when
List<YamlDocumentValidationError> validationErrors = new YamlFileValidator().validateYamlFileWithSchema(path);
- // then
+ //then
assertValidationReturnedExpectedErrors(validationErrors);
-
}
@Test
- void shouldReturnCorrecErrorsWhenGivenPathToValidJsonStylePmDictionaryFile() throws YamlProcessingException {
- // given
+ void shouldReturnCorrectErrorsWhenGivenPathToValidJsonStylePmDictionaryFile() throws YamlProcessingException {
+ //given
String path = getFullPathForGivenResources(YamlLoadingUtils.PATH_TO_VALID_JSON_STYLE_YAML);
- // when
+ //when
List<YamlDocumentValidationError> validationErrors = new YamlFileValidator().validateYamlFileWithSchema(path);
- // then
+ //then
assertValidationReturnedExpectedErrors(validationErrors);
}
@@ -62,7 +60,7 @@ class YamlFileValidatorTest {
.hasSize(4)
.usingRecursiveFieldByFieldElementComparator()
.containsAll(
- Lists.list(
+ List.of(
new YamlDocumentValidationError(1,
"/pmMetaData/pmFields/measResultType",
"Value(s) is/are not in array of accepted values.\n" +
@@ -85,21 +83,28 @@ class YamlFileValidatorTest {
@Test
void shouldThrowErrorWhenGivenPathToInvalidPmDictionaryFile() {
- // given
+ //given
String path = getFullPathForGivenResources(YamlLoadingUtils.PATH_TO_MULTI_DOCUMENT_INVALID_YAML);
- // when then
- assertThatThrownBy(() -> new YamlFileValidator().validateYamlFileWithSchema(path))
+
+ //when
+ Throwable ex = catchThrowable(() -> new YamlFileValidator().validateYamlFileWithSchema(path));
+
+ //then
+ assertThat(ex)
.isInstanceOf(ParserException.class)
.hasMessageContaining("expected the node content, but found '<document end>'");
}
@Test
void shouldThrowErrorWhenGivenInvalidPath() {
- // given
+ //given
String path = "invalid/path/to/pm_dictionary";
- // when then
- assertThatThrownBy(() -> new YamlFileValidator().validateYamlFileWithSchema(path))
+ //when
+ Throwable ex = catchThrowable(() -> new YamlFileValidator().validateYamlFileWithSchema(path));
+
+ //then
+ assertThat(ex)
.isInstanceOf(YamlProcessingException.class)
.hasMessageContaining("PM_Dictionary YAML file is empty");
}