Credential expected = createCredential();
store.store(USER_ID, expected);
// migrate to new store
File dataDir = Files.createTempDir();
dataDir.deleteOnExit();
FileDataStoreFactory newFactory = new FileDataStoreFactory(dataDir);
store.migrateTo(newFactory);
// check new store
DataStore<StoredCredential> newStore =
newFactory.getDataStore(StoredCredential.DEFAULT_DATA_STORE_ID);
assertEquals(ImmutableSet.of(USER_ID), newStore.keySet());
StoredCredential actual = newStore.get(USER_ID);
assertEquals(expected.getAccessToken(), actual.getAccessToken());
assertEquals(expected.getRefreshToken(), actual.getRefreshToken());
assertEquals(expected.getExpirationTimeMilliseconds(), actual.getExpirationTimeMilliseconds());