InMemoryEntityFilter implements Predicate<ArchivedMessage> { @Override public boolean test(ArchivedMessage message) { EntityFilter.Type type = filter.type(); if (type == EntityFilter.Type.TO_AND_FROM) { return matchToAndFrom(message); } else if (type == EntityFilter.Type.TO_OR_FROM) { return matchToOrFrom(message); } else { throw new IllegalArgumentException("Unexpected entity filter type '" + type + "'"); } } InMemoryEntityFilter(EntityFilter filter); @Override boolean test(ArchivedMessage message);  }
@Test public void toAndFromIgnoringResource() { EntityFilter entityFilter = new SimpleEntityFilter(ROMEO_CAR, EntityFilter.Type.TO_AND_FROM, true); InMemoryEntityFilter tested = new InMemoryEntityFilter(entityFilter); assertTrue(tested.test(romeoSidewalkToRomeoCar)); assertFalse(tested.test(romeoSidewalkToJulietBalcony)); }
@Test public void toAndFromNotIgnoringResource() { EntityFilter entityFilter = new SimpleEntityFilter(ROMEO_CAR, EntityFilter.Type.TO_AND_FROM, false); InMemoryEntityFilter tested = new InMemoryEntityFilter(entityFilter); assertFalse(tested.test(romeoSidewalkToRomeoCar)); assertFalse(tested.test(romeoSidewalkToJulietBalcony)); }
@Test public void toOrFromIgnoringResource() { EntityFilter entityFilter = new SimpleEntityFilter(ROMEO_CAR, EntityFilter.Type.TO_OR_FROM, true); InMemoryEntityFilter tested = new InMemoryEntityFilter(entityFilter); assertTrue(tested.test(romeoSidewalkToRomeoCar)); assertTrue(tested.test(romeoSidewalkToJulietBalcony)); }
@Test public void toOrFromNotIgnoringResource() { EntityFilter entityFilter = new SimpleEntityFilter(ROMEO_CAR, EntityFilter.Type.TO_OR_FROM, false); InMemoryEntityFilter tested = new InMemoryEntityFilter(entityFilter); assertTrue(tested.test(romeoSidewalkToRomeoCar)); assertFalse(tested.test(romeoSidewalkToJulietBalcony)); }