### Question:
ArchiveIdentifierPattern extends ArchiveIdentifier { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (getClass() != obj.getClass()) { return false; } ArchiveIdentifierPattern other = (ArchiveIdentifierPattern) obj; return Objects.equals(pattern.pattern(), other.pattern.pattern()) && patternType == other.patternType; } ArchiveIdentifierPattern(final ArchiveType archiveType, final PatternType patternType, final String regex); final PatternType getPatternType(); final Pattern getPattern(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }### Answer:
@Test public void testEqualsSame() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final ArchiveIdentifierPattern ai2 = ai1; Assert.assertTrue("equals()", ai1.equals(ai2)); }
@Test public void testEqualsIdentical() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final ArchiveIdentifierPattern ai2 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); Assert.assertTrue("equals()", ai1.equals(ai2)); }
@Test public void testEqualsNull() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final ArchiveIdentifierPattern ai2 = null; Assert.assertFalse("equals()", ai1.equals(ai2)); }
@Test public void testEqualsObject() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final Object ai2 = new Object(); Assert.assertFalse("equals()", ai1.equals(ai2)); }
@Test public void testEqualsArchiveIdentifier() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final ArchiveIdentifier ai2 = new ArchiveIdentifier(ArchiveType.JAVA, NameMatchingType.PATTERN, "abc") { }; Assert.assertFalse("equals()", ai1.equals(ai2)); }
@Test public void testEqualsDifferentArchiveType() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final ArchiveIdentifierPattern ai2 = new ArchiveIdentifierPattern(ArchiveType.JAVASCRIPT, PatternType.PATTERN_ON_FILENAME, "abc"); Assert.assertFalse("equals()", ai1.equals(ai2)); }
@Test public void testEqualsDifferentPatternType() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final ArchiveIdentifierPattern ai2 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_PATH, "abc"); Assert.assertFalse("equals()", ai1.equals(ai2)); }
@Test public void testEqualsDifferentRegex() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final ArchiveIdentifierPattern ai2 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "def"); Assert.assertFalse("equals()", ai1.equals(ai2)); }
@Test public void testEqualsDifferentPatternTypeAndRegex() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final ArchiveIdentifierPattern ai2 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_PATH, "def"); Assert.assertFalse("equals()", ai1.equals(ai2)); }