use of net.grandcentrix.tray.core.WrongTypeException in project tray by grandcentrix.
the class ReadDifferentFormat method testReadNullStringAsWrongType.
public void testReadNullStringAsWrongType() throws Exception {
assertEquals("default", mPref.getString(KEY, "default"));
mPref.put(KEY, null);
final TrayItem pref = mPref.getPref(KEY);
assertNotNull(pref);
assertEquals(null, pref.value());
assertEquals(null, mPref.getString(KEY));
assertEquals(false, mPref.getBoolean(KEY));
try {
assertEquals(0.0f, mPref.getFloat(KEY));
fail();
} catch (WrongTypeException e) {
assertTrue(e.getMessage().contains("Float"));
assertTrue(e.getMessage().contains("null"));
}
try {
assertEquals(0l, mPref.getLong(KEY));
fail();
} catch (WrongTypeException e) {
assertTrue(e.getMessage().contains("Long"));
assertTrue(e.getMessage().contains("null"));
}
try {
assertEquals(0, mPref.getInt(KEY));
fail();
} catch (WrongTypeException e) {
assertTrue(e.getMessage().contains("Integer"));
assertTrue(e.getMessage().contains("null"));
}
}
Aggregations