source: josm/trunk/test/unit/org/openstreetmap/josm/data/notes/NoteTest.java@ 10758

Last change on this file since 10758 was 10758, checked in by Don-vip, 8 years ago

sonar - squid:S3578 - Test methods should comply with a naming convention

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.notes;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNotEquals;
6
7import java.util.Date;
8
9import org.junit.BeforeClass;
10import org.junit.Test;
11import org.openstreetmap.josm.JOSMFixture;
12import org.openstreetmap.josm.data.coor.LatLon;
13
14import nl.jqno.equalsverifier.EqualsVerifier;
15import nl.jqno.equalsverifier.Warning;
16
17/**
18 * Unit tests for class {@link NoteComment}.
19 */
20public class NoteTest {
21
22 /**
23 * Setup test.
24 */
25 @BeforeClass
26 public static void init() {
27 JOSMFixture.createUnitTestFixture().init();
28 }
29
30 /**
31 * Unit test of {@link Note#toString} method.
32 */
33 @Test
34 public void testToString() {
35 Note note = new Note(LatLon.ZERO);
36 assertEquals("Note 0: null", note.toString());
37 note.addComment(new NoteComment(new Date(), null, "foo", null, true));
38 assertEquals("Note 0: foo", note.toString());
39 }
40
41 /**
42 * Unit test of {@link Note#updateWith} method.
43 */
44 @Test
45 public void testUpdateWith() {
46 Note n1 = new Note(LatLon.ZERO);
47 n1.setId(1);
48 Note n2 = new Note(LatLon.ZERO);
49 n1.setId(2);
50 assertNotEquals(n1, n2);
51 n1.updateWith(n2);
52 assertEquals(n1, n2);
53 }
54
55 /**
56 * Unit test of methods {@link Note#equals} and {@link Note#hashCode}.
57 */
58 @Test
59 public void testEqualsContract() {
60 EqualsVerifier.forClass(Note.class).usingGetClass()
61 .withIgnoredFields("latLon", "createdAt", "closedAt", "state", "comments")
62 .suppress(Warning.NONFINAL_FIELDS)
63 .withPrefabValues(LatLon.class, LatLon.ZERO, new LatLon(1, 1))
64 .withPrefabValues(NoteComment.class,
65 new NoteComment(new Date(), null, "foo", null, true),
66 new NoteComment(new Date(), null, "bar", null, false))
67 .verify();
68 }
69}
Note: See TracBrowser for help on using the repository browser.