### Question:
PendingFederation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } PendingFederation otherFederation = (PendingFederation) other; ByteArrayWrapper[] thisPublicKeys = this.getPublicKeys().stream() .sorted(UldECKey.PUBKEY_COMPARATOR) .map(k -> new ByteArrayWrapper(k.getPubKey())) .toArray(ByteArrayWrapper[]::new); ByteArrayWrapper[] otherPublicKeys = otherFederation.getPublicKeys().stream() .sorted(UldECKey.PUBKEY_COMPARATOR) .map(k -> new ByteArrayWrapper(k.getPubKey())) .toArray(ByteArrayWrapper[]::new); return this.getPublicKeys().size() == otherFederation.getPublicKeys().size() && Arrays.equals(thisPublicKeys, otherPublicKeys); } PendingFederation(List<UldECKey> publicKeys); List<UldECKey> getPublicKeys(); boolean isComplete(); PendingFederation addPublicKey(UldECKey key); Federation buildFederation(Instant creationTime, long blockNumber, NetworkParameters uldParams); @Override String toString(); @Override boolean equals(Object other); Keccak256 getHash(); @Override int hashCode();  }### Answer:
@Test public void testEquals_a() { Assert.assertTrue(pendingFederation.equals(pendingFederation)); Assert.assertFalse(pendingFederation.equals(null)); Assert.assertFalse(pendingFederation.equals(new Object())); Assert.assertFalse(pendingFederation.equals("something else")); }
@Test public void testEquals_differentNumberOfPublicKeys() { PendingFederation otherPendingFederation = new PendingFederation( Arrays.asList(new UldECKey[]{ UldECKey.fromPrivate(BigInteger.valueOf(100)), UldECKey.fromPrivate(BigInteger.valueOf(200)), UldECKey.fromPrivate(BigInteger.valueOf(300)), UldECKey.fromPrivate(BigInteger.valueOf(400)), UldECKey.fromPrivate(BigInteger.valueOf(500)), UldECKey.fromPrivate(BigInteger.valueOf(600)), UldECKey.fromPrivate(BigInteger.valueOf(700)), }) ); Assert.assertFalse(pendingFederation.equals(otherPendingFederation)); }
@Test public void testEquals_differentPublicKeys() { PendingFederation otherPendingFederation = new PendingFederation( Arrays.asList(new UldECKey[]{ UldECKey.fromPrivate(BigInteger.valueOf(100)), UldECKey.fromPrivate(BigInteger.valueOf(200)), UldECKey.fromPrivate(BigInteger.valueOf(300)), UldECKey.fromPrivate(BigInteger.valueOf(400)), UldECKey.fromPrivate(BigInteger.valueOf(500)), UldECKey.fromPrivate(BigInteger.valueOf(610)), }) ); Assert.assertFalse(pendingFederation.equals(otherPendingFederation)); }
@Test public void testEquals_same() { PendingFederation otherPendingFederation = new PendingFederation( Arrays.asList(new UldECKey[]{ UldECKey.fromPrivate(BigInteger.valueOf(100)), UldECKey.fromPrivate(BigInteger.valueOf(200)), UldECKey.fromPrivate(BigInteger.valueOf(300)), UldECKey.fromPrivate(BigInteger.valueOf(400)), UldECKey.fromPrivate(BigInteger.valueOf(500)), UldECKey.fromPrivate(BigInteger.valueOf(600)), }) ); Assert.assertTrue(pendingFederation.equals(otherPendingFederation)); }