-
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.
- Loading branch information
Showing
3 changed files
with
98 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
INTERLIS 2.4; | ||
|
||
MODEL TestSuite | ||
AT "mailto:[email protected]" VERSION "2022-12-02" = | ||
IMPORTS GeoW_FunctionsExt; | ||
|
||
TOPIC FunctionTestTopic = | ||
|
||
CLASS ReferencedClass = | ||
textAttr: TEXT*16; | ||
enumAttr: (val1,val2,val3); | ||
numberAttr: 0..10; | ||
END ReferencedClass; | ||
|
||
CLASS BaseClass = | ||
MANDATORY CONSTRAINT trueConstraintTextAttr: INTERLIS.elementCount(GeoW_FunctionsExt.FindObjects("TestSuite.FunctionTestTopic.ReferencedClass", "textAttr", "Some Value")) == 2; | ||
MANDATORY CONSTRAINT trueConstraintEnumAttr: INTERLIS.elementCount(GeoW_FunctionsExt.FindObjects("TestSuite.FunctionTestTopic.ReferencedClass", "enumAttr", #val2)) == 3; | ||
MANDATORY CONSTRAINT trueConstraintNumberAttr: INTERLIS.elementCount(GeoW_FunctionsExt.FindObjects("TestSuite.FunctionTestTopic.ReferencedClass", "numberAttr", 3)) == 0; | ||
MANDATORY CONSTRAINT falseConstraintTextAttr: INTERLIS.elementCount(GeoW_FunctionsExt.FindObjects("TestSuite.FunctionTestTopic.ReferencedClass", "textAttr", "Some Value")) == 0; | ||
MANDATORY CONSTRAINT falseConstraintEnumAttr: INTERLIS.elementCount(GeoW_FunctionsExt.FindObjects("TestSuite.FunctionTestTopic.ReferencedClass", "enumAttr", #val2)) == 0; | ||
MANDATORY CONSTRAINT falseConstraintNumberAttr: INTERLIS.elementCount(GeoW_FunctionsExt.FindObjects("TestSuite.FunctionTestTopic.ReferencedClass", "numberAttr", 3)) == 2; | ||
END BaseClass; | ||
|
||
END FunctionTestTopic; | ||
|
||
END TestSuite. |
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,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ili:transfer xmlns:ili="http://www.interlis.ch/xtf/2.4/INTERLIS" xmlns:geom="http://www.interlis.ch/geometry/1.0" | ||
xmlns:TestSuite="http://www.interlis.ch/xtf/2.4/TestSuite"> | ||
<ili:headersection> | ||
<ili:models> | ||
<ili:model>GeoW_FunctionsExt</ili:model> | ||
<ili:model>TestSuite</ili:model> | ||
</ili:models> | ||
<ili:sender>ili2gpkg-4.6.1-63db90def1260a503f0f2d4cb846686cd4851184</ili:sender> | ||
</ili:headersection> | ||
<ili:datasection> | ||
<TestSuite:FunctionTestTopic ili:bid="TestSuite.FunctionTestTopic"> | ||
<TestSuite:BaseClass ili:tid="base"> | ||
</TestSuite:BaseClass> | ||
<TestSuite:ReferencedClass ili:tid="1"> | ||
<TestSuite:textAttr>Some Value</TestSuite:textAttr> | ||
<TestSuite:enumAttr>val2</TestSuite:enumAttr> | ||
<TestSuite:numberAttr>2</TestSuite:numberAttr> | ||
</TestSuite:ReferencedClass> | ||
<TestSuite:ReferencedClass ili:tid="2"> | ||
<TestSuite:textAttr>aaa</TestSuite:textAttr> | ||
<TestSuite:enumAttr>val2</TestSuite:enumAttr> | ||
<TestSuite:numberAttr>2</TestSuite:numberAttr> | ||
</TestSuite:ReferencedClass> | ||
<TestSuite:ReferencedClass ili:tid="3"> | ||
<TestSuite:textAttr>aaa</TestSuite:textAttr> | ||
<TestSuite:enumAttr>val2</TestSuite:enumAttr> | ||
<TestSuite:numberAttr>2</TestSuite:numberAttr> | ||
</TestSuite:ReferencedClass> | ||
<TestSuite:ReferencedClass ili:tid="4"> | ||
<TestSuite:textAttr>Some Value</TestSuite:textAttr> | ||
<TestSuite:enumAttr>val3</TestSuite:enumAttr> | ||
<TestSuite:numberAttr>1</TestSuite:numberAttr> | ||
</TestSuite:ReferencedClass> | ||
<TestSuite:ReferencedClass ili:tid="5"> | ||
<TestSuite:textAttr>bbb</TestSuite:textAttr> | ||
<TestSuite:enumAttr>val1</TestSuite:enumAttr> | ||
<TestSuite:numberAttr>1</TestSuite:numberAttr> | ||
</TestSuite:ReferencedClass> | ||
</TestSuite:FunctionTestTopic> | ||
</ili:datasection> | ||
</ili:transfer> |
30 changes: 30 additions & 0 deletions
30
...test/java/ch/geowerkstatt/ilivalidator/extensions/functions/FindObjectsIoxPluginTest.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,30 @@ | ||
package ch.geowerkstatt.ilivalidator.extensions.functions; | ||
|
||
import ch.interlis.ili2c.Ili2cFailure; | ||
import ch.interlis.iox.IoxException; | ||
import com.vividsolutions.jts.util.Assert; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class FindObjectsIoxPluginTest { | ||
protected static final String TEST_DATA = "FindObjects/TestData.xtf"; | ||
private ValidationTestHelper vh = null; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
vh = new ValidationTestHelper(); | ||
vh.addFunction(new FindObjectsIoxPlugin()); | ||
} | ||
|
||
@Test | ||
void mandatoryConstraint() throws Ili2cFailure, IoxException { | ||
vh.runValidation(new String[]{TEST_DATA}, new String[]{"FindObjects/MandatoryConstraints.ili"}); | ||
Assert.equals(3, vh.getErrs().size()); | ||
AssertionHelper.assertNoConstraintError(vh, "trueConstraintTextAttr"); | ||
AssertionHelper.assertNoConstraintError(vh, "trueConstraintEnumAttr"); | ||
AssertionHelper.assertNoConstraintError(vh, "trueConstraintNumberAttr"); | ||
AssertionHelper.assertConstraintErrors(vh, 1, "base", "falseConstraintTextAttr"); | ||
AssertionHelper.assertConstraintErrors(vh, 1, "base", "falseConstraintEnumAttr"); | ||
AssertionHelper.assertConstraintErrors(vh, 1, "base", "falseConstraintNumberAttr"); | ||
} | ||
} |