1 package com.networknt.schema; 2 3 import java.nio.file.Path; 4 import java.util.HashMap; 5 import java.util.Map; 6 import java.util.Optional; 7 import java.util.stream.Stream; 8 9 import org.junit.jupiter.api.DisplayName; 10 import org.junit.jupiter.api.DynamicNode; 11 import org.junit.jupiter.api.TestFactory; 12 13 import com.networknt.schema.SpecVersion.VersionFlag; 14 15 @DisplayName("JSON Schema Test Suite") 16 class JsonSchemaTestSuiteTest extends AbstractJsonSchemaTestSuite { 17 18 private final Map<Path, String> disabled; 19 JsonSchemaTestSuiteTest()20 public JsonSchemaTestSuiteTest() { 21 this.disabled = new HashMap<>(); 22 23 disableV202012Tests(); 24 disableV201909Tests(); 25 disableV7Tests(); 26 disableV6Tests(); 27 disableV4Tests(); 28 } 29 30 @TestFactory 31 @DisplayName("Draft 2020-12") draft2022012()32 Stream<DynamicNode> draft2022012() { 33 return createTests(VersionFlag.V202012, "src/test/suite/tests/draft2020-12"); 34 } 35 36 @TestFactory 37 @DisplayName("Draft 2019-09") draft201909()38 Stream<DynamicNode> draft201909() { 39 return createTests(VersionFlag.V201909, "src/test/suite/tests/draft2019-09"); 40 } 41 42 @TestFactory 43 @DisplayName("Draft 7") draft7()44 Stream<DynamicNode> draft7() { 45 return createTests(VersionFlag.V7, "src/test/suite/tests/draft7"); 46 } 47 48 @TestFactory 49 @DisplayName("Draft 6") draft6()50 Stream<DynamicNode> draft6() { 51 return createTests(VersionFlag.V6, "src/test/suite/tests/draft6"); 52 } 53 54 @TestFactory 55 @DisplayName("Draft 4") draft4()56 Stream<DynamicNode> draft4() { 57 return createTests(VersionFlag.V4, "src/test/suite/tests/draft4"); 58 } 59 60 @Override enabled(Path path)61 protected boolean enabled(Path path) { 62 return !this.disabled.containsKey(path); 63 } 64 65 @Override reason(Path path)66 protected Optional<String> reason(Path path) { 67 return Optional.ofNullable(this.disabled.get(path)); 68 } 69 disableV202012Tests()70 private void disableV202012Tests() { 71 // nothing here 72 } 73 disableV201909Tests()74 private void disableV201909Tests() { 75 // nothing here 76 } 77 disableV7Tests()78 private void disableV7Tests() { 79 // nothing here 80 } 81 disableV6Tests()82 private void disableV6Tests() { 83 // nothing here 84 } 85 disableV4Tests()86 private void disableV4Tests() { 87 // nothing here 88 } 89 90 } 91