Edge { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Edge other = (Edge) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; return true; } Edge(String id, String src, String dest, long metric, long bandwidth);  Edge(VirtualLink virtualLink);  Edge(PhysicalLink physicalLink); String getId(); String getSrc(); String getDest(); long getMetric(); long getBandwidth(); void setMetric(long metric); void setBandwidth(long bandwidth); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testEquals() throws Exception { String s = new String("tests"); Edge obj = new Edge(s,s,s,1,1); id = src = dest = s; metric = bandwidth = 1; edge = new Edge(id,src,dest,metric,bandwidth); Edge edge1= new Edge("test1","test1","test1",1,1); Assert.assertTrue(obj.getId().equals(edge.getId())); Assert.assertTrue(obj.getSrc().equals(edge.getSrc())); Assert.assertTrue(obj.getDest().equals(edge.getDest())); Assert.assertTrue(obj.equals(obj)); Assert.assertTrue(!obj.equals(edge1)); }