Changeset 17714 in josm for trunk/test


Ignore:
Timestamp:
2021-04-07T23:41:13+02:00 (3 years ago)
Author:
simon04
Message:

fix #20583 - Filter notes in notes dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/NotesDialogTest.java

    r17712 r17714  
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
    57
    68import java.time.Instant;
     
    3234    public JOSMTestRules josmTestRules = new JOSMTestRules().preferences();
    3335
    34     @Test
    35     void testMultiLineNoteRendering() {
     36    private Note createMultiLineNote() {
    3637        Note note = new Note(LatLon.ZERO);
    3738        note.setCreatedAt(Instant.now());
    3839        note.addComment(new NoteComment(Instant.now(), User.createLocalUser(null), "foo\nbar\n\nbaz:\nfoo", null, false));
     40        return note;
     41    }
     42
     43    /**
     44     * Unit test of {@link NoteRenderer}
     45     */
     46    @Test
     47    void testMultiLineNoteRendering() {
     48        Note note = createMultiLineNote();
    3949        assertEquals("0: foo; bar; baz: foo",
    4050                ((JLabel) new NoteRenderer().getListCellRendererComponent(new JList<>(), note, 0, false, false)).getText());
    4151    }
     52
     53    /**
     54     * Unit test of {@link NotesDialog#matchesNote}
     55     */
     56    @Test
     57    void testMatchesNote() {
     58        Note note = createMultiLineNote();
     59        assertTrue(NotesDialog.matchesNote(null, note));
     60        assertTrue(NotesDialog.matchesNote("", note));
     61        assertTrue(NotesDialog.matchesNote("foo", note));
     62        assertFalse(NotesDialog.matchesNote("xxx", note));
     63        assertFalse(NotesDialog.matchesNote("open", note));
     64        assertFalse(NotesDialog.matchesNote("new", note));
     65        assertFalse(NotesDialog.matchesNote("reopened", note));
     66    }
    4267}
Note: See TracChangeset for help on using the changeset viewer.