Changeset 15822 in josm


Ignore:
Timestamp:
2020-02-06T21:05:35+01:00 (2 weeks ago)
Author:
GerdP
Message:

see #18654: Fix unit test
OsmPrimitiveComparator.comparingUniqueId() no longer works because test creates a node with -1 and a way with -1 now. I see no need to store the elements in an unordered set and sort again later.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialogTest.java

    r11177 r15822  
    55
    66import java.util.ArrayList;
    7 import java.util.Collections;
    87import java.util.List;
    98
     
    1110import org.junit.Test;
    1211import org.openstreetmap.josm.data.coor.LatLon;
    13 import org.openstreetmap.josm.data.osm.DataSet;
    1412import org.openstreetmap.josm.data.osm.Node;
    1513import org.openstreetmap.josm.data.osm.OsmPrimitive;
    16 import org.openstreetmap.josm.data.osm.OsmPrimitiveComparator;
    1714import org.openstreetmap.josm.data.osm.Way;
    1815import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    3229    public JOSMTestRules test = new JOSMTestRules();
    3330
    34     private static String createSearchSetting(DataSet ds, boolean sameType) {
    35         List<OsmPrimitive> sel = new ArrayList<>(ds.allPrimitives());
    36         Collections.sort(sel, OsmPrimitiveComparator.comparingUniqueId());
     31    private static String createSearchSetting(List<OsmPrimitive> sel, boolean sameType) {
    3732        return PropertiesDialog.createSearchSetting("foo", sel, sameType).text;
    3833    }
     
    4338    @Test
    4439    public void testTicket12504() {
    45         DataSet ds = new DataSet();
     40        List<OsmPrimitive> sel = new ArrayList<>();
    4641        // 160 objects with foo=bar, 400 objects without foo
    4742        for (int i = 0; i < 160+400; i++) {
     
    5045                n.put("foo", "bar");
    5146            }
    52             ds.addPrimitive(n);
     47            sel.add(n);
    5348        }
    54         assertEquals("(\"foo\"=\"bar\")", createSearchSetting(ds, false));
     49        assertEquals("(\"foo\"=\"bar\")", createSearchSetting(sel, false));
    5550
    5651        Node n = new Node(LatLon.ZERO);
    5752        n.put("foo", "baz");
    58         ds.addPrimitive(n);
     53        sel.add(0, n);
    5954
    60         assertEquals("(\"foo\"=\"baz\") OR (\"foo\"=\"bar\")", createSearchSetting(ds, false));
     55        assertEquals("(\"foo\"=\"baz\") OR (\"foo\"=\"bar\")", createSearchSetting(sel, false));
    6156
    62         ds.removePrimitive(n);
     57        sel.remove(0);
    6358
    6459        Way w = new Way();
    6560        w.put("foo", "bar");
    66         ds.addPrimitive(w);
     61        sel.add(0, w);
    6762
    68         assertEquals("(type:way \"foo\"=\"bar\") OR (type:node \"foo\"=\"bar\")", createSearchSetting(ds, true));
     63        assertEquals("(type:way \"foo\"=\"bar\") OR (type:node \"foo\"=\"bar\")", createSearchSetting(sel, true));
    6964    }
    7065}
Note: See TracChangeset for help on using the changeset viewer.