### Question:
ProtectedMailboxStorageEntry extends ProtectedStorageEntry { @Override public boolean matchesRelevantPubKey(ProtectedStorageEntry protectedStorageEntry) { if (!(protectedStorageEntry instanceof ProtectedMailboxStorageEntry)) { log.error("ProtectedMailboxStorageEntry::isMetadataEquals() failed due to object type mismatch. " + "ProtectedMailboxStorageEntry required, but got\n" + protectedStorageEntry); return false; } ProtectedMailboxStorageEntry protectedMailboxStorageEntry = (ProtectedMailboxStorageEntry) protectedStorageEntry; boolean result = protectedMailboxStorageEntry.getReceiversPubKey().equals(this.receiversPubKey); if (!result) { log.warn("ProtectedMailboxStorageEntry::isMetadataEquals() failed due to metadata mismatch. " + "new.receiversPubKey=" + Utilities.bytesAsHexString(protectedMailboxStorageEntry.getReceiversPubKeyBytes()) + "stored.receiversPubKey=" + Utilities.bytesAsHexString(this.getReceiversPubKeyBytes())); } return result; } ProtectedMailboxStorageEntry(MailboxStoragePayload mailboxStoragePayload,
                                        PublicKey ownerPubKey,
                                        int sequenceNumber,
                                        byte[] signature,
                                        PublicKey receiversPubKey,
                                        Clock clock); private  ProtectedMailboxStorageEntry(MailboxStoragePayload mailboxStoragePayload,
                                        byte[] ownerPubKeyBytes,
                                        PublicKey ownerPubKey,
                                        int sequenceNumber,
                                        byte[] signature,
                                        byte[] receiversPubKeyBytes,
                                        PublicKey receiversPubKey,
                                        long creationTimeStamp,
                                        Clock clock); private  ProtectedMailboxStorageEntry(MailboxStoragePayload mailboxStoragePayload,
                                         byte[] ownerPubKeyBytes,
                                         int sequenceNumber,
                                         byte[] signature,
                                         byte[] receiversPubKeyBytes,
                                         long creationTimeStamp,
                                         Clock clock); MailboxStoragePayload getMailboxStoragePayload(); @Override boolean isValidForAddOperation(); @Override boolean isValidForRemoveOperation(); @Override /* * Returns true if the Entry metadata that is expected to stay constant between different versions of the same object * matches. For ProtectedMailboxStorageEntry, the receiversPubKey must stay the same. */ boolean matchesRelevantPubKey(ProtectedStorageEntry protectedStorageEntry); protobuf.ProtectedMailboxStorageEntry toProtoMessage(); static ProtectedMailboxStorageEntry fromProto(protobuf.ProtectedMailboxStorageEntry proto,
                                                         NetworkProtoResolver resolver); @Override String toString();  }### Answer:
@Test public void isMetadataEquals() throws NoSuchAlgorithmException, CryptoException { KeyPair senderKeys = TestUtils.generateKeyPair(); KeyPair receiverKeys = TestUtils.generateKeyPair(); MailboxStoragePayload mailboxStoragePayload = buildMailboxStoragePayload(senderKeys.getPublic(), receiverKeys.getPublic()); ProtectedStorageEntry seqNrOne = buildProtectedMailboxStorageEntry(mailboxStoragePayload, senderKeys, receiverKeys.getPublic(), 1); ProtectedStorageEntry seqNrTwo = buildProtectedMailboxStorageEntry(mailboxStoragePayload, senderKeys, receiverKeys.getPublic(), 2); Assert.assertTrue(seqNrOne.matchesRelevantPubKey(seqNrTwo)); }
@Test public void isMetadataEquals_receiverPubKeyChanged() throws NoSuchAlgorithmException, CryptoException { KeyPair senderKeys = TestUtils.generateKeyPair(); KeyPair receiverKeys = TestUtils.generateKeyPair(); MailboxStoragePayload mailboxStoragePayload = buildMailboxStoragePayload(senderKeys.getPublic(), receiverKeys.getPublic()); ProtectedStorageEntry seqNrOne = buildProtectedMailboxStorageEntry(mailboxStoragePayload, senderKeys, receiverKeys.getPublic(), 1); ProtectedStorageEntry seqNrTwo = buildProtectedMailboxStorageEntry(mailboxStoragePayload, senderKeys, senderKeys.getPublic(), 1); Assert.assertFalse(seqNrOne.matchesRelevantPubKey(seqNrTwo)); }