From b698fd26453cd5a05b5762f112689f788492c404 Mon Sep 17 00:00:00 2001 From: Patrick Ackermann Date: Fri, 22 Sep 2023 09:00:14 +0200 Subject: [PATCH 1/4] Enable checkstyle Use the sun_checks config from https://github.com/checkstyle/checkstyle/blob/ccc12eb6d7f6c8e0876077e7883cf8f59a541a37/src/main/resources/sun_checks.xml --- build.gradle | 1 + config/checkstyle/checkstyle.xml | 198 +++++++++++++++++++++++++++++++ 2 files changed, 199 insertions(+) create mode 100644 config/checkstyle/checkstyle.xml diff --git a/build.gradle b/build.gradle index 57bca0e..4acf810 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ plugins { id 'maven-publish' id 'signing' id("io.github.gradle-nexus.publish-plugin") version "1.1.0" + id 'checkstyle' } group = 'ch.geowerkstatt.ilivalidator.extensions.functions' diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000..1278ab7 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 17edfc0ba6083d447b73274af2ae7918215dd53e Mon Sep 17 00:00:00 2001 From: Patrick Ackermann Date: Fri, 22 Sep 2023 09:00:14 +0200 Subject: [PATCH 2/4] Customize checkstyle config and fix violations --- config/checkstyle/checkstyle.xml | 26 ++++++++---- .../functions/BaseInterlisFunction.java | 6 +-- .../functions/EvaluationHelper.java | 26 +++++++++++- .../functions/GetAreaIoxPlugin.java | 3 +- .../functions/GetInGroupsIoxPlugin.java | 31 +++++++------- .../GetInnerRingsCountIoxPlugin.java | 8 ++-- .../functions/GetLengthIoxPlugin.java | 3 +- .../IsInsideExternalDatasetIoxPlugin.java | 40 +++++++++---------- 8 files changed, 84 insertions(+), 59 deletions(-) diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 1278ab7..0fe4814 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -58,7 +58,7 @@ - + @@ -73,6 +73,7 @@ + @@ -100,9 +101,14 @@ - + + + + - + + + @@ -120,7 +126,9 @@ - + + + @@ -162,10 +170,10 @@ - + - + @@ -177,12 +185,14 @@ - + + + - + diff --git a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/BaseInterlisFunction.java b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/BaseInterlisFunction.java index e25adf9..2368229 100644 --- a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/BaseInterlisFunction.java +++ b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/BaseInterlisFunction.java @@ -18,7 +18,7 @@ public abstract class BaseInterlisFunction implements InterlisFunction { protected Validator validator; @Override - public void init(TransferDescription td, Settings settings, IoxValidationConfig validationConfig, ObjectPool objectPool, LogEventFactory logEventFactory) { + public final void init(TransferDescription td, Settings settings, IoxValidationConfig validationConfig, ObjectPool objectPool, LogEventFactory logEventFactory) { this.logger = logEventFactory; this.logger.setValidationConfig(validationConfig); this.td = td; @@ -27,10 +27,10 @@ public void init(TransferDescription td, Settings settings, IoxValidationConfig } @Override - public Value evaluate(String validationKind, String usageScope, IomObject mainObj, Value[] actualArguments) { + public final Value evaluate(String validationKind, String usageScope, IomObject mainObj, Value[] actualArguments) { for (Value arg : actualArguments) { - if (arg.skipEvaluation()){ + if (arg.skipEvaluation()) { return arg; } } diff --git a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/EvaluationHelper.java b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/EvaluationHelper.java index cb6f43b..30331d3 100644 --- a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/EvaluationHelper.java +++ b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/EvaluationHelper.java @@ -16,7 +16,21 @@ import java.util.Iterator; import java.util.function.Function; -public class EvaluationHelper { +public final class EvaluationHelper { + + private EvaluationHelper() { + // Utility class + } + + /** + * Parse the {@code argPath} into a {@link PathEl} array. + * + * @param validator the {@link Validator} instance. + * @param contextClass the {@link Viewable} definition where the {@code argPath} starts. + * @param argPath the path string to parse. see {@link Value#getValue()}. + * + * @return the parsed {@link PathEl} array or {@code null} if the {@code argPath} could not be parsed. + */ public static PathEl[] getAttributePathEl(Validator validator, Viewable contextClass, Value argPath) { try { ObjectPath objectPath = validator.parseObjectOrAttributePath(contextClass, argPath.getValue()); @@ -29,6 +43,10 @@ public static PathEl[] getAttributePathEl(Validator validator, Viewable return null; } + /** + * Get the {@link Viewable} (e.g. the class definition) from the {@link TransferDescription}. + * If the {@code iomObject} is {@code null}, the {@code argObjects} is used to retrieve the {@link Viewable}. + */ public static Viewable getContextClass(TransferDescription td, IomObject iomObject, Value argObjects) { if (iomObject != null) { return (Viewable) td.getElement(iomObject.getobjecttag()); @@ -44,6 +62,9 @@ public static Viewable getContextClass(TransferDescription td, IomObject iomObje return null; } + /** + * Get the collection of {@link IomObject} inside {@code argObjects} by following the provided {@code attributePath}. + */ public static Collection evaluateAttributes(Validator validator, Value argObjects, PathEl[] attributePath) { Collection attributes = new ArrayList<>(); @@ -57,6 +78,9 @@ public static Collection evaluateAttributes(Validator validator, Valu return attributes; } + /** + * Applies the given function to each item in the collection and sums up the results. + */ public static Double sum(Collection items, Function func) { return items .stream() diff --git a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetAreaIoxPlugin.java b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetAreaIoxPlugin.java index f3be83e..501fe07 100644 --- a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetAreaIoxPlugin.java +++ b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetAreaIoxPlugin.java @@ -7,10 +7,9 @@ import ch.interlis.iox_j.jts.Iox2jtsext; import ch.interlis.iox_j.validator.Value; -import java.util.ArrayList; import java.util.Collection; -public class GetAreaIoxPlugin extends BaseInterlisFunction { +public final class GetAreaIoxPlugin extends BaseInterlisFunction { @Override public String getQualifiedIliName() { diff --git a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInGroupsIoxPlugin.java b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInGroupsIoxPlugin.java index 4b5f287..687e798 100644 --- a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInGroupsIoxPlugin.java +++ b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInGroupsIoxPlugin.java @@ -5,15 +5,9 @@ import ch.interlis.iom.IomObject; import ch.interlis.iox_j.validator.Value; -import java.security.acl.Group; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; -public class GetInGroupsIoxPlugin extends BaseInterlisFunction { +public final class GetInGroupsIoxPlugin extends BaseInterlisFunction { private static Map> groups = new HashMap<>(); @@ -43,17 +37,17 @@ public Value evaluateInternal(String validationKind, String usageScope, IomObjec PathEl[] attributePath = EvaluationHelper.getAttributePathEl(validator, contextClass, argPath); GroupKey key = new GroupKey(inputObjects, validator.getValueFromObjectPath(null, contextObject, attributePath, null)); - if(!groups.containsKey(key)){ - FillGroups(inputObjects, attributePath); + if (!groups.containsKey(key)) { + fillGroups(inputObjects, attributePath); } return new Value(groups.get(key)); } - private void FillGroups(Collection inputObjects, PathEl[] attributePath) { + private void fillGroups(Collection inputObjects, PathEl[] attributePath) { for (IomObject object: inputObjects) { GroupKey key = new GroupKey(inputObjects, validator.getValueFromObjectPath(null, object, attributePath, null)); - if(!groups.containsKey(key)){ + if (!groups.containsKey(key)) { groups.put(key, new ArrayList<>()); } @@ -61,19 +55,22 @@ private void FillGroups(Collection inputObjects, PathEl[] attributePa } } - private static class GroupKey - { + private static final class GroupKey { private Collection inputObjects; private Value groupId; - public GroupKey(Collection inputObjects, Value groupId){ + GroupKey(Collection inputObjects, Value groupId) { this.inputObjects = inputObjects; this.groupId = groupId; } @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } GroupKey that = (GroupKey) o; return inputObjects.equals(that.inputObjects) && groupId.compareTo(that.groupId) == 0; } diff --git a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInnerRingsCountIoxPlugin.java b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInnerRingsCountIoxPlugin.java index 2c990c3..e5da813 100644 --- a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInnerRingsCountIoxPlugin.java +++ b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInnerRingsCountIoxPlugin.java @@ -3,20 +3,18 @@ import ch.interlis.ili2c.metamodel.PathEl; import ch.interlis.ili2c.metamodel.Viewable; import ch.interlis.iom.IomObject; -import ch.interlis.iox.IoxException; -import ch.interlis.iox_j.jts.Iox2jtsext; import ch.interlis.iox_j.validator.Value; import java.util.Collection; -public class GetInnerRingsCountIoxPlugin extends BaseInterlisFunction { +public final class GetInnerRingsCountIoxPlugin extends BaseInterlisFunction { @Override public String getQualifiedIliName() { return "GeoW_FunctionsExt.GetInnerRingsCount"; } - private Integer GetInnerRingsCount(IomObject multisurface) { + private Integer getInnerRingsCount(IomObject multisurface) { int innerRings = 0; for (int si = 0; si < multisurface.getattrvaluecount("surface"); si++) { @@ -55,7 +53,7 @@ public Value evaluateInternal(String validationKind, String usageScope, IomObjec surfaces = EvaluationHelper.evaluateAttributes(validator, argObjects, attributePath); } - int innerRingsCount = surfaces.stream().map(this::GetInnerRingsCount).reduce(0, Integer::sum); + int innerRingsCount = surfaces.stream().map(this::getInnerRingsCount).reduce(0, Integer::sum); return new Value(innerRingsCount); } } diff --git a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetLengthIoxPlugin.java b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetLengthIoxPlugin.java index 6f8922d..234bb48 100644 --- a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetLengthIoxPlugin.java +++ b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetLengthIoxPlugin.java @@ -7,10 +7,9 @@ import ch.interlis.iox_j.jts.Iox2jtsext; import ch.interlis.iox_j.validator.Value; -import java.util.ArrayList; import java.util.Collection; -public class GetLengthIoxPlugin extends BaseInterlisFunction { +public final class GetLengthIoxPlugin extends BaseInterlisFunction { @Override public String getQualifiedIliName() { diff --git a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPlugin.java b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPlugin.java index 79a80be..d896be8 100644 --- a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPlugin.java +++ b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPlugin.java @@ -1,18 +1,17 @@ package ch.geowerkstatt.ilivalidator.extensions.functions; -import ch.ehi.basics.settings.Settings; import ch.ehi.basics.types.OutParam; -import ch.interlis.ili2c.metamodel.TransferDescription; import ch.interlis.iom.IomObject; import ch.interlis.iom_j.Iom_jObject; import ch.interlis.iom_j.itf.impl.jtsext.geom.CompoundCurve; import ch.interlis.iom_j.xtf.XtfReader; import ch.interlis.iom_j.xtf.XtfStartTransferEvent; -import ch.interlis.iox.*; +import ch.interlis.iox.IoxEvent; +import ch.interlis.iox.IoxException; +import ch.interlis.iox.IoxReader; +import ch.interlis.iox.ObjectEvent; import ch.interlis.iox_j.jts.Iox2jtsext; -import ch.interlis.iox_j.logging.LogEventFactory; import ch.interlis.iox_j.utility.IoxUtility; -import ch.interlis.iox_j.validator.ObjectPool; import ch.interlis.iox_j.validator.Value; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; @@ -33,21 +32,16 @@ import java.util.jar.JarFile; import java.util.stream.Collectors; -public class IsInsideExternalDatasetIoxPlugin extends BaseInterlisFunction { +public final class IsInsideExternalDatasetIoxPlugin extends BaseInterlisFunction { private static File dataDirectory; private static Map> modelFilesFromDataDirectory; private static Map> modelFilesFromJars; - private static final Map validAreaCache = new HashMap<>(); - private static final String qualifiedIliName = "GeoW_FunctionsExt.IsInsideExternalDataset"; + private static final Map VALID_AREA_CACHE = new HashMap<>(); + private static final String QUALIFIED_ILI_NAME = "GeoW_FunctionsExt.IsInsideExternalDataset"; @Override public String getQualifiedIliName() { - return qualifiedIliName; - } - - @Override - public void init(TransferDescription td, Settings settings, IoxValidationConfig validationConfig, ObjectPool objectPool, LogEventFactory logEventFactory) { - super.init(td, settings, validationConfig, objectPool, logEventFactory); + return QUALIFIED_ILI_NAME; } @Override @@ -66,7 +60,7 @@ protected Value evaluateInternal(String validationKind, String usageScope, IomOb String datasetName = argDatasetName.getValue(); ValidAreaKey key = new ValidAreaKey(datasetName, transferIds); - Geometry validArea = validAreaCache.computeIfAbsent(key, this::getValidArea); + Geometry validArea = VALID_AREA_CACHE.computeIfAbsent(key, this::getValidArea); if (validArea == null) { return Value.createUndefined(); @@ -196,11 +190,11 @@ private Map> analyzeDataDirectory(File dataDirectory) { } } catch (IoxException e) { // ignore the erroneous file - logger.addEvent(logger.logWarningMsg("{0}: Error while reading xtf file {1}. {2}", qualifiedIliName, xtfUrl.toString(), e.getLocalizedMessage())); + logger.addEvent(logger.logWarningMsg("{0}: Error while reading xtf file {1}. {2}", QUALIFIED_ILI_NAME, xtfUrl.toString(), e.getLocalizedMessage())); } } } catch (IOException e) { - logger.addEvent(logger.logWarningMsg("{0}: Could not read data directory {1}. {2}", qualifiedIliName, dataDirectory.getAbsolutePath(), e.getLocalizedMessage())); + logger.addEvent(logger.logWarningMsg("{0}: Could not read data directory {1}. {2}", QUALIFIED_ILI_NAME, dataDirectory.getAbsolutePath(), e.getLocalizedMessage())); } return result; @@ -235,13 +229,13 @@ private Map> analyzeClasspathResources() { } } catch (IoxException e) { // ignore the erroneous file - logger.addEvent(logger.logWarningMsg("{0}: Error while reading xtf file {1}. {2}", qualifiedIliName, xtfUrl.toString(), e.getLocalizedMessage())); + logger.addEvent(logger.logWarningMsg("{0}: Error while reading xtf file {1}. {2}", QUALIFIED_ILI_NAME, xtfUrl.toString(), e.getLocalizedMessage())); } } } } } catch (IOException e) { - logger.addEvent(logger.logWarningMsg("{0}: Could not read JAR files from classpath. {2}", qualifiedIliName, e.getLocalizedMessage())); + logger.addEvent(logger.logWarningMsg("{0}: Could not read JAR files from classpath. {2}", QUALIFIED_ILI_NAME, e.getLocalizedMessage())); } return result; @@ -396,8 +390,12 @@ private static class ValidAreaKey { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } ValidAreaKey that = (ValidAreaKey) o; return Objects.equals(datasetName, that.datasetName) && Arrays.equals(transferIds, that.transferIds); } From ed5fc4df4a988cb7d83c86b5cb3b84d825078306 Mon Sep 17 00:00:00 2001 From: Patrick Ackermann Date: Fri, 22 Sep 2023 09:00:14 +0200 Subject: [PATCH 3/4] Fix violations in tests and suppress some checks --- config/checkstyle/checkstyle.xml | 3 +-- config/checkstyle/suppressions.xml | 12 ++++++++++++ .../extensions/functions/AssertionHelper.java | 17 ++++++++++++----- .../functions/GetAreaIoxPluginTest.java | 14 +++++++------- .../functions/GetInGroupsIoxPluginTest.java | 3 +-- .../GetInnerringsCountIoxPluginTest.java | 3 +-- .../functions/GetLengthIoxPluginTest.java | 14 +++++++------- .../IsInsideExternalDatasetIoxPluginTest.java | 6 +++--- .../extensions/functions/LogCollector.java | 6 +++--- .../functions/ValidationTestHelper.java | 6 +++--- 10 files changed, 50 insertions(+), 34 deletions(-) create mode 100644 config/checkstyle/suppressions.xml diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 0fe4814..7789e88 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -51,8 +51,7 @@ - + diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml new file mode 100644 index 0000000..9f935b1 --- /dev/null +++ b/config/checkstyle/suppressions.xml @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/AssertionHelper.java b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/AssertionHelper.java index 5b1a3cc..2ade885 100644 --- a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/AssertionHelper.java +++ b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/AssertionHelper.java @@ -8,13 +8,18 @@ import static org.junit.jupiter.api.Assertions.fail; -public class AssertionHelper { +public final class AssertionHelper { + + private AssertionHelper() { + // Utility class + } public static void assertConstraintErrors(ValidationTestHelper vh, int expectedCount, String oid, String constraintName) { int errorsFound = 0; for (IoxLogEvent err : vh.getErrs()) { - if (oid.equals(err.getSourceObjectXtfId()) && err.getEventMsg().contains(String.format(".%s ", constraintName))) + if (oid.equals(err.getSourceObjectXtfId()) && err.getEventMsg().contains(String.format(".%s ", constraintName))) { errorsFound++; + } } Assert.equals(expectedCount, errorsFound, @@ -28,8 +33,9 @@ public static void assertSingleConstraintError(ValidationTestHelper vh, int oid, public static void assertConstraintErrors(ValidationTestHelper vh, int expectedCount, String constraintName) { int errorsFound = 0; for (IoxLogEvent err : vh.getErrs()) { - if (err.getEventMsg().contains(String.format(".%s ", constraintName))) + if (err.getEventMsg().contains(String.format(".%s ", constraintName))) { errorsFound++; + } } Assert.equals(expectedCount, errorsFound, @@ -39,14 +45,15 @@ public static void assertConstraintErrors(ValidationTestHelper vh, int expectedC public static void assertNoConstraintError(ValidationTestHelper vh, String constraintName) { int errorsFound = 0; for (IoxLogEvent err : vh.getErrs()) { - if (err.getEventMsg().contains(String.format(".%s ", constraintName))) + if (err.getEventMsg().contains(String.format(".%s ", constraintName))) { errorsFound++; + } } Assert.equals(0, errorsFound, String.format("Expected No errors with Source <%s> but found %d.", constraintName, errorsFound)); } - + public static void assertLogEventsContainMessage(List logs, String expectedMessageRegex) { Pattern pattern = Pattern.compile(expectedMessageRegex); if (logs.stream().noneMatch(log -> pattern.matcher(log.getEventMsg()).find())) { diff --git a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetAreaIoxPluginTest.java b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetAreaIoxPluginTest.java index 2b18d0d..369c2ac 100644 --- a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetAreaIoxPluginTest.java +++ b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetAreaIoxPluginTest.java @@ -19,7 +19,7 @@ void setUp() { } @Test - void MandatoryConstraintOnThis() throws Ili2cFailure, IoxException { + void mandatoryConstraintOnThis() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{TEST_DATA}, new String[]{"GetArea/MandatoryConstraintThis.ili"}); Assert.equals(4, vh.getErrs().size()); AssertionHelper.assertSingleConstraintError(vh, 0, "Constraint1"); @@ -29,7 +29,7 @@ void MandatoryConstraintOnThis() throws Ili2cFailure, IoxException { } @Test - void SetConstraintOnAll() throws Ili2cFailure, IoxException { + void setConstraintOnAll() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{TEST_DATA}, new String[]{"GetArea/SetConstraintAll.ili"}); Assert.equals(3, vh.getErrs().size()); AssertionHelper.assertNoConstraintError(vh, "Constraint1"); @@ -40,7 +40,7 @@ void SetConstraintOnAll() throws Ili2cFailure, IoxException { } @Test - void SetConstraintOnThis() throws Ili2cFailure, IoxException { + void setConstraintOnThis() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{TEST_DATA}, new String[]{"GetArea/SetConstraintThis.ili"}); Assert.equals(2, vh.getErrs().size()); AssertionHelper.assertSingleConstraintError(vh, 0, "Constraint2"); @@ -49,7 +49,7 @@ void SetConstraintOnThis() throws Ili2cFailure, IoxException { @Test @Disabled("XTF24Reader fails on reading Bag Of Struct") - void SetConstraintOnThisWithBagOfStruct() throws Ili2cFailure, IoxException { + void setConstraintOnThisWithBagOfStruct() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{"GetArea/TestDataBagOf.xtf"}, new String[]{"GetArea/SetConstraintBagOf.ili"}); Assert.equals(1, vh.getErrs().size()); AssertionHelper.assertNoConstraintError(vh, "Constraint1"); @@ -60,7 +60,7 @@ void SetConstraintOnThisWithBagOfStruct() throws Ili2cFailure, IoxException { } @Test - void SetConstraintOnAssociationOne2Many() throws Ili2cFailure, IoxException { + void setConstraintOnAssociationOne2Many() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{"GetArea/TestDataAssocOne2Many.xtf"}, new String[]{"GetArea/SetConstraintAssocOne2Many.ili"}); AssertionHelper.assertNoConstraintError(vh, "Constraint1"); @@ -79,7 +79,7 @@ void SetConstraintOnAssociationOne2Many() throws Ili2cFailure, IoxException { } @Test - void SetConstraintOnAssociationMany2Many() throws Ili2cFailure, IoxException { + void setConstraintOnAssociationMany2Many() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{"GetArea/TestDataAssocMany2Many.xtf"}, new String[]{"GetArea/SetConstraintAssocMany2Many.ili"}); AssertionHelper.assertNoConstraintError(vh, "Constraint1"); @@ -102,4 +102,4 @@ void SetConstraintOnAssociationMany2Many() throws Ili2cFailure, IoxException { AssertionHelper.assertNoConstraintError(vh, "Constraint8"); Assert.equals(11, vh.getErrs().size()); } -} \ No newline at end of file +} diff --git a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInGroupsIoxPluginTest.java b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInGroupsIoxPluginTest.java index f0b3b64..55ff24c 100644 --- a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInGroupsIoxPluginTest.java +++ b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInGroupsIoxPluginTest.java @@ -4,7 +4,6 @@ import ch.interlis.iox.IoxException; import com.vividsolutions.jts.util.Assert; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; class GetInGroupsIoxPluginTest { @@ -19,7 +18,7 @@ void setUp() { } @Test - void MandatoryConstraintOnThis() throws Ili2cFailure, IoxException { + void mandatoryConstraintOnThis() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{TEST_DATA}, new String[]{"GetInGroups/SetConstraintAll.ili"}); Assert.equals(3, vh.getErrs().size()); AssertionHelper.assertNoConstraintError(vh, "trueConstraintTextAttr"); diff --git a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInnerringsCountIoxPluginTest.java b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInnerringsCountIoxPluginTest.java index 2c4a570..6e3a7f5 100644 --- a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInnerringsCountIoxPluginTest.java +++ b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetInnerringsCountIoxPluginTest.java @@ -4,7 +4,6 @@ import ch.interlis.iox.IoxException; import com.vividsolutions.jts.util.Assert; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; class GetInnerringsCountIoxPluginTest { @@ -19,7 +18,7 @@ void setUp() { } @Test - void MandatoryConstraintOnThis() throws Ili2cFailure, IoxException { + void mandatoryConstraintOnThis() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{TEST_DATA}, new String[]{"GetInnerRingsCount/MandatoryConstraintThis.ili"}); Assert.equals(5, vh.getErrs().size()); diff --git a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetLengthIoxPluginTest.java b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetLengthIoxPluginTest.java index 8ae5919..abe8f0a 100644 --- a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetLengthIoxPluginTest.java +++ b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/GetLengthIoxPluginTest.java @@ -19,7 +19,7 @@ void setUp() { } @Test - void MandatoryConstraintOnThis() throws Ili2cFailure, IoxException { + void mandatoryConstraintOnThis() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{TEST_DATA}, new String[]{"GetLength/MandatoryConstraintThis.ili"}); Assert.equals(4, vh.getErrs().size()); AssertionHelper.assertSingleConstraintError(vh, 0, "Constraint1"); @@ -29,7 +29,7 @@ void MandatoryConstraintOnThis() throws Ili2cFailure, IoxException { } @Test - void SetConstraintOnAll() throws Ili2cFailure, IoxException { + void setConstraintOnAll() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{TEST_DATA}, new String[]{"GetLength/SetConstraintAll.ili"}); Assert.equals(3, vh.getErrs().size()); AssertionHelper.assertNoConstraintError(vh, "Constraint1"); @@ -40,7 +40,7 @@ void SetConstraintOnAll() throws Ili2cFailure, IoxException { } @Test - void SetConstraintOnThis() throws Ili2cFailure, IoxException { + void setConstraintOnThis() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{TEST_DATA}, new String[]{"GetLength/SetConstraintThis.ili"}); Assert.equals(2, vh.getErrs().size()); AssertionHelper.assertSingleConstraintError(vh, 0, "Constraint2"); @@ -49,7 +49,7 @@ void SetConstraintOnThis() throws Ili2cFailure, IoxException { @Test @Disabled("XTF24Reader fails on reading Bag Of Struct") - void SetConstraintOnThisWithBagOfStruct() throws Ili2cFailure, IoxException { + void setConstraintOnThisWithBagOfStruct() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{"GetLength/TestDataBagOf.xtf"}, new String[]{"GetLength/SetConstraintBagOf.ili"}); Assert.equals(1, vh.getErrs().size()); AssertionHelper.assertNoConstraintError(vh, "Constraint1"); @@ -60,7 +60,7 @@ void SetConstraintOnThisWithBagOfStruct() throws Ili2cFailure, IoxException { } @Test - void SetConstraintOnAssociationOne2Many() throws Ili2cFailure, IoxException { + void setConstraintOnAssociationOne2Many() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{"GetLength/TestDataAssocOne2Many.xtf"}, new String[]{"GetLength/SetConstraintAssocOne2Many.ili"}); AssertionHelper.assertNoConstraintError(vh, "Constraint1"); @@ -79,7 +79,7 @@ void SetConstraintOnAssociationOne2Many() throws Ili2cFailure, IoxException { } @Test - void SetConstraintOnAssociationMany2Many() throws Ili2cFailure, IoxException { + void setConstraintOnAssociationMany2Many() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{"GetLength/TestDataAssocMany2Many.xtf"}, new String[]{"GetLength/SetConstraintAssocMany2Many.ili"}); AssertionHelper.assertNoConstraintError(vh, "Constraint1"); @@ -102,4 +102,4 @@ void SetConstraintOnAssociationMany2Many() throws Ili2cFailure, IoxException { AssertionHelper.assertNoConstraintError(vh, "Constraint8"); Assert.equals(11, vh.getErrs().size()); } -} \ No newline at end of file +} diff --git a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPluginTest.java b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPluginTest.java index d10b277..3456f6d 100644 --- a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPluginTest.java +++ b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/IsInsideExternalDatasetIoxPluginTest.java @@ -9,8 +9,8 @@ import java.io.File; import java.lang.reflect.Field; -public class IsInsideExternalDatasetIoxPluginTest { - protected static final String TEST_DATA = "IsInsideExternalDataset/TestData.xtf"; +class IsInsideExternalDatasetIoxPluginTest { + private static final String TEST_DATA = "IsInsideExternalDataset/TestData.xtf"; ValidationTestHelper vh; @BeforeEach @@ -26,7 +26,7 @@ void setUp() throws NoSuchFieldException, IllegalAccessException { } @Test - void IsInsideExternalDataset() throws Ili2cFailure, IoxException { + void isInsideExternalDataset() throws Ili2cFailure, IoxException { vh.runValidation(new String[]{TEST_DATA}, new String[]{"IsInsideExternalDataset/MandatoryConstraintThis.ili"}); Assert.equals(6, vh.getErrs().size()); diff --git a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/LogCollector.java b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/LogCollector.java index d041946..6285214 100644 --- a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/LogCollector.java +++ b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/LogCollector.java @@ -7,9 +7,9 @@ import java.util.ArrayList; -public class LogCollector implements ch.interlis.iox.IoxLogging { - private ArrayList errs = new ArrayList<>(); - private ArrayList warn = new ArrayList<>(); +public final class LogCollector implements ch.interlis.iox.IoxLogging { + private final ArrayList errs = new ArrayList<>(); + private final ArrayList warn = new ArrayList<>(); @Override public void addEvent(IoxLogEvent event) { diff --git a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/ValidationTestHelper.java b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/ValidationTestHelper.java index 7cc12cb..57d77ad 100644 --- a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/ValidationTestHelper.java +++ b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/ValidationTestHelper.java @@ -21,7 +21,7 @@ import java.util.Arrays; import java.util.HashMap; -public class ValidationTestHelper { +public final class ValidationTestHelper { private final HashMap> userFunctions = new HashMap<>(); private LogCollector logCollector; @@ -68,9 +68,9 @@ public void runValidation(String[] dataFiles, String[] modelFiles) throws IoxExc private String[] appendGeoWFunctionsExtIli(String[] modelDirs) { System.out.println("Working Directory = " + System.getProperty("user.dir")); - String GeoW_FunctionsExtIliPath = "src/model/GeoW_FunctionsExt.ili"; + String functionsExtIliPath = "src/model/GeoW_FunctionsExt.ili"; ArrayList result = new ArrayList<>(); - result.add(GeoW_FunctionsExtIliPath); + result.add(functionsExtIliPath); result.addAll(Arrays.asList(modelDirs)); return result.toArray(new String[0]); } From 9f04637b9384205b69486041a2d2e915b5f2a8e0 Mon Sep 17 00:00:00 2001 From: Patrick Ackermann Date: Fri, 22 Sep 2023 09:00:15 +0200 Subject: [PATCH 4/4] Fix typo in build.gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4acf810..e91cf5d 100644 --- a/build.gradle +++ b/build.gradle @@ -54,7 +54,7 @@ publishing { developers { developer { id = 'GeoWerkstatt' - name = 'GeoWerkstatt GmbHH' + name = 'GeoWerkstatt GmbH' email = 'office@geowerkstatt.ch' } }