@Test public void testSaveNewRemoteItem() { remote.add(aRemoteTask); aRemoteTask.setModified(lastSyncTime - 1000); TodoSyncAdapter.algorithm(local, remote, lastSyncTime, toSaveLocally, toSaveRemotely); assertTrue(toSaveLocally.contains(aRemoteTask)); assertTrue(!toSaveRemotely.contains(aRemoteTask)); }
@Test public void testSaveModifiedRemoteItem() { aRemoteTask.setDeviceId(222L); // So it won't be saved for not having a local ID aRemoteTask.setModified(System.currentTimeMillis() + 1000); // Should be saved for mtime remote.add(aRemoteTask); TodoSyncAdapter.algorithm(local, remote, lastSyncTime, toSaveLocally, toSaveRemotely); assertTrue(toSaveLocally.contains(aRemoteTask)); assertTrue(!toSaveRemotely.contains(aRemoteTask)); }
@Test public void testSendLocalWithHighModTime() { // Set this one's mod time past lastsynchtime so it should be sent localTaskWithBothIds.setModified(System.currentTimeMillis() + 1000); local.add(localTaskWithBothIds); local.add(localTaskWithLocalId); // Call onSynchronize core TodoSyncAdapter.algorithm(local, remote, lastSyncTime, toSaveLocally, toSaveRemotely); // Assert calls based on lists assertTrue(toSaveRemotely.contains(localTaskWithLocalId)); // Should upload this task as its mtime is high assertTrue(toSaveRemotely.contains(localTaskWithBothIds)); assertEquals("Size", 2, toSaveRemotely.size()); }
@Test public void testSendLocalWithLowModTime() { local.add(localTaskWithBothIds); local.add(localTaskWithLocalId); // Call onSynchronize core TodoSyncAdapter.algorithm(local, remote, lastSyncTime, toSaveLocally, toSaveRemotely); // Assert calls based on lists assertTrue(toSaveRemotely.contains(localTaskWithLocalId)); // Initially we will upload this task as its mtime is zero assertTrue(toSaveRemotely.contains(localTaskWithBothIds)); // So there should be 2 assertEquals("Upload both", 2, toSaveRemotely.size()); }