VClock { public void merge(VClock other) { for (Map.Entry<String, Long> clock : other.vc.entrySet()) { Long time = this.vc.get(clock.getKey()); if (time == null) { this.vc.put(clock.getKey(), clock.getValue()); } else { if (time < clock.getValue()) this.vc.put(clock.getKey(), clock.getValue()); } } } VClock(); void tick(String pid); void set(String pid, long ticks); VClock copy(); long findTicks(String pid); long lastUpdate(); void merge(VClock other); String returnVCString(); void printVC(); TreeMap<String, Long> getClockMap();  }
@Test public void merge() throws Exception { VClock testClock2 = new VClock(); testClock.set("Proc1", 1); testClock.set("Proc2", 2); testClock2.set("Proc2", 3); testClock2.set("Proc3", 1); VClock mergeClock = testClock.copy(); mergeClock.merge(testClock2); assertEquals("The clock did not merge correctly!", "{\"Proc1\":1, \"Proc2\":3," + " \"Proc3\":1}", mergeClock.returnVCString()); }