Changeset 10127 in josm for trunk/test


Ignore:
Timestamp:
2016-04-09T19:12:05+02:00 (9 years ago)
Author:
Don-vip
Message:

sort primitives to avoid intermittent unit test failures

File:
1 edited

Legend:

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

    r9762 r10127  
    33
    44import static org.junit.Assert.assertEquals;
     5
     6import java.util.ArrayList;
     7import java.util.Collections;
     8import java.util.List;
    59
    610import org.junit.BeforeClass;
     
    1014import org.openstreetmap.josm.data.osm.DataSet;
    1115import org.openstreetmap.josm.data.osm.Node;
     16import org.openstreetmap.josm.data.osm.OsmPrimitive;
     17import org.openstreetmap.josm.data.osm.OsmPrimitiveComparator;
    1218import org.openstreetmap.josm.data.osm.Way;
    1319
     
    2329    public static void setUpBeforeClass() {
    2430        JOSMFixture.createUnitTestFixture().init();
     31    }
     32
     33    private static String createSearchSetting(DataSet ds, boolean sameType) {
     34        List<OsmPrimitive> sel = new ArrayList<>(ds.allPrimitives());
     35        Collections.sort(sel, new OsmPrimitiveComparator(true, false));
     36        return PropertiesDialog.createSearchSetting("foo", sel, sameType).text;
    2537    }
    2638
     
    3951            ds.addPrimitive(n);
    4052        }
    41         assertEquals("(\"foo\"=\"bar\")",
    42                 PropertiesDialog.createSearchSetting("foo", ds.allPrimitives(), false).text);
     53        assertEquals("(\"foo\"=\"bar\")", createSearchSetting(ds, false));
    4354
    4455        Node n = new Node(LatLon.ZERO);
     
    4657        ds.addPrimitive(n);
    4758
    48         assertEquals("(\"foo\"=\"bar\") OR (\"foo\"=\"baz\")",
    49                 PropertiesDialog.createSearchSetting("foo", ds.allPrimitives(), false).text);
     59        assertEquals("(\"foo\"=\"baz\") OR (\"foo\"=\"bar\")", createSearchSetting(ds, false));
    5060
    5161        ds.removePrimitive(n);
     
    5565        ds.addPrimitive(w);
    5666
    57         assertEquals("(type:node \"foo\"=\"bar\") OR (type:way \"foo\"=\"bar\")",
    58                 PropertiesDialog.createSearchSetting("foo", ds.allPrimitives(), true).text);
     67        assertEquals("(type:way \"foo\"=\"bar\") OR (type:node \"foo\"=\"bar\")", createSearchSetting(ds, true));
    5968    }
    6069}
Note: See TracChangeset for help on using the changeset viewer.