Changeset 18009 in josm for trunk/test
- Timestamp:
- 2021-07-13T00:27:59+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/osm/NoteDataTest.java
r17275 r18009 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 import static org.junit.jupiter.api.Assertions.assertThrows; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 5 9 6 10 import java.util.Arrays; 11 import java.util.List; 7 12 8 13 import org.junit.jupiter.api.Test; 14 import org.junit.jupiter.api.extension.RegisterExtension; 9 15 import org.openstreetmap.josm.data.coor.LatLon; 10 16 import org.openstreetmap.josm.data.notes.Note; 17 import org.openstreetmap.josm.data.notes.Note.State; 18 import org.openstreetmap.josm.data.notes.NoteComment; 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 11 22 12 23 /** … … 14 25 */ 15 26 class NoteDataTest { 27 28 /** 29 * Setup test. 30 */ 31 @RegisterExtension 32 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 33 public JOSMTestRules test = new JOSMTestRules().preferences(); 16 34 17 35 /** … … 25 43 assertEquals(1, notEmpty.getNotes().size()); 26 44 } 45 46 /** 47 * Unit test for {@link NoteData#closeNote} 48 */ 49 @Test 50 void testCloseNote_nominal() { 51 Note note = new Note(LatLon.ZERO); 52 note.setState(State.OPEN); 53 assertNull(note.getClosedAt()); 54 assertTrue(note.getComments().isEmpty()); 55 56 NoteData data = new NoteData(Arrays.asList(note)); 57 data.closeNote(note, "foo"); 58 59 assertEquals(State.CLOSED, note.getState()); 60 assertNotNull(note.getClosedAt()); 61 List<NoteComment> comments = note.getComments(); 62 assertEquals(1, comments.size()); 63 NoteComment comment = comments.get(0); 64 assertEquals("foo", comment.getText()); 65 assertEquals(note.getClosedAt(), comment.getCommentTimestamp()); 66 } 67 68 /** 69 * Checks that closeNote does not throw NPE on null arguments 70 */ 71 @Test 72 void testCloseNote_nullsafe() { 73 assertEquals("Note to close must be in layer", 74 assertThrows(IllegalArgumentException.class, 75 () -> new NoteData().closeNote(null, null)).getMessage()); 76 } 27 77 }
Note:
See TracChangeset
for help on using the changeset viewer.