### Question:
PushMechanism extends Mechanism { public static PushBuilder builder() { return new PushBuilder(); } private  PushMechanism(String mechanismUID, String issuer, String accountName, String type, String secret,
                          String registrationEndpoint, String authenticationEndpoint, Calendar timeCreated); List<PushNotification> getAllNotifications(); List<PushNotification> getPendingNotifications(); @Override String toJson(); static PushBuilder builder();  }### Answer:
@Test public void testShouldEqualEquivalentPushMechanism() { Mechanism mechanism1 = PushMechanism.builder() .setMechanismUID(MECHANISM_UID) .setIssuer(ISSUER) .setAccountName(ACCOUNT_NAME) .setAuthenticationEndpoint(AUTHENTICATION_ENDPOINT) .setRegistrationEndpoint(REGISTRATION_ENDPOINT) .setSecret(SECRET) .build(); Mechanism mechanism2 = PushMechanism.builder() .setMechanismUID(MECHANISM_UID) .setIssuer(ISSUER) .setAccountName(ACCOUNT_NAME) .setAuthenticationEndpoint(AUTHENTICATION_ENDPOINT) .setRegistrationEndpoint(REGISTRATION_ENDPOINT) .setSecret(SECRET) .build(); assertEquals(mechanism1, mechanism2); assertTrue(mechanism1.matches(mechanism2)); assertEquals(mechanism1.hashCode(), mechanism2.hashCode()); }
@Test public void testShouldNotEqualDifferentPushMechanismWithAccountName() { Mechanism mechanism1 = PushMechanism.builder() .setMechanismUID(MECHANISM_UID) .setIssuer(ISSUER) .setAccountName(ACCOUNT_NAME) .setAuthenticationEndpoint(AUTHENTICATION_ENDPOINT) .setRegistrationEndpoint(REGISTRATION_ENDPOINT) .setSecret(SECRET) .build(); Mechanism mechanism2 = PushMechanism.builder() .setMechanismUID(MECHANISM_UID) .setIssuer(ISSUER) .setAccountName(OTHER_ACCOUNT_NAME) .setAuthenticationEndpoint(AUTHENTICATION_ENDPOINT) .setRegistrationEndpoint(REGISTRATION_ENDPOINT) .setSecret(SECRET) .build(); assertFalse(mechanism1.equals(mechanism2)); assertFalse(mechanism1.matches(mechanism2)); }
@Test public void testShouldNotEqualDifferentPushMechanismWithAccountIssuer() { Mechanism mechanism1 = PushMechanism.builder() .setMechanismUID(MECHANISM_UID) .setIssuer(ISSUER) .setAccountName(ACCOUNT_NAME) .setAuthenticationEndpoint(AUTHENTICATION_ENDPOINT) .setRegistrationEndpoint(REGISTRATION_ENDPOINT) .setSecret(SECRET) .build(); Mechanism mechanism2 = PushMechanism.builder() .setMechanismUID(MECHANISM_UID) .setIssuer(OTHER_ISSUER) .setAccountName(ACCOUNT_NAME) .setAuthenticationEndpoint(OTHER_AUTHENTICATION_ENDPOINT) .setRegistrationEndpoint(OTHER_REGISTRATION_ENDPOINT) .setSecret(SECRET) .build(); assertFalse(mechanism1.equals(mechanism2)); assertFalse(mechanism1.matches(mechanism2)); }