VClock { public void tick(String pid) { if (this.vc.containsKey(pid)) this.vc.put(pid, this.vc.get(pid) + 1); else this.vc.put(pid, (long) 1); } 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 tick() throws Exception { testClock.tick("Proc1"); TreeMap clockMap = testClock.getClockMap(); assertEquals("Key value does not match the expected value!", clockMap.get("Proc1"), 1L); assertEquals("Process ID does not conform to the expected key!", clockMap.firstEntry().getKey(), "Proc1"); testClock.tick("Proc1"); assertEquals("Key value after second tick does not match the expected value!", clockMap.get("Proc1"), 2L); assertEquals("Process ID after second tick does not conform to the expected key!", clockMap.firstEntry().getKey(), "Proc1"); testClock.tick("Proc2"); assertEquals("Key value for Proc1 does not match the expected value!", 2L, clockMap.get("Proc1")); assertEquals("Key value for Proc2 does not match the expected value!", 1L, clockMap.get("Proc2")); assertEquals("Process ID Proc1 does not conform to the expected key!", "Proc1", clockMap.firstKey()); assertEquals("Process ID Proc2 does not conform to the expected key!", "Proc2", clockMap.lastKey()); testClock.tick(""); assertEquals("Key value for Proc1 does not match the expected value!", 1L, clockMap.get("")); }
@Test(expected = NullPointerException.class) public void tickNullPointerException() { testClock.tick(null); }