### Question:
SyncDB { public Map<String,Integer> getMods () { return new HashMap<String,Integer>(_mods); } protected  SyncDB(Platform platform); int version(); boolean hasUnsyncedChanges(); Map<String,String> getDelta(); Map<String,Integer> getMods(); void noteSync(int version, Map<String,Integer> syncedMods); boolean containsMerges(Map<String,String> delta); void applyDelta(int version, Map<String,String> delta); void prepareToMeld(); void processPurges();  }### Answer:
@Test public void testSimpleSync () { Protocol.Session session = testSession(); TestDB one = new TestDB(), two = new TestDB(); one.trueBool.update(true); one.maxInt.update(42); one.maxLong.update(400L); one.serverString.update("foo"); one.unionSet.add("one"); one.unionSet.add("two"); one.unionSet.add("three"); one.interSet.add("four"); one.serverSet.add("five"); session.sync(one); session.sync(two); one.assertEquals(two); assertEquals(0, one.getMods().size()); assertEquals(0, two.getMods().size()); }
@Test public void testModsWhileSyncing () { final TestDB one = new TestDB(), two = new TestDB(); Protocol.Session session = new Protocol.Session(new TestServer()) { @Override protected void onSyncSuccess (SyncDB db, Map<String,Integer> mods, Protocol.Response rsp) { if (rsp.cleanSync) { one.maxInt.update(50); one.maxLong.update(400L); } super.onSyncSuccess(db, mods, rsp); } @Override protected void onSyncFailure (SyncDB db, Throwable cause) { System.err.println("Sync failure " + cause); } }; one.trueBool.update(true); one.maxInt.update(42); one.serverString.update("foo"); session.sync(one); session.sync(two); assertEquals(Sets.newHashSet("maxInt", "maxLong"), one.getMods().keySet()); assertEquals(0, two.getMods().size()); }
@Test public void testSets () { Protocol.Session session = testSession(); TestDB one = new TestDB(), two = new TestDB(); one.unionSet.add("one"); one.unionSet.add("two"); one.interSet.add("1"); one.interSet.add("2"); one.serverSet.add("a"); one.serverSet.add("b"); session.sync(one); session.sync(two); one.unionSet.add("three"); two.unionSet.add("four"); one.interSet.remove("1"); two.interSet.add("3"); one.serverSet.add("c"); two.serverSet.remove("b"); session.sync(one); session.sync(two); session.sync(one); one.assertEquals(two); assertEquals(Sets.newHashSet("one", "two", "three", "four"), two.unionSet); assertEquals(Sets.newHashSet("2"), two.interSet); assertEquals(Sets.newHashSet("a", "b", "c"), two.serverSet); one.assertEquals(one.clone()); assertEquals(0, one.getMods().size()); assertEquals(0, two.getMods().size()); }