### Question:
ConnectionKey implements Serializable { public boolean equals(Object o) { if (!(o instanceof ConnectionKey)) { return false; } ConnectionKey other = (ConnectionKey) o; boolean sameProvider = providerId.equals(other.providerId); return providerUserId != null ? sameProvider && providerUserId.equals(other.providerUserId) : sameProvider && other.providerUserId == null; } ConnectionKey(String providerId, String providerUserId); String getProviderId(); String getProviderUserId(); boolean equals(Object o); int hashCode(); String toString();  }### Answer:
@Test public void equals() { ConnectionKey key1 = new ConnectionKey("provider1", "providerUser1"); ConnectionKey key2 = new ConnectionKey("provider1", "providerUser1"); assertEquals(key1, key1); assertEquals(key1, key2); assertEquals(key2, key1); }
@Test public void equals_notEqual() { ConnectionKey key1 = new ConnectionKey("provider1", "providerUser1"); ConnectionKey key2 = new ConnectionKey("provider2", "providerUser1"); ConnectionKey key3 = new ConnectionKey("provider1", "providerUser2"); ConnectionKey key4 = new ConnectionKey("provider1", null); assertFalse(key1.equals(key2)); assertFalse(key2.equals(key1)); assertFalse(key1.equals(key3)); assertFalse(key3.equals(key1)); assertFalse(key2.equals(key3)); assertFalse(key3.equals(key2)); assertFalse(key1.equals(key4)); assertFalse(key4.equals(key1)); }