### Question:
Link { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Link other = (Link) obj; if (from == null) { if (other.from != null) return false; } if (to == null) { if (other.to != null) return false; } else if (from.equals(other.from) && to.equals(other.to) || from.equals(other.to) && to.equals(other.from)) { return true; } return false; }  Port getFrom(); void setFrom(Port from); Port getTo(); void setTo(Port to); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }### Answer:
@Test public void testEquals() { Port portA = new Port(); portA.setDeviceId(DEVICE_ID); portA.setId(PORT_A_ID); Port portB = new Port(); portB.setDeviceId(DEVICE_ID); portB.setId(PORT_B_ID); Link link1 = new Link(); link1.setFrom(portA); link1.setTo(portB); Link link2 = new Link(); link2.setFrom(portB); link2.setTo(portA); Assert.assertEquals("Links must be equals!", link1, link2); Assert.assertEquals("Links hash codes must be equals!", link1.hashCode(), link2.hashCode()); }