-
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.
Verify that log files contain constraint errors (#4)
- Loading branch information
Showing
6 changed files
with
128 additions
and
4 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
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,7 @@ | ||
Info: validate data... | ||
Info: assume unknown external objects | ||
Info: first validation pass... | ||
Info: second validation pass... | ||
Info: validate mandatory constraint ModelA.TopicA.ClassA.ConstraintA... | ||
Error: line 10: ModelA.TopicA.ClassA: tid 1: Mandatory Constraint ModelA.TopicA.ClassA.ConstraintA is not true. | ||
Info: validate mandatory constraint ModelA.TopicA.ClassA.ConstraintB... |
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
48 changes: 48 additions & 0 deletions
48
src/test/java/ch/geowerkstatt/interlis/testbed/runner/ValidatorTest.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,48 @@ | ||
package ch.geowerkstatt.interlis.testbed.runner; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public final class ValidatorTest { | ||
private static final String CONSTRAINT_A_NAME = "ModelA.TopicA.ClassA.ConstraintA"; | ||
private static final String CONSTRAINT_B_NAME = "ModelA.TopicA.ClassA.ConstraintB"; | ||
private static final Path BASE_PATH = Path.of("src/test/data/validator"); | ||
private static final Path LOG_FILE = BASE_PATH.resolve("logfile.log"); | ||
|
||
private TestOptions options; | ||
|
||
@BeforeEach | ||
public void setup() { | ||
options = new TestOptions(BASE_PATH, Path.of("ilivalidator.jar")); | ||
} | ||
|
||
@Test | ||
public void containsConstraintError() throws ValidatorException { | ||
var validator = new InterlisValidator(options); | ||
|
||
var result = validator.containsConstraintError(LOG_FILE, CONSTRAINT_A_NAME); | ||
|
||
assertTrue(result, "The log file should contain an error for constraint A."); | ||
} | ||
|
||
@Test | ||
public void noErrorForValidConstraint() throws ValidatorException, IOException { | ||
var validator = new InterlisValidator(options); | ||
|
||
var result = validator.containsConstraintError(LOG_FILE, CONSTRAINT_B_NAME); | ||
|
||
assertFalse(result, "The log file should not contain an error for constraint B."); | ||
|
||
try (var lines = Files.lines(LOG_FILE)) { | ||
var hasConstraintInfo = lines.anyMatch(line -> line.startsWith("Info:") && line.contains(CONSTRAINT_B_NAME)); | ||
assertTrue(hasConstraintInfo, "The log file should contain an info message for the constraint."); | ||
} | ||
} | ||
} |