Skip to content

Commit 1bc9272

Browse files
committed
PrefServiceTest: merge in existing Prefs tests
1 parent 606f9f2 commit 1bc9272

File tree

2 files changed

+39
-81
lines changed

2 files changed

+39
-81
lines changed

src/test/java/org/scijava/prefs/PrefServiceTest.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
import static org.junit.Assert.assertNull;
3737
import static org.junit.Assert.assertTrue;
3838

39+
import java.util.ArrayList;
40+
import java.util.HashMap;
41+
import java.util.List;
42+
import java.util.Map;
43+
3944
import org.junit.After;
4045
import org.junit.Before;
4146
import org.junit.Test;
@@ -136,4 +141,38 @@ public void testLong() {
136141
assertTrue(prefService.getLong(getClass(), "power level", dv) > 9000);
137142
}
138143

144+
/**
145+
* Tests {@link PrefService#putMap(Class, Map, String)} and
146+
* {@link PrefService#getMap(Class, String)}.
147+
*/
148+
@Test
149+
public void testMap() {
150+
final Map<String, String> map = new HashMap<String, String>();
151+
map.put("0", "A");
152+
map.put("1", "B");
153+
map.put("2", "C");
154+
map.put("3", "D");
155+
map.put("5", "f");
156+
final String mapKey = "MapKey";
157+
prefService.putMap(getClass(), map, mapKey);
158+
final Map<String, String> result = prefService.getMap(getClass(), mapKey);
159+
assertEquals(map, result);
160+
}
161+
162+
/**
163+
* Tests {@link PrefService#putList(Class, List, String)} and
164+
* {@link PrefService#getList(Class, String)}.
165+
*/
166+
@Test
167+
public void testList() {
168+
final String recentFilesKey = "RecentFiles";
169+
final List<String> recentFiles = new ArrayList<String>();
170+
recentFiles.add("some/path1");
171+
recentFiles.add("some/path2");
172+
recentFiles.add("some/path3");
173+
prefService.putList(getClass(), recentFiles, recentFilesKey);
174+
final List<String> result = prefService.getList(getClass(), recentFilesKey);
175+
assertEquals(recentFiles, result);
176+
}
177+
139178
}

src/test/java/org/scijava/util/PrefsTest.java

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)