Skip to content

Commit

Permalink
Add test data and validation rules for the initial DSL implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
stijn-dejongh committed Nov 19, 2024
1 parent 62557f9 commit af3a524
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>be.sddevelopment</groupId>
<artifactId>modular-validators</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
36 changes: 35 additions & 1 deletion dsl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,51 @@
<parent>
<groupId>be.sddevelopment</groupId>
<artifactId>modular-validators</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>dsl</artifactId>

<description>
A Domain Specific Language (DSL) to define validation rules, using a PlantUML like syntax to enable easy
visualisation of the ruleset.
</description>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>be.sddevelopment</groupId>
<artifactId>core</artifactId>
</dependency>

<!-- BEGIN TEST SCOPE -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* <p>
* 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}.
* </p>
*
* @since 1.1.0-SNAPSHOT
*/
package be.sddevelopment.validation.dsl;
32 changes: 32 additions & 0 deletions dsl/src/test/resources/parsing/star_wars/STARWARS_INPUT_DATA.csv
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions dsl/src/test/resources/parsing/star_wars/STARWARS_VALIDATOR.puml
Original file line number Diff line number Diff line change
@@ -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')
}
}
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>be.sddevelopment</groupId>
<artifactId>modular-validators</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<description>
Expand Down Expand Up @@ -64,6 +64,18 @@
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>be.sddevelopment</groupId>
<artifactId>core</artifactId>
<version>${version}</version>
</dependency>

<dependency>
<groupId>be.sddevelopment</groupId>
<artifactId>dsl</artifactId>
<version>${version}</version>
</dependency>

<!-- BEGIN TEST SCOPE -->
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down

0 comments on commit af3a524

Please sign in to comment.