-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First implementation of validation spec parsing -- WIP
- Loading branch information
1 parent
8ce0daf
commit 1f1e1fb
Showing
13 changed files
with
194 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
core/src/test/java/be/sddevelopment/validation/core/ContrainsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
core/src/test/java/be/sddevelopment/validation/core/InvalidObjectExceptionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 0 additions & 86 deletions
86
core/src/test/java/be/sddevelopment/validation/specs/code_quality/CodeConventionsTest.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...c/test/java/be/sddevelopment/validation/specs/code_quality/ConventionsAdherenceTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package be.sddevelopment.validation.specs.code_quality; | ||
|
||
import be.sddevelopment.commons.testing.conventions.CodeConventions; | ||
import be.sddevelopment.commons.testing.naming.ReplaceUnderscoredCamelCasing; | ||
import com.tngtech.archunit.core.domain.JavaClass; | ||
import com.tngtech.archunit.core.domain.JavaClasses; | ||
import com.tngtech.archunit.core.domain.JavaConstructor; | ||
import com.tngtech.archunit.junit.AnalyzeClasses; | ||
import com.tngtech.archunit.junit.ArchTest; | ||
import com.tngtech.archunit.lang.ArchCondition; | ||
import com.tngtech.archunit.lang.ArchRule; | ||
import com.tngtech.archunit.lang.ConditionEvents; | ||
import org.assertj.core.api.WithAssertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.DisplayNameGeneration; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.List; | ||
|
||
import static com.tngtech.archunit.core.domain.JavaModifier.FINAL; | ||
import static com.tngtech.archunit.lang.SimpleConditionEvent.satisfied; | ||
import static com.tngtech.archunit.lang.SimpleConditionEvent.violated; | ||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; | ||
import static com.tngtech.archunit.library.GeneralCodingRules.*; | ||
import static org.junit.platform.commons.util.ReflectionUtils.makeAccessible; | ||
|
||
@DisplayName("Complies with code conventions") | ||
@AnalyzeClasses(packages = "be.sddevelopment.validation.core") | ||
public class ConventionsAdherenceTests implements CodeConventions { | ||
|
||
/* This class can be empty, it is used to run the test of its parent interface | ||
* CodeConventions. This interface contains the tests for the code conventions, | ||
* and will execute them based on the {@code @AnalyzeClasses} annotation. | ||
*/ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
dsl/src/main/java/be/sddevelopment/validation/dsl/ValidatorParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package be.sddevelopment.validation.dsl; | ||
|
||
import be.sddevelopment.commons.access.AccessProtectionUtils; | ||
import be.sddevelopment.commons.annotations.Utility; | ||
import be.sddevelopment.validation.core.ModularRuleset; | ||
|
||
import java.nio.file.Path; | ||
|
||
import static be.sddevelopment.commons.access.AccessProtectionUtils.utilityClassConstructor; | ||
|
||
@Utility | ||
public final class ValidatorParser { | ||
|
||
private ValidatorParser() { | ||
utilityClassConstructor(); | ||
} | ||
|
||
public static ModularRuleset fromSpecification(Path validationSpec) { | ||
return null; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
dsl/src/test/java/be/sddevelopment/validation/dsl/ConventionsAdherenceTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package be.sddevelopment.validation.dsl; | ||
|
||
import be.sddevelopment.commons.testing.conventions.CodeConventions; | ||
import be.sddevelopment.commons.testing.naming.ReplaceUnderscoredCamelCasing; | ||
import com.tngtech.archunit.junit.AnalyzeClasses; | ||
import org.junit.jupiter.api.DisplayNameGeneration; | ||
|
||
@AnalyzeClasses(packages = "be.sddevelopment.commons") | ||
@DisplayNameGeneration(ReplaceUnderscoredCamelCasing.class) | ||
public class ConventionsAdherenceTests implements CodeConventions { | ||
|
||
/* This class can be empty, it is used to run the test of its parent interface | ||
* CodeConventions. This interface contains the tests for the code conventions, | ||
* and will execute them based on the {@code @AnalyzeClasses} annotation. | ||
*/ | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
dsl/src/test/java/be/sddevelopment/validation/dsl/ValidatorParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package be.sddevelopment.validation.dsl; | ||
|
||
import be.sddevelopment.commons.testing.naming.ReplaceUnderscoredCamelCasing; | ||
import be.sddevelopment.validation.core.ModularRuleset; | ||
import be.sddevelopment.validation.core.Rationale; | ||
import org.assertj.core.api.WithAssertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.DisplayNameGeneration; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Paths; | ||
|
||
@DisplayName("Parsing of validation rules") | ||
@DisplayNameGeneration(ReplaceUnderscoredCamelCasing.class) | ||
class ValidatorParserTest implements WithAssertions { | ||
|
||
@Test | ||
void createsAValidatorBasedOnSpecifications() throws IOException { | ||
var validationSpec = Paths.get("src/test/resources/parsing/star_wars/STARWARS_VALIDATOR.puml"); | ||
var dataFile = Paths.get("src/test/resources/parsing/star_wars/STARWARS_INPUT_DATA.csv"); | ||
assertThat(validationSpec).exists(); | ||
assertThat(validationSpec).isRegularFile(); | ||
|
||
var validator = ValidatorParser.fromSpecification(validationSpec); | ||
|
||
assertThat(validator).isNotNull(); | ||
|
||
var result = validator.check(dataFile); | ||
|
||
assertThat(result).isNotNull() | ||
.matches(Rationale::isPassing); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.