Changeset 17838 in josm for trunk/test/unit


Ignore:
Timestamp:
2021-05-01T11:39:00+02:00 (4 years ago)
Author:
simon04
Message:

see #14176 - Migrate HistoryOsmPrimitive to Instant

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

Legend:

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

    r17275 r17838  
    77import static org.junit.jupiter.api.Assertions.fail;
    88
    9 import java.util.Date;
     9import java.time.Instant;
    1010import java.util.Iterator;
    1111
     
    4040    void testIterator() {
    4141        final ChangesetDataSet cds = new ChangesetDataSet();
    42         HistoryNode prim1 = new HistoryNode(1, 1, true, User.getAnonymous(), 1, new Date(), LatLon.ZERO);
     42        HistoryNode prim1 = new HistoryNode(1, 1, true, User.getAnonymous(), 1, Instant.now(), LatLon.ZERO);
    4343        cds.put(prim1, ChangesetModificationType.CREATED);
    4444        Iterator<ChangesetDataSetEntry> it = cds.iterator();
     
    6262    void testGetEntry() {
    6363        final ChangesetDataSet cds = new ChangesetDataSet();
    64         HistoryNode prim1 = new HistoryNode(1, 1, true, User.getAnonymous(), 1, new Date(), LatLon.ZERO);
     64        HistoryNode prim1 = new HistoryNode(1, 1, true, User.getAnonymous(), 1, Instant.now(), LatLon.ZERO);
    6565        cds.put(prim1, ChangesetModificationType.CREATED);
    66         HistoryNode prim2 = new HistoryNode(1, 2, true, User.getAnonymous(), 1, new Date(), LatLon.ZERO);
     66        HistoryNode prim2 = new HistoryNode(1, 2, true, User.getAnonymous(), 1, Instant.now(), LatLon.ZERO);
    6767        prim2.put("highway", "stop");
    6868        cds.put(prim2, ChangesetModificationType.UPDATED);
    6969        assertEquals(prim1, cds.getFirstEntry(prim1.getPrimitiveId()).getPrimitive());
    7070        assertEquals(prim2, cds.getLastEntry(prim1.getPrimitiveId()).getPrimitive());
    71         HistoryNode prim3 = new HistoryNode(1, 3, false, User.getAnonymous(), 1, new Date(), null);
     71        HistoryNode prim3 = new HistoryNode(1, 3, false, User.getAnonymous(), 1, Instant.now(), null);
    7272
    7373        cds.put(prim3, ChangesetModificationType.DELETED);
  • trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryNodeTest.java

    r17275 r17838  
    55import static org.junit.jupiter.api.Assertions.assertTrue;
    66
    7 import java.util.Date;
     7import java.time.Instant;
    88import java.util.HashMap;
    99import java.util.Map;
     
    3232    public JOSMTestRules test = new JOSMTestRules();
    3333
    34     private static HistoryNode create(Date d) {
     34    private static HistoryNode create(Instant d) {
    3535        return new HistoryNode(
    3636                1L,   // id
     
    4949    @Test
    5050    void testHistoryNode() {
    51         Date d = new Date();
     51        Instant d = Instant.now();
    5252        HistoryNode node = create(d);
    5353
     
    5858        assertEquals(3, node.getUser().getId());
    5959        assertEquals(4, node.getChangesetId());
    60         assertEquals(d, node.getTimestamp());
     60        assertEquals(d, node.getInstant());
    6161    }
    6262
     
    6666    @Test
    6767    void testGetType() {
    68         assertEquals(OsmPrimitiveType.NODE, create(new Date()).getType());
     68        assertEquals(OsmPrimitiveType.NODE, create(Instant.now()).getType());
    6969    }
    7070
     
    8686    @Test
    8787    void testGetDisplayName() {
    88         HistoryNode node = create(new Date());
     88        HistoryNode node = create(Instant.now());
    8989        HistoryNameFormatter hnf = DefaultNameFormatter.getInstance();
    9090        assertEquals("1 (0.0, 0.0)", node.getDisplayName(hnf));
  • trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryRelationTest.java

    r17275 r17838  
    55import static org.junit.jupiter.api.Assertions.assertTrue;
    66
    7 import java.util.Date;
     7import java.time.Instant;
    88import java.util.HashMap;
    99import java.util.Map;
     
    3131    public JOSMTestRules test = new JOSMTestRules();
    3232
    33     private static HistoryRelation create(Date d) {
     33    private static HistoryRelation create(Instant d) {
    3434        return new HistoryRelation(
    3535                1,    // id
     
    4747    @Test
    4848    void testHistoryRelation() {
    49         Date d = new Date();
     49        Instant d = Instant.now();
    5050        HistoryRelation rel = create(d);
    5151
     
    5656        assertEquals(3, rel.getUser().getId());
    5757        assertEquals(4, rel.getChangesetId());
    58         assertEquals(d, rel.getTimestamp());
     58        assertEquals(d, rel.getInstant());
    5959    }
    6060
     
    6464    @Test
    6565    void testGetType() {
    66         assertEquals(OsmPrimitiveType.RELATION, create(new Date()).getType());
     66        assertEquals(OsmPrimitiveType.RELATION, create(Instant.now()).getType());
    6767    }
    6868
     
    7373    void testGetDisplayName() {
    7474        HistoryNameFormatter hnf = DefaultNameFormatter.getInstance();
    75         HistoryRelation rel0 = create(new Date()); // 0 member
    76         HistoryRelation rel1 = create(new Date()); // 1 member
    77         HistoryRelation rel2 = create(new Date()); // 2 members
     75        HistoryRelation rel0 = create(Instant.now()); // 0 member
     76        HistoryRelation rel1 = create(Instant.now()); // 1 member
     77        HistoryRelation rel2 = create(Instant.now()); // 2 members
    7878
    7979        rel1.addMember(new RelationMemberData(null, OsmPrimitiveType.NODE, 1));
  • trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryWayTest.java

    r17275 r17838  
    66import static org.junit.jupiter.api.Assertions.fail;
    77
    8 import java.util.Date;
     8import java.time.Instant;
    99import java.util.HashMap;
    1010import java.util.List;
     
    3333    public JOSMTestRules test = new JOSMTestRules();
    3434
    35     private static HistoryWay create(Date d) {
     35    private static HistoryWay create(Instant d) {
    3636        return new HistoryWay(
    3737                1,    // id
     
    4949    @Test
    5050    void testHistoryWay() {
    51         Date d = new Date();
     51        Instant d = Instant.now();
    5252        HistoryWay way = create(d);
    5353
     
    5858        assertEquals(3, way.getUser().getId());
    5959        assertEquals(4, way.getChangesetId());
    60         assertEquals(d, way.getTimestamp());
     60        assertEquals(d, way.getInstant());
    6161
    6262        assertEquals(0, way.getNumNodes());
     
    6868    @Test
    6969    void testGetType() {
    70         assertEquals(OsmPrimitiveType.WAY, create(new Date()).getType());
     70        assertEquals(OsmPrimitiveType.WAY, create(Instant.now()).getType());
    7171    }
    7272
    7373    @Test
    7474    void testNodeManipulation() {
    75         HistoryWay way = create(new Date());
     75        HistoryWay way = create(Instant.now());
    7676
    7777        way.addNode(1);
     
    9393    @Test
    9494    void testIterating() {
    95         HistoryWay way = create(new Date());
     95        HistoryWay way = create(Instant.now());
    9696
    9797        way.addNode(1);
     
    110110    void testGetDisplayName() {
    111111        HistoryNameFormatter hnf = DefaultNameFormatter.getInstance();
    112         HistoryWay way0 = create(new Date()); // no node
    113         HistoryWay way1 = create(new Date()); // 1 node
    114         HistoryWay way2 = create(new Date()); // 2 nodes
     112        HistoryWay way0 = create(Instant.now()); // no node
     113        HistoryWay way1 = create(Instant.now()); // 1 node
     114        HistoryWay way2 = create(Instant.now()); // 2 nodes
    115115
    116116        way1.addNode(1);
  • trunk/test/unit/org/openstreetmap/josm/gui/history/HistoryBrowserDialogTest.java

    r17275 r17838  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 import java.util.Date;
     6import java.time.Instant;
    77
    88import org.junit.jupiter.api.extension.RegisterExtension;
     
    1515import org.openstreetmap.josm.data.osm.history.HistoryWay;
    1616import org.openstreetmap.josm.testutils.JOSMTestRules;
    17 import org.openstreetmap.josm.tools.date.DateUtils;
    1817
    1918import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    3837        HistoryDataSet hds = new HistoryDataSet();
    3938        User user = User.createOsmUser(1, "");
    40         Date date = DateUtils.fromString("2016-01-01");
     39        Instant date = Instant.parse("2016-01-01T00:00:00Z");
    4140        hds.put(new HistoryNode(1, 1, true, user, 1, date, null));
    4241        assertEquals("History for node 1", HistoryBrowserDialog.buildTitle(hds.getHistory(1, OsmPrimitiveType.NODE)));
  • trunk/test/unit/org/openstreetmap/josm/io/OsmChangesetContentParserTest.java

    r17275 r17838  
    116116        assertEquals(1, p.getVersion());
    117117        assertEquals(1, p.getChangesetId());
    118         assertNotNull(p.getTimestamp());
     118        assertNotNull(p.getInstant());
    119119        assertEquals(ChangesetModificationType.CREATED, ds.getModificationType(p.getPrimitiveId()));
    120120        assertTrue(ds.isCreated(p.getPrimitiveId()));
     
    146146        assertEquals(1, p.getVersion());
    147147        assertEquals(1, p.getChangesetId());
    148         assertNotNull(p.getTimestamp());
     148        assertNotNull(p.getInstant());
    149149        assertEquals(ChangesetModificationType.UPDATED, ds.getModificationType(p.getPrimitiveId()));
    150150        assertTrue(ds.isUpdated(p.getPrimitiveId()));
     
    176176        assertEquals(1, p.getVersion());
    177177        assertEquals(1, p.getChangesetId());
    178         assertNotNull(p.getTimestamp());
     178        assertNotNull(p.getInstant());
    179179        assertEquals(ChangesetModificationType.DELETED, ds.getModificationType(p.getPrimitiveId()));
    180180        assertTrue(ds.isDeleted(p.getPrimitiveId()));
     
    218218        assertEquals(1, p.getVersion());
    219219        assertEquals(1, p.getChangesetId());
    220         assertNotNull(p.getTimestamp());
     220        assertNotNull(p.getInstant());
    221221        assertEquals(ChangesetModificationType.CREATED, ds.getModificationType(p.getPrimitiveId()));
    222222        assertTrue(ds.isCreated(p.getPrimitiveId()));
     
    228228        assertEquals(2, w.getVersion());
    229229        assertEquals(1, w.getChangesetId());
    230         assertNotNull(w.getTimestamp());
     230        assertNotNull(w.getInstant());
    231231        assertEquals(ChangesetModificationType.UPDATED, ds.getModificationType(w.getPrimitiveId()));
    232232        assertTrue(ds.isUpdated(w.getPrimitiveId()));
     
    239239        assertEquals(3, r.getVersion());
    240240        assertEquals(1, r.getChangesetId());
    241         assertNotNull(r.getTimestamp());
     241        assertNotNull(r.getInstant());
    242242        assertEquals(ChangesetModificationType.DELETED, ds.getModificationType(r.getPrimitiveId()));
    243243        assertTrue(ds.isDeleted(r.getPrimitiveId()));
  • trunk/test/unit/org/openstreetmap/josm/io/OsmServerHistoryReaderTest.java

    r17194 r17838  
    1717
    1818import com.github.tomakehurst.wiremock.junit.WireMockRule;
     19
     20import java.time.Instant;
    1921
    2022/**
     
    5052        assertEquals(1, h.getLatest().getNumKeys());
    5153        assertEquals(65565982, h.getLatest().getChangesetId());
    52         assertEquals(1545089885000L, h.getLatest().getTimestamp().getTime());
     54        assertEquals(Instant.ofEpochMilli(1545089885000L), h.getLatest().getInstant());
    5355    }
    5456
     
    6567        assertEquals(10, h.getLatest().getNumKeys());
    6668        assertEquals(26368284, h.getLatest().getChangesetId());
    67         assertEquals(1414429134000L, h.getLatest().getTimestamp().getTime());
     69        assertEquals(Instant.ofEpochMilli(1414429134000L), h.getLatest().getInstant());
    6870    }
    6971
     
    8082        assertEquals(0, h.getLatest().getNumKeys());
    8183        assertEquals(486501, h.getLatest().getChangesetId());
    82         assertEquals(1194886166000L, h.getLatest().getTimestamp().getTime());
     84        assertEquals(Instant.ofEpochMilli(1194886166000L), h.getLatest().getInstant());
    8385    }
    8486}
Note: See TracChangeset for help on using the changeset viewer.