Changeset 15811 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2020-02-03T06:35:22+01:00 (5 years ago)
Author:
GerdP
Message:

fix #18566: Download object: member of relations always downloaded (18566.3.patch)

  • return same result when downloading objects, no matter if overpass api is enabled or not.
  • fix an EDT violation in class ChildRelationBrowser
  • let MultiFetchOverpassObjectReader create a single overpass query, no matter how many objects are requested

(gives much better reaction times).

  • use multi-fetch in ChildRelationBrowser to reduce duplicated code. Small disadvantage: When downloading multiple members of a relation the dialog doesn't update after each member. Should not matter much as the overall time for multiple members is shorter

I tried to keep the code backward compatible. Plugins reverter and undelete should continue to work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/io/MultiFetchOverpassObjectReaderTest.java

    r15717 r15811  
    55
    66import java.util.Arrays;
    7 import java.util.TreeSet;
     7
     8import org.junit.Rule;
     9import org.junit.Test;
     10import org.openstreetmap.josm.data.osm.Node;
     11import org.openstreetmap.josm.data.osm.Relation;
     12import org.openstreetmap.josm.data.osm.Way;
     13import org.openstreetmap.josm.testutils.JOSMTestRules;
    814
    915import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    10 import org.junit.Rule;
    11 import org.junit.Test;
    12 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    13 import org.openstreetmap.josm.testutils.JOSMTestRules;
    14 import org.openstreetmap.josm.tools.Utils;
    1516
    1617/**
     
    3031     */
    3132    @Test
    32     public void testBuildRequestString() {
    33         String requestString = new MultiFetchOverpassObjectReader()
    34                 .buildRequestString(OsmPrimitiveType.WAY, new TreeSet<>(Arrays.asList(130L, 123L, 126L)));
    35         assertEquals("interpreter?data=" + Utils.encodeUrl("(way(123);>;way(126);>;way(130);>;);out meta;"), requestString);
     33    public void testBuildRequestWaysString() {
     34        MultiFetchOverpassObjectReader reader = new MultiFetchOverpassObjectReader();
     35        reader.append(Arrays.asList(new Way(123), new Way(126), new Way(130)));
     36        String requestString = reader.buildComplexRequestString();
     37        assertEquals("(way(id:123,126,130);>;);out meta;", requestString);
     38    }
     39
     40    /**
     41     * Test {@link MultiFetchOverpassObjectReader#buildRequestString}
     42     */
     43    @Test
     44    public void testBuildRequestRelationsString() {
     45        MultiFetchOverpassObjectReader reader = new MultiFetchOverpassObjectReader();
     46        reader.append(Arrays.asList(new Relation(123), new Relation(126), new Relation(130)));
     47        reader.setRecurseDownRelations(true);
     48        String requestString = reader.buildComplexRequestString();
     49        assertEquals("relation(id:123,126,130);>>;out meta;", requestString);
     50        reader.setRecurseDownRelations(false);
     51        requestString = reader.buildComplexRequestString();
     52        assertEquals("relation(id:123,126,130);out meta;", requestString);
     53    }
     54
     55    /**
     56     * Test {@link MultiFetchOverpassObjectReader#buildRequestString}
     57     */
     58    @Test
     59    public void testBuildComplexString() {
     60        MultiFetchOverpassObjectReader reader = new MultiFetchOverpassObjectReader();
     61        reader.setRecurseDownRelations(true);
     62        reader.append(Arrays.asList(new Relation(123), new Relation(126), new Relation(130), new Way(88), new Way(99),
     63                new Node(1)));
     64        String requestString = reader.buildComplexRequestString();
     65        assertEquals("(relation(id:123,126,130);>>;(way(id:88,99);>;);node(1););out meta;", requestString);
     66        reader.setRecurseDownRelations(false);
     67        requestString = reader.buildComplexRequestString();
     68        assertEquals("(relation(id:123,126,130);(way(id:88,99);>;);node(1););out meta;", requestString);
    3669    }
    3770
Note: See TracChangeset for help on using the changeset viewer.