Changeset 17712 in josm for trunk/test/unit


Ignore:
Timestamp:
2021-04-07T22:34:03+02:00 (3 years ago)
Author:
simon04
Message:

see #14176 - Migrate Note/NoteComment to Instant

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

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/notes/NoteCommentTest.java

    r17275 r17712  
    66import static org.junit.jupiter.api.Assertions.assertTrue;
    77
    8 import java.util.Date;
     8import java.time.Instant;
    99
    1010import org.junit.jupiter.api.extension.RegisterExtension;
     
    3131    @Test
    3232    void testNoteComment() {
    33         NoteComment comment = new NoteComment(new Date(), null, "foo", null, true);
     33        NoteComment comment = new NoteComment(Instant.now(), null, "foo", null, true);
    3434        assertEquals("foo", comment.toString());
    3535        assertTrue(comment.isNew());
  • trunk/test/unit/org/openstreetmap/josm/data/notes/NoteTest.java

    r17275 r17712  
    55import static org.junit.jupiter.api.Assertions.assertNotEquals;
    66
    7 import java.util.Date;
     7import java.time.Instant;
    88
    99import org.junit.jupiter.api.extension.RegisterExtension;
     
    3636        Note note = new Note(LatLon.ZERO);
    3737        assertEquals("Note 0: null", note.toString());
    38         note.addComment(new NoteComment(new Date(), null, "foo", null, true));
     38        note.addComment(new NoteComment(Instant.now(), null, "foo", null, true));
    3939        assertEquals("Note 0: foo", note.toString());
    4040    }
     
    6565            .withPrefabValues(LatLon.class, LatLon.ZERO, new LatLon(1, 1))
    6666            .withPrefabValues(NoteComment.class,
    67                     new NoteComment(new Date(), null, "foo", null, true),
    68                     new NoteComment(new Date(), null, "bar", null, false))
     67                    new NoteComment(Instant.now(), null, "foo", null, true),
     68                    new NoteComment(Instant.now(), null, "bar", null, false))
    6969            .verify();
    7070    }
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/NotesDialogTest.java

    r17269 r17712  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 import java.util.Date;
     6import java.time.Instant;
    77
    88import javax.swing.JLabel;
     
    3535    void testMultiLineNoteRendering() {
    3636        Note note = new Note(LatLon.ZERO);
    37         note.setCreatedAt(new Date());
    38         note.addComment(new NoteComment(new Date(), User.createLocalUser(null), "foo\nbar\n\nbaz:\nfoo", null, false));
     37        note.setCreatedAt(Instant.now());
     38        note.addComment(new NoteComment(Instant.now(), User.createLocalUser(null), "foo\nbar\n\nbaz:\nfoo", null, false));
    3939        assertEquals("0: foo; bar; baz: foo",
    4040                ((JLabel) new NoteRenderer().getListCellRendererComponent(new JList<>(), note, 0, false, false)).getText());
  • trunk/test/unit/org/openstreetmap/josm/io/NoteReaderTest.java

    r17275 r17712  
    6464        assertEquals(1, list.size());
    6565        Note n = list.get(0);
    66         assertEquals(DateUtils.fromString("2013-04-24 08:08:51 UTC"), n.getClosedAt());
    67         assertEquals(DateUtils.fromString("2013-04-24 08:07:02 UTC"), n.getCreatedAt());
     66        assertEquals(DateUtils.parseInstant("2013-04-24 08:08:51 UTC"), n.getClosedAt());
     67        assertEquals(DateUtils.parseInstant("2013-04-24 08:07:02 UTC"), n.getCreatedAt());
    6868        assertEquals(4, n.getId());
    6969        assertEquals(new LatLon(36.7232991, 68.86415), n.getLatLon());
     
    7474        NoteComment c1 = comments.get(0);
    7575        assertEquals(c1, n.getFirstComment());
    76         assertEquals(DateUtils.fromString("2013-04-24 08:07:02 UTC"), c1.getCommentTimestamp());
     76        assertEquals(DateUtils.parseInstant("2013-04-24 08:07:02 UTC"), c1.getCommentTimestamp());
    7777        assertEquals(Action.OPENED, c1.getNoteAction());
    7878        assertEquals("test", c1.getText());
  • trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java

    r17275 r17712  
    1010
    1111import java.text.DateFormat;
     12import java.time.Instant;
     13import java.time.format.FormatStyle;
    1214import java.util.Date;
    1315import java.util.Random;
     
    272274        assertNotSame(date, DateUtils.cloneDate(date));
    273275    }
     276
     277    /**
     278     * Unit test of {@link DateUtils#getDateTimeFormatter} method.
     279     */
     280    @Test
     281    void testDateTimeFormatter() {
     282        Instant instant = Instant.parse("2006-01-02T15:04:05Z");
     283        Boolean iso = DateUtils.PROP_ISO_DATES.get();
     284        try {
     285            assertNotNull(DateUtils.getDateFormatter(FormatStyle.SHORT).format(instant));
     286            assertNotNull(DateUtils.getTimeFormatter(FormatStyle.SHORT).format(instant));
     287            assertNotNull(DateUtils.getDateTimeFormatter(FormatStyle.SHORT, FormatStyle.SHORT).format(instant));
     288            DateUtils.PROP_ISO_DATES.put(!iso);
     289            assertNotNull(DateUtils.getDateFormatter(FormatStyle.SHORT).format(instant));
     290            assertNotNull(DateUtils.getTimeFormatter(FormatStyle.SHORT).format(instant));
     291            assertNotNull(DateUtils.getDateTimeFormatter(FormatStyle.SHORT, FormatStyle.SHORT).format(instant));
     292        } finally {
     293            DateUtils.PROP_ISO_DATES.put(iso);
     294        }
     295    }
    274296}
Note: See TracChangeset for help on using the changeset viewer.