source: josm/trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/PrefEntryTest.java@ 10047

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

update to equalsverifier 2.0

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.advanced;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertFalse;
6import static org.junit.Assert.assertTrue;
7
8import org.junit.BeforeClass;
9import org.junit.Test;
10import org.openstreetmap.josm.JOSMFixture;
11import org.openstreetmap.josm.data.preferences.StringSetting;
12
13import nl.jqno.equalsverifier.EqualsVerifier;
14
15/**
16 * Unit tests of {@link PrefEntry} class.
17 */
18public class PrefEntryTest {
19
20 /**
21 * Setup test.
22 */
23 @BeforeClass
24 public static void setUpBeforeClass() {
25 JOSMFixture.createUnitTestFixture().init();
26 }
27
28 /**
29 * Unit test of {@link PrefEntry#PrefEntry}.
30 */
31 @Test
32 public void testPrefEntry() {
33 String key = "key";
34 StringSetting val = new StringSetting("value");
35 StringSetting def = new StringSetting("defaultValue");
36 PrefEntry pe = new PrefEntry(key, val, def, false);
37 assertFalse(pe.isDefault());
38 assertEquals(key, pe.getKey());
39 assertEquals(val, pe.getValue());
40 assertEquals(def, pe.getDefaultValue());
41 StringSetting val2 = new StringSetting("value2");
42 assertFalse(pe.isChanged());
43 pe.setValue(val2);
44 assertEquals(val2, pe.getValue());
45 assertEquals(val2.toString(), pe.toString());
46 assertTrue(pe.isChanged());
47 pe.reset();
48 pe.markAsChanged();
49 assertTrue(pe.isChanged());
50 }
51
52 /**
53 * Unit test of methods {@link PrefEntry#equals} and {@link PrefEntry#hashCode}.
54 */
55 @Test
56 public void equalsContract() {
57 EqualsVerifier.forClass(PrefEntry.class).usingGetClass()
58 .withIgnoredFields("value", "defaultValue", "isDefault", "changed")
59 .verify();
60 }
61}
Note: See TracBrowser for help on using the repository browser.