Changeset 12714 in josm for trunk/test


Ignore:
Timestamp:
2017-09-03T21:14:05+02:00 (2 years ago)
Author:
Don-vip
Message:

fix #15228 - Support missing Overpass Turbo extended shortcuts: {{center}}, {{date:string}}, {{geocodeId:name}}, {{geocodeBbox:name}}, {{geocodeCoords:name}}

File:
1 edited

Legend:

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

    r12557 r12714  
    77import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
    88import static org.junit.Assert.assertEquals;
     9import static org.junit.Assert.assertNotNull;
    910import static org.junit.Assert.assertTrue;
    1011
     12import java.time.LocalDateTime;
    1113import java.util.regex.Matcher;
    1214
     
    2022import org.openstreetmap.josm.tools.OverpassTurboQueryWizard;
    2123import org.openstreetmap.josm.tools.Utils;
     24import org.openstreetmap.josm.tools.date.DateUtils;
    2225
    2326import com.github.tomakehurst.wiremock.junit.WireMockRule;
     
    8790
    8891    /**
     92     * Tests evaluating the extended query feature {@code date}.
     93     */
     94    @Test
     95    public void testDate() {
     96        LocalDateTime from = LocalDateTime.of(2017, 7, 14, 2, 40);
     97        assertEquals("2016-07-14T02:40:00Z", OverpassDownloadReader.date("1 year", from));
     98        assertEquals("2007-07-14T02:40:00Z", OverpassDownloadReader.date("10years", from));
     99        assertEquals("2017-06-14T02:40:00Z", OverpassDownloadReader.date("1 month", from));
     100        assertEquals("2016-09-14T02:40:00Z", OverpassDownloadReader.date("10months", from));
     101        assertEquals("2017-07-07T02:40:00Z", OverpassDownloadReader.date("1 week", from));
     102        assertEquals("2017-05-05T02:40:00Z", OverpassDownloadReader.date("10weeks", from));
     103        assertEquals("2017-07-13T02:40:00Z", OverpassDownloadReader.date("1 day", from));
     104        assertEquals("2017-07-04T02:40:00Z", OverpassDownloadReader.date("10days", from));
     105        assertEquals("2017-07-14T01:40:00Z", OverpassDownloadReader.date("1 hour", from));
     106        assertEquals("2017-07-13T16:40:00Z", OverpassDownloadReader.date("10hours", from));
     107        assertEquals("2017-07-14T02:39:00Z", OverpassDownloadReader.date("1 minute", from));
     108        assertEquals("2017-07-14T02:30:00Z", OverpassDownloadReader.date("10minutes", from));
     109        assertEquals("2017-07-14T02:39:59Z", OverpassDownloadReader.date("1 second", from));
     110        assertEquals("2017-07-14T02:39:50Z", OverpassDownloadReader.date("10seconds", from));
     111
     112        assertEquals("2016-07-13T02:40:00Z", OverpassDownloadReader.date("1 year 1 day", from));
     113        assertEquals("2016-07-14T02:38:20Z", OverpassDownloadReader.date("1 year 100 seconds", from));
     114        assertEquals("2017-07-13T02:38:20Z", OverpassDownloadReader.date("1 day  100 seconds", from));
     115    }
     116
     117    /**
     118     * Tests evaluating the extended query feature {@code date} through {@code newer:} operator.
     119     */
     120    @Test
     121    public void testDateNewer() {
     122        final String query = getExpandedQuery("type:node and newer:3minutes");
     123        String statement = query.substring(query.indexOf("node(newer:\"") + 12, query.lastIndexOf("\");"));
     124        assertNotNull(DateUtils.fromString(statement));
     125    }
     126
     127    /**
    89128     * Tests evaluating the extended query feature {@code geocodeArea}.
    90129     */
Note: See TracChangeset for help on using the changeset viewer.