ConnectedAgentAttache extends AgentAttache { @Override public boolean equals(final Object obj) { if (obj == null) { return false; } if (this.getClass() != obj.getClass()) { return false; } if (_link == null) { return false; } ConnectedAgentAttache that = (ConnectedAgentAttache)obj; return super.equals(obj) && _link == that._link; } ConnectedAgentAttache(final AgentManagerImpl agentMgr, final long id, final String name, final Link link, final boolean maintenance); @Override synchronized void send(final Request req); @Override synchronized boolean isClosed(); @Override void disconnect(final Status state); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void testEquals() throws Exception { Link link = mock(Link.class); ConnectedAgentAttache agentAttache1 = new ConnectedAgentAttache(null, 0, null, link, false); ConnectedAgentAttache agentAttache2 = new ConnectedAgentAttache(null, 0, null, link, false); assertTrue(agentAttache1.equals(agentAttache2)); }
@Test public void testEqualsFalseNull() throws Exception { Link link = mock(Link.class); ConnectedAgentAttache agentAttache1 = new ConnectedAgentAttache(null, 0, null, link, false); assertFalse(agentAttache1.equals(null)); }
@Test public void testEqualsFalseDiffLink() throws Exception { Link link1 = mock(Link.class); Link link2 = mock(Link.class); ConnectedAgentAttache agentAttache1 = new ConnectedAgentAttache(null, 0, null, link1, false); ConnectedAgentAttache agentAttache2 = new ConnectedAgentAttache(null, 0, null, link2, false); assertFalse(agentAttache1.equals(agentAttache2)); }
@Test public void testEqualsFalseDiffId() throws Exception { Link link1 = mock(Link.class); ConnectedAgentAttache agentAttache1 = new ConnectedAgentAttache(null, 1, null, link1, false); ConnectedAgentAttache agentAttache2 = new ConnectedAgentAttache(null, 2, null, link1, false); assertFalse(agentAttache1.equals(agentAttache2)); }
@Test public void testEqualsFalseDiffClass() throws Exception { Link link1 = mock(Link.class); ConnectedAgentAttache agentAttache1 = new ConnectedAgentAttache(null, 1, null, link1, false); assertFalse(agentAttache1.equals("abc")); }