diff --git a/core/pom.xml b/core/pom.xml index d8d62bb..9af4b2f 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -7,7 +7,7 @@ be.sddevelopment modular-validators - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml diff --git a/dsl/pom.xml b/dsl/pom.xml index 6202dca..dd8eb7b 100644 --- a/dsl/pom.xml +++ b/dsl/pom.xml @@ -7,17 +7,51 @@ be.sddevelopment modular-validators - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml dsl + + A Domain Specific Language (DSL) to define validation rules, using a PlantUML like syntax to enable easy + visualisation of the ruleset. + + 21 21 UTF-8 + + + be.sddevelopment + core + + + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.assertj + assertj-core + test + + + org.mockito + mockito-junit-jupiter + test + + + \ No newline at end of file diff --git a/dsl/src/main/java/be/sddevelopment/validation/dsl/package-info.java b/dsl/src/main/java/be/sddevelopment/validation/dsl/package-info.java new file mode 100644 index 0000000..084a365 --- /dev/null +++ b/dsl/src/main/java/be/sddevelopment/validation/dsl/package-info.java @@ -0,0 +1,9 @@ +/** + *

+ * Contains the domain-specific language classes (DSL) for the validation framework. These classes are used to create the validation rules, based on the DSL specifications provided to it. + * The most notable entries are {@link be.sddevelopment.validation.dsl.ValidatorParser}. + *

+ * + * @since 1.1.0-SNAPSHOT + */ +package be.sddevelopment.validation.dsl; \ No newline at end of file diff --git a/dsl/src/test/resources/parsing/star_wars/STARWARS_INPUT_DATA.csv b/dsl/src/test/resources/parsing/star_wars/STARWARS_INPUT_DATA.csv new file mode 100644 index 0000000..4779c16 --- /dev/null +++ b/dsl/src/test/resources/parsing/star_wars/STARWARS_INPUT_DATA.csv @@ -0,0 +1,32 @@ +NAME,HEIGHT,MASS,HAIR_COLOR,SKIN_COLOR,EYE_COLOR,BIRTH_YEAR,GENDER,HOMEWORLD,SPECIES +Luke Skywalker,172,77,blond,fair,blue,19BBY,male,Tatooine,Human +C-3PO,167,75,NA,gold,yellow,112BBY,NA,Tatooine,Droid +R2-D2,96,32,NA,"white, blue",red,33BBY,NA,Naboo,Droid +Darth Vader,202,136,none,white,yellow,41.9BBY,male,Tatooine,Human +Leia Organa,150,49,brown,light,brown,19BBY,female,Alderaan,Human +Owen Lars,178,120,"brown, grey",light,blue,52BBY,male,Tatooine,Human +Beru Whitesun lars,165,75,brown,light,blue,47BBY,female,Tatooine,Human +R5-D4,97,32,NA,"white, red",red,NA,NA,Tatooine,Droid +Biggs Darklighter,183,84,black,light,brown,24BBY,male,Tatooine,Human +Obi-Wan Kenobi,182,77,"auburn, white",fair,blue-gray,57BBY,male,Stewjon,Human +Anakin Skywalker,188,84,blond,fair,blue,41.9BBY,male,Tatooine,Human +Wilhuff Tarkin,180,NA,"auburn, grey",fair,blue,64BBY,male,Eriadu,Human +Chewbacca,228,112,brown,NA,blue,200BBY,male,Kashyyyk,Wookiee +Han Solo,180,80,brown,fair,brown,29BBY,male,Corellia,Human +Greedo,173,74,NA,green,black,44BBY,male,Rodia,Rodian +Jabba Desilijic Tiure,175,"1,358",NA,"green-tan, brown",orange,600BBY,hermaphrodite,Nal Hutta,Hutt +Wedge Antilles,170,77,brown,fair,hazel,21BBY,male,Corellia,Human +Jek Tono Porkins,180,110,brown,fair,blue,NA,male,Bestine IV,Human +Yoda,66,17,white,green,brown,896BBY,male,NA,Yoda's species +Palpatine,170,75,grey,pale,yellow,82BBY,male,Naboo,Human +Boba Fett,183,78.2,black,fair,brown,31.5BBY,male,Kamino,Human +IG-88,200,140,none,metal,red,15BBY,none,NA,Droid +Bossk,190,113,none,green,red,53BBY,male,Trandosha,Trandoshan +Lando Calrissian,177,79,black,dark,brown,31BBY,male,Socorro,Human +Lobot,175,79,none,light,blue,37BBY,male,Bespin,Human +Ackbar,180,83,none,brown mottle,orange,41BBY,male,Mon Cala,Mon Calamari +Mon Mothma,150,NA,auburn,fair,blue,48BBY,female,Chandrila,Human +Arvel Crynyd,NA,NA,brown,fair,brown,NA,male,NA,Human +Wicket Systri Warrick,88,20,brown,brown,brown,8BBY,male,Endor,Ewok +Nien Nunb,160,68,none,grey,black,NA,male,Sullust,Sullustan +Qui-Gon Jinn,193,89,brown,fair,blue,92BBY,male,NA,Human diff --git a/dsl/src/test/resources/parsing/star_wars/STARWARS_VALIDATOR.puml b/dsl/src/test/resources/parsing/star_wars/STARWARS_VALIDATOR.puml new file mode 100644 index 0000000..a487a35 --- /dev/null +++ b/dsl/src/test/resources/parsing/star_wars/STARWARS_VALIDATOR.puml @@ -0,0 +1,28 @@ +ValidatorFor(".*STARWARS.*\\.csv") { + Header{ + Field('NAME') + Field('HEIGHT') + Field('MASS') + Field('HAIR_COLOR') + Field('SKIN_COLOR') + Field('EYE_COLOR') + Field('BIRTH_YEAR') + Field('GENDER') + Field('HOMEWORLD') + Field('SPECIES') + } + FieldPopulated('SPECIES') + RecordIdentifier('NAME') + + ValidationCase("GoldenBoy") { + RecordExists('C-3PO') + RecordHasValue('C-3PO', 'SKIN_COLOR', 'gold') + RecordHasValue('C-3PO', 'SPECIES', 'Droid') + } + + ValidationCase("The true protagonist") { + RecordExists('R2-D2') + RecordHasValue('R2-D2', 'SKIN_COLOR', 'white, blue') + RecordHasValue('R2-D2', 'SPECIES', 'Droid') + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 6cd1ec2..29006bb 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ be.sddevelopment modular-validators - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT pom @@ -64,6 +64,18 @@ + + be.sddevelopment + core + ${version} + + + + be.sddevelopment + dsl + ${version} + + org.junit.jupiter