diff --git a/.github/workflows/ant-release.yml b/.github/workflows/ant-release.yml new file mode 100644 index 0000000..57d0066 --- /dev/null +++ b/.github/workflows/ant-release.yml @@ -0,0 +1,12 @@ +name: Release + +on: + release: + types: [created] + +jobs: + call-workflow: + uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v2 + with: + josm-revision: "r18221" + diff --git a/.github/workflows/ant.yml b/.github/workflows/ant.yml new file mode 100644 index 0000000..742885d --- /dev/null +++ b/.github/workflows/ant.yml @@ -0,0 +1,23 @@ +name: Java CI + +on: + push: + branches: + - master + - $default-branch + - $protected-branches + pull_request: + branches: + - master + - $default-branch + workflow_dispatch: + +jobs: + call-workflow: + strategy: + matrix: + josm-revision: ["", "r18221"] + uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v2 + with: + josm-revision: ${{ matrix.josm-revision }} + diff --git a/.github/workflows/reports.yaml b/.github/workflows/reports.yaml new file mode 100644 index 0000000..817c66f --- /dev/null +++ b/.github/workflows/reports.yaml @@ -0,0 +1,14 @@ +name: Publish reports + +on: + workflow_run: + workflows: [Java CI] + types: [completed] + +permissions: + checks: write + +jobs: + call-workflow: + uses: JOSM/JOSMPluginAction/.github/workflows/reports.yaml@v2 + diff --git a/test/unit/com/vividsolutions/jcs/conflate/polygonmatch/WeightedMatcherTest.java b/test/unit/com/vividsolutions/jcs/conflate/polygonmatch/WeightedMatcherTest.java index 8845b60..6b72563 100644 --- a/test/unit/com/vividsolutions/jcs/conflate/polygonmatch/WeightedMatcherTest.java +++ b/test/unit/com/vividsolutions/jcs/conflate/polygonmatch/WeightedMatcherTest.java @@ -5,28 +5,25 @@ import java.util.Arrays; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.osm.Node; import org.openstreetmap.josm.plugins.conflation.OsmFeature; import org.openstreetmap.josm.plugins.jts.JTSConverter; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Projection; import com.vividsolutions.jump.feature.Feature; import com.vividsolutions.jump.feature.FeatureCollection; import com.vividsolutions.jump.feature.FeatureDataset; import com.vividsolutions.jump.feature.FeatureSchema; -import com.vividsolutions.jump.feature.IndexedFeatureCollection; /** * Test class for {@link WeightedMatcher} * @author Taylor Smock */ @BasicPreferences +@Projection class WeightedMatcherTest { - @RegisterExtension - JOSMTestRules josmTestRules = new JOSMTestRules().projection(); /** * Non-regression test for JOSM #21788 * This occurred when two {@link org.openstreetmap.josm.plugins.conflation.OsmFeature} objects had {@link Comparable} diff --git a/test/unit/org/openstreetmap/josm/plugins/conflation/ConflationPluginTest.java b/test/unit/org/openstreetmap/josm/plugins/conflation/ConflationPluginTest.java index 16fca95..0a02b29 100644 --- a/test/unit/org/openstreetmap/josm/plugins/conflation/ConflationPluginTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/conflation/ConflationPluginTest.java @@ -2,8 +2,8 @@ // Copyright 2012 by Josh Doe and others. package org.openstreetmap.josm.plugins.conflation; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.BufferedReader; import java.io.File; @@ -17,10 +17,9 @@ import javax.xml.stream.XMLStreamException; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.openstreetmap.josm.actions.ExpertToggleAction; import org.openstreetmap.josm.command.Command; import org.openstreetmap.josm.data.Preferences; @@ -37,38 +36,33 @@ import org.openstreetmap.josm.plugins.conflation.config.MatchingPanel; import org.openstreetmap.josm.plugins.conflation.config.MergingPanel; import org.openstreetmap.josm.spi.preferences.Config; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.tools.I18n; /** * FIXME: this class is not functional yet */ -public class ConflationPluginTest { - - @Rule - public JOSMTestRules rules = new JOSMTestRules().preferences(); - +class ConflationPluginTest { static String[] testList = new String[]{"test1-buildings"}; @Test - @Ignore("FIXME: restore test when @{link #compare} method will be fixed") - public void testConflationPlugin() throws FileNotFoundException, XMLStreamException, IOException, IllegalDataException { + @Disabled("FIXME: restore test when @{link #compare} method will be fixed") + void testConflationPlugin() throws XMLStreamException, IOException, IllegalDataException { for (String testName: testList) { - assertTrue(testName, testCase(testName)); + assertTrue(testCase(testName), testName); } } - static boolean testCase(String name) throws FileNotFoundException, XMLStreamException, IOException, IllegalDataException { + static boolean testCase(String name) throws XMLStreamException, IOException, IllegalDataException { SimpleMatchSettings settings = openTestCase(name); OsmDataLayer expectedResult = openTestResult(name); SimpleMatchList matchesList = new SimpleMatchList(); matchesList.addAll(MatchesComputation.generateMatches(settings, NullProgressMonitor.INSTANCE)); Collection referenceOnly = settings.referenceSelection.stream() .filter((p) -> matchesList.getMatchByReference(p) == null) - .collect(Collectors.toList());; + .collect(Collectors.toList()); Collection subjectOnly = settings.subjectSelection.stream() .filter((p) -> matchesList.getMatchBySubject(p) == null) - .collect(Collectors.toList());; + .collect(Collectors.toList()); while (matchesList.size() > 0) { SimpleMatch match = matchesList.get(matchesList.size()-1); new ConflateMatchCommand(match, matchesList, settings).executeCommand(); @@ -100,21 +94,21 @@ static boolean compare(OsmDataLayer layer1, OsmDataLayer layer2) { /** * Open a test case and return the corresponding settings. - * + *

* A test case a directory "test/data/name>/". - * - * This directory should contains a files "reference.osm", a file "subject.osm" + *

+ * This directory should contain a file "reference.osm", a file "subject.osm" * or a file "reference-subject.osm" if the same layer should be used * for both reference and subject. - * + *

* The directory should also contain a file named "result.xml" for * the expected result of the conflation. - * + *

* The directory could contain a file named "preferences.xml" to specify * specific settings. */ static SimpleMatchSettings openTestCase(String name) - throws FileNotFoundException, XMLStreamException, IOException, IllegalDataException { + throws XMLStreamException, IOException, IllegalDataException { SimpleMatchSettings settings = new SimpleMatchSettings(); File path = new File(new File("test", "data"), name); assertTrue(path.isDirectory()); @@ -122,11 +116,11 @@ static SimpleMatchSettings openTestCase(String name) OsmDataLayer subject; if (reference == null) { reference = importOsmFile(new File(path, "reference-subject.osm")); - assertNotNull("referece.osm or reference-subject.osm file not found in directory " + path, reference); + assertNotNull(reference, "reference.osm or reference-subject.osm file not found in directory " + path); subject = reference; } else { subject = importOsmFile(new File(path, "subject.osm")); - assertNotNull("subject.osm file not found in directory " + path, subject); + assertNotNull(subject, "subject.osm file not found in directory " + path); } Preferences pref = openPreferencesXML(new File(path, "preferences.xml")); settings.subjectLayer = subject; @@ -136,7 +130,7 @@ static SimpleMatchSettings openTestCase(String name) settings.referenceSelection = reference.data.allPrimitives().stream().filter( (p) -> "yes".equals(p.get("reference"))).collect(Collectors.toList()); settings.subjectSelection = subject.data.allPrimitives().stream().filter( - (p) -> "yes".equals(p.get("subject"))).collect(Collectors.toList());; + (p) -> "yes".equals(p.get("subject"))).collect(Collectors.toList()); new MatchingPanel(null, pref, () -> { }).fillSettings(settings); new MergingPanel(null, pref).fillSettings(settings); return settings; @@ -147,7 +141,7 @@ static OsmDataLayer openTestResult(String name) throws IllegalDataException { return importOsmFile(new File(path, "result.osm")); } - public static Preferences openPreferencesXML(File file) throws FileNotFoundException, XMLStreamException, IOException { + static Preferences openPreferencesXML(File file) throws XMLStreamException, IOException { Preferences pref = new Preferences(); if (file.exists()) { pref.fromXML(new BufferedReader(new FileReader(file))); @@ -155,13 +149,12 @@ public static Preferences openPreferencesXML(File file) throws FileNotFoundExcep return pref; } - public static OsmDataLayer importOsmFile(File file) throws IllegalDataException { + static OsmDataLayer importOsmFile(File file) throws IllegalDataException { OsmImporter importer = new OsmImporter(); try { InputStream in = new FileInputStream(file); OsmImporterData oid = importer.loadLayer(in, file, file.getName(), NullProgressMonitor.INSTANCE); - OsmDataLayer layer = oid.getLayer(); - return layer; + return oid.getLayer(); } catch (FileNotFoundException e) { e.printStackTrace(); } @@ -169,8 +162,8 @@ public static OsmDataLayer importOsmFile(File file) throws IllegalDataException } static boolean isInitialized; - @BeforeClass - public static void setUpBeforeClass() { + @BeforeAll + static void setUpBeforeClass() { if (!isInitialized) { //System.setProperty("josm.home", "test/data/preferences"); Preferences.main().enableSaveOnPut(false); diff --git a/test/unit/org/openstreetmap/josm/plugins/conflation/OsmFeatureTest.java b/test/unit/org/openstreetmap/josm/plugins/conflation/OsmFeatureTest.java index 27e9395..de7ab4a 100644 --- a/test/unit/org/openstreetmap/josm/plugins/conflation/OsmFeatureTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/conflation/OsmFeatureTest.java @@ -2,18 +2,16 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.osm.Node; import org.openstreetmap.josm.data.osm.OsmPrimitive; import org.openstreetmap.josm.plugins.jts.JTSConverter; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Projection; import com.vividsolutions.jump.feature.AttributeType; import com.vividsolutions.jump.feature.FeatureSchema; @@ -24,9 +22,8 @@ * @author Taylor Smock */ @BasicPreferences +@Projection class OsmFeatureTest { - @RegisterExtension - JOSMTestRules josmTestRules = new JOSMTestRules().projection(); /** * This checks that two osm features (points) do not match if they have the same geometry but different ids. * This is a partial non-regression test for JOSM #21788. The root of the issue is that TreeMap uses the Comparable diff --git a/test/unit/org/openstreetmap/josm/plugins/conflation/SimpleMatchTest.java b/test/unit/org/openstreetmap/josm/plugins/conflation/SimpleMatchTest.java index 17804b3..4d21678 100644 --- a/test/unit/org/openstreetmap/josm/plugins/conflation/SimpleMatchTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/conflation/SimpleMatchTest.java @@ -1,31 +1,27 @@ // License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.plugins.conflation; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; -import java.util.Arrays; +import java.util.Collections; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openstreetmap.josm.data.osm.Node; import org.openstreetmap.josm.data.osm.OsmPrimitive; import org.openstreetmap.josm.data.osm.TagCollection; -import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.testutils.annotations.BasicPreferences; /** * Unit tests of {@link SimpleMatch} */ -public class SimpleMatchTest { - - @Rule - public JOSMTestRules rules = new JOSMTestRules().preferences(); - +@BasicPreferences +class SimpleMatchTest { @Test - public void testGetMergingTagCollectionOverwrite() { + void testGetMergingTagCollectionOverwrite() { SimpleMatchSettings settings = new SimpleMatchSettings(); settings.isReplacingGeometry = true; settings.mergeTags = new SimpleMatchSettings.All<>(); - settings.overwriteTags = Arrays.asList("addr:housenumber"); + settings.overwriteTags = Collections.singletonList("addr:housenumber"); OsmPrimitive n1 = new Node(); OsmPrimitive n2 = new Node(); SimpleMatch match = new SimpleMatch(n1, n2, 0.5, 10.0); @@ -34,7 +30,7 @@ public void testGetMergingTagCollectionOverwrite() { n1.put("addr:street", "Street One"); n2.put("addr:street", "Street One Two"); TagCollection tagCollection = match.getMergingTagCollection(settings); - assertTrue(tagCollection.getNumTagsFor("addr:street") == 2); - assertTrue(tagCollection.getNumTagsFor("addr:housenumber") == 1); + assertEquals(2, tagCollection.getNumTagsFor("addr:street")); + assertEquals(1, tagCollection.getNumTagsFor("addr:housenumber")); } }