### Question:
FromMatchesFilter extends AbstractFromToMatchesFilter { public static FromMatchesFilter createBare(Jid address) { return new FromMatchesFilter(address, true); } FromMatchesFilter(Jid address, boolean ignoreResourcepart); static FromMatchesFilter create(Jid address); static FromMatchesFilter createBare(Jid address); static FromMatchesFilter createFull(Jid address); static final FromMatchesFilter MATCH_NO_FROM_SET; }### Answer:
@Test public void bareCompareMatchingEntityFullJid() { FromMatchesFilter filter = FromMatchesFilter.createBare(FULL_JID1_R1); Stanza packet = StanzaBuilder.buildMessage().build(); packet.setFrom(BASE_JID1); assertTrue(filter.accept(packet)); packet.setFrom(FULL_JID1_R1); assertTrue(filter.accept(packet)); packet.setFrom(FULL_JID1_R2); assertTrue(filter.accept(packet)); packet.setFrom(BASE_JID2); assertFalse(filter.accept(packet)); packet.setFrom(FULL_JID2); assertFalse(filter.accept(packet)); packet.setFrom(BASE_JID3); assertFalse(filter.accept(packet)); }
@Test public void bareCompareMatchingBaseJid() { FromMatchesFilter filter = FromMatchesFilter.createBare(BASE_JID1); Stanza packet = StanzaBuilder.buildMessage().build(); packet.setFrom(BASE_JID1); assertTrue(filter.accept(packet)); packet.setFrom(FULL_JID1_R1); assertTrue(filter.accept(packet)); packet.setFrom(FULL_JID1_R2); assertTrue(filter.accept(packet)); packet.setFrom(BASE_JID2); assertFalse(filter.accept(packet)); packet.setFrom(FULL_JID2); assertFalse(filter.accept(packet)); packet.setFrom(BASE_JID3); assertFalse(filter.accept(packet)); }
@Test public void bareCompareMatchingServiceJid() { FromMatchesFilter filter = FromMatchesFilter.createBare(SERVICE_JID1); Stanza packet = StanzaBuilder.buildMessage().build(); packet.setFrom(SERVICE_JID1); assertTrue(filter.accept(packet)); packet.setFrom(SERVICE_JID2); assertFalse(filter.accept(packet)); packet.setFrom(BASE_JID1); assertFalse(filter.accept(packet)); packet.setFrom(FULL_JID1_R1); assertFalse(filter.accept(packet)); packet.setFrom(BASE_JID3); assertFalse(filter.accept(packet)); }