Changeset 36042 in osm for applications/editors


Ignore:
Timestamp:
2022-12-12T19:28:40+01:00 (19 months ago)
Author:
taylor.smock
Message:

Fix #22520: IllegalStateException: Missing merge target for node (patch by GerdP, modified to add tests)

The added test is essentially an integration test instead of a unit test, mostly
due to having no good way to do a test specifically for the method at issue.
The test uses wiremock to (a) speed up the test and (b) avoid adding a test-time
dependency on the OSM API servers. The test required a custom wiremock response
transformer for the OSM multi-fetch API, since it is not guaranteed that the
order of objects will remain the same, which will lead to stub misses, failing
the test.

Location:
applications/editors/josm/plugins/reverter
Files:
12 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java

    r35980 r36042  
    424424            ChangesetDataSetEntry entry = it.next();
    425425            if (!checkOsmChangeEntry(entry)) continue;
     426            if (entry.getModificationType() == ChangesetModificationType.DELETED
     427                    && revertType == RevertType.SELECTION_WITH_UNDELETE) {
     428                // see #22520: missing merge target when object is first created and then
     429                // deleted in the same changeset
     430                ChangesetDataSetEntry first = cds.getFirstEntry(entry.getPrimitive().getPrimitiveId());
     431                if (first.getModificationType() == ChangesetModificationType.CREATED)
     432                    continue;
     433            }
    426434            HistoryOsmPrimitive hp = entry.getPrimitive();
    427435            OsmPrimitive dp = ds.getPrimitiveById(hp.getPrimitiveId());
  • applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetTask.java

    r35869 r36042  
    5353
    5454    public RevertChangesetTask(Collection<Integer> changesetIds, RevertType revertType, boolean autoConfirmDownload, boolean newLayer) {
    55         super(tr("Reverting..."));
     55        this(null, changesetIds, revertType, autoConfirmDownload, newLayer);
     56    }
     57
     58    /**
     59     * Create a new task for reverting a changeset
     60     * @param progressMonitor The {@link ProgressMonitor} to use. May be {@code null}
     61     * @param changesetIds The changeset ids to revert
     62     * @param revertType The type of revert to do
     63     * @param autoConfirmDownload {@code true} if the user has already indicated that they want to download missing data
     64     * @param newLayer {@code true} if the user wants the reversion to be on a new layer
     65     */
     66    public RevertChangesetTask(ProgressMonitor progressMonitor, Collection<Integer> changesetIds, RevertType revertType, boolean autoConfirmDownload, boolean newLayer) {
     67        super(tr("Reverting..."), progressMonitor, false);
    5668        this.changesetIds = new ArrayList<>(changesetIds);
    5769        this.revertType = revertType;
Note: See TracChangeset for help on using the changeset viewer.