|
36 | 36 | import static org.junit.Assert.assertNull; |
37 | 37 | import static org.junit.Assert.assertTrue; |
38 | 38 |
|
| 39 | +import java.util.ArrayList; |
| 40 | +import java.util.HashMap; |
| 41 | +import java.util.List; |
| 42 | +import java.util.Map; |
| 43 | + |
39 | 44 | import org.junit.After; |
40 | 45 | import org.junit.Before; |
41 | 46 | import org.junit.Test; |
@@ -136,4 +141,38 @@ public void testLong() { |
136 | 141 | assertTrue(prefService.getLong(getClass(), "power level", dv) > 9000); |
137 | 142 | } |
138 | 143 |
|
| 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 | + |
139 | 178 | } |
0 commit comments