use of net.grandcentrix.tray.core.TrayItem in project tray by grandcentrix.
the class ContentProviderStorageTest method checkVersionAfterClear.
private void checkVersionAfterClear(final ContentProviderStorage storage) throws Exception {
assertTrue(storage.put("key", "value"));
final TrayItem key = storage.get("key");
assertNotNull(key);
assertEquals("value", key.value());
storage.setVersion(1);
assertEquals(1, storage.getVersion());
storage.clear();
assertNull(storage.get("key"));
assertEquals(0, storage.getAll().size());
assertEquals(1, storage.getVersion());
}
use of net.grandcentrix.tray.core.TrayItem in project tray by grandcentrix.
the class TrayProviderHelperTest method testUpdateEqualsCreatedAtFirst.
public void testUpdateEqualsCreatedAtFirst() throws Exception {
assertTrue(mProviderHelper.persist(MODULE_A, KEY_A, STRING_A));
final List<TrayItem> list = mProviderHelper.queryProvider(getUri(MODULE_A, KEY_A));
assertNotNull(list);
assertEquals(1, list.size());
TrayItem itemA = list.get(0);
assertNotNull(itemA.created());
assertNotNull(itemA.updateTime());
assertEquals(itemA.updateTime(), itemA.created());
}
use of net.grandcentrix.tray.core.TrayItem in project tray by grandcentrix.
the class TrayItemTest method testNullValues.
public void testNullValues() throws Exception {
final TrayItem item = new TrayItem(null, null, null, null, null, null);
assertEquals(null, item.key());
assertEquals(null, item.value());
assertEquals(null, item.migratedKey());
assertEquals(null, item.module());
assertEquals(null, item.updateTime());
assertEquals(null, item.created());
}
use of net.grandcentrix.tray.core.TrayItem in project tray by grandcentrix.
the class TrayProviderHelperTest method testCursorToTrayItem.
public void testCursorToTrayItem() throws Exception {
final MatrixCursor matrixCursor = new MatrixCursor(new String[] { TrayContract.Preferences.Columns.KEY, TrayContract.Preferences.Columns.VALUE, TrayContract.Preferences.Columns.MODULE, TrayContract.Preferences.Columns.CREATED, TrayContract.Preferences.Columns.UPDATED, TrayContract.Preferences.Columns.MIGRATED_KEY });
final Date created = new Date();
final Date updated = new Date();
matrixCursor.addRow(new Object[] { "key", "value", "module", created.getTime(), updated.getTime(), "migratedKey" });
assertTrue(matrixCursor.moveToFirst());
final TrayItem item = TrayProviderHelper.cursorToTrayItem(matrixCursor);
assertEquals("key", item.key());
assertEquals("value", item.value());
assertEquals("migratedKey", item.migratedKey());
assertEquals("module", item.module());
assertEquals(updated, item.updateTime());
assertEquals(created, item.created());
}
use of net.grandcentrix.tray.core.TrayItem in project tray by grandcentrix.
the class TrayProviderHelperTest method testReadParsedProperties.
public void testReadParsedProperties() throws Exception {
assertTrue(mProviderHelper.persist(MODULE_A, KEY_A, STRING_A));
final List<TrayItem> list = mProviderHelper.queryProvider(getUri(MODULE_A, KEY_A));
assertNotNull(list);
assertEquals(1, list.size());
TrayItem itemA = list.get(0);
assertEquals(STRING_A, itemA.value());
assertEquals(KEY_A, itemA.key());
assertEquals(MODULE_A, itemA.module());
}
Aggregations