Ignore:
Timestamp:
2021-04-11T21:56:50+02:00 (4 years ago)
Author:
simon04
Message:

see #14176 - Migrate OsmPrimitive to Instant

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r17346 r17749  
    1414import java.time.Instant;
    1515import java.util.Arrays;
    16 import java.util.Date;
    1716
    1817import org.junit.jupiter.api.AfterEach;
     
    2524import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2625import org.openstreetmap.josm.testutils.JOSMTestRules;
    27 import org.openstreetmap.josm.tools.date.DateUtils;
    2826
    2927import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    307305        n.put("key1", "value1");
    308306        n.setUser(myUser);
    309         n.setTimestamp(new Date());
     307        n.setInstant(Instant.now());
    310308
    311309        my.addPrimitive(n);
     
    314312        n1.setCoor(LatLon.ZERO);
    315313        n1.put("key1", "value1");
    316         n1.setTimestamp(Date.from(Instant.now().plusSeconds(3600)));
     314        n1.setInstant(Instant.now().plusSeconds(3600));
    317315        n1.setUser(theirUser);
    318316        their.addPrimitive(n1);
     
    346344        n1.setOsmId(1, 1);
    347345        n1.put("key1", "value1");
    348         n1.setTimestamp(new Date());
     346        n1.setInstant(Instant.now());
    349347        their.addPrimitive(n1);
    350348
     
    646644        User user = User.createOsmUser(1111, "their");
    647645        theirWay.setUser(user);
    648         theirWay.setTimestamp(new Date());
     646        theirWay.setInstant(Instant.now());
    649647        their.addPrimitive(theirWay);
    650648
     
    699697        User user = User.createOsmUser(1111, "their");
    700698        theirWay.setUser(user);
    701         theirWay.setTimestamp(new Date());
     699        theirWay.setInstant(Instant.now());
    702700        their.addPrimitive(theirWay);
    703701
     
    754752        theirWay.addNode(tn3);
    755753        theirWay.setUser(User.createOsmUser(1111, "their"));
    756         theirWay.setTimestamp(new Date());
     754        theirWay.setInstant(Instant.now());
    757755        their.addPrimitive(theirWay);
    758756
     
    11821180        Node nA = new Node(2848219691L, 1);
    11831181        nA.setCoor(LatLon.ZERO);
    1184         nA.setTimestamp(DateUtils.fromString("2014-05-10T14:25:40Z"));
     1182        nA.setInstant(Instant.parse("2014-05-10T14:25:40Z"));
    11851183        nA.setChangesetId(22251108);
    11861184        nA.setUser(User.createOsmUser(385987, "yaho"));
  • trunk/test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java

    r17746 r17749  
    1313import java.nio.file.Files;
    1414import java.nio.file.Paths;
     15import java.time.Instant;
    1516import java.util.Arrays;
    1617import java.util.Collection;
     
    4445import org.openstreetmap.josm.testutils.JOSMTestRules;
    4546import org.openstreetmap.josm.tools.Logging;
    46 import org.openstreetmap.josm.tools.date.DateUtils;
    4747
    4848import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    449449    void testTimestamp() throws SearchParseError {
    450450        final Node n1 = new Node();
    451         n1.setTimestamp(DateUtils.fromString("2010-01-22"));
     451        n1.setInstant(Instant.parse("2010-01-22T00:00:00Z"));
    452452        assertTrue(SearchCompiler.compile("timestamp:2010/2011").match(n1));
    453453        assertTrue(SearchCompiler.compile("timestamp:2010-01/2011").match(n1));
     
    455455        assertFalse(SearchCompiler.compile("timestamp:2010-01-23/2011").match(n1));
    456456        assertFalse(SearchCompiler.compile("timestamp:2010/2010-01-21").match(n1));
    457         n1.setTimestamp(DateUtils.fromString("2016-01-22"));
     457        n1.setInstant(Instant.parse("2016-01-22T00:00:00Z"));
    458458        assertFalse(SearchCompiler.compile("timestamp:2010/2011").match(n1));
    459459    }
  • trunk/test/unit/org/openstreetmap/josm/io/OsmJsonReaderTest.java

    r17275 r17749  
    99import java.io.InputStream;
    1010import java.nio.charset.StandardCharsets;
     11import java.time.Instant;
    1112import java.util.Iterator;
    1213
     
    131132        assertEquals(1, n.getUniqueId());
    132133        assertEquals(new LatLon(2.0, -3.0), n.getCoor());
    133         assertEquals("2018-01-01T00:00:00Z", DateUtils.newIsoDateTimeFormat().format(n.getTimestamp()));
     134        assertEquals(Instant.parse("2018-01-01T00:00:00Z"), n.getInstant());
    134135        assertEquals(4, n.getVersion());
    135136        assertEquals(5, n.getChangesetId());
  • trunk/test/unit/org/openstreetmap/josm/io/OsmWriterTest.java

    r17717 r17749  
    2424import org.openstreetmap.josm.data.osm.DataSet;
    2525import org.openstreetmap.josm.data.osm.DownloadPolicy;
     26import org.openstreetmap.josm.data.osm.INode;
     27import org.openstreetmap.josm.data.osm.Node;
    2628import org.openstreetmap.josm.data.osm.NodeData;
    2729import org.openstreetmap.josm.data.osm.UploadPolicy;
     
    127129        }
    128130    }
     131
     132    /**
     133     * Unit test of {@link OsmWriter#visit(INode)}.
     134     * @throws IOException if an I/O error occurs
     135     */
     136    @Test
     137    void testNode() throws IOException {
     138        Node node = new Node(1, 42);
     139        node.setCoor(new LatLon(12., 34.));
     140        node.setInstant(Instant.parse("2006-05-10T18:27:47Z"));
     141        try (StringWriter stringWriter = new StringWriter();
     142             OsmWriter osmWriter = OsmWriterFactory.createOsmWriter(new PrintWriter(stringWriter), true, OsmWriter.DEFAULT_API_VERSION)) {
     143            osmWriter.visit(node);
     144            assertEquals("  <node id='1' timestamp='2006-05-10T18:27:47Z' visible='true' version='42' lat='12.0' lon='34.0' />\n",
     145                    stringWriter.toString().replace("\r", ""));
     146        }
     147    }
    129148}
Note: See TracChangeset for help on using the changeset viewer.