EndpointListenerNotifier { private void notifyListener(EndpointEvent event, EndpointEventListener listener, Set<Filter> filters) { Set<Filter> matchingFilters = getMatchingFilters(filters, event.getEndpoint()); for (Filter filter : matchingFilters) { listener.endpointChanged(event, filter.toString()); } } EndpointListenerNotifier(); static Set<Filter> filtersFromEL(ServiceReference<EndpointListener> sref); static Set<Filter> filtersFromEEL(ServiceReference<EndpointEventListener> sref); void add(EndpointEventListener ep, Set<Filter> filters, Collection<EndpointDescription> endpoints); void remove(EndpointEventListener ep); void sendEvent(EndpointEvent event);  }
@Test public void testNotifyListener() throws InvalidSyntaxException { IMocksControl c = EasyMock.createControl(); EndpointEventListener epl = c.createMock(EndpointEventListener.class); Capture<EndpointEvent> capturedEvents = newCapture(CaptureType.ALL); Capture<String> capturedFilters = newCapture(CaptureType.ALL); epl.endpointChanged(capture(capturedEvents), capture(capturedFilters)); expectLastCall().anyTimes(); EndpointDescription endpoint1 = createEndpoint("myClass"); EndpointDescription endpoint2 = createEndpoint("notMyClass"); c.replay(); EndpointListenerNotifier notifier = new EndpointListenerNotifier(); Filter filter = FrameworkUtil.createFilter("(objectClass=myClass)"); notifier.add(epl, new HashSet(asList(filter)), Collections.emptyList()); notifier.sendEvent(new EndpointEvent(EndpointEvent.ADDED, endpoint1)); notifier.sendEvent(new EndpointEvent(EndpointEvent.ADDED, endpoint2)); notifier.sendEvent(new EndpointEvent(EndpointEvent.REMOVED, endpoint1)); notifier.sendEvent(new EndpointEvent(EndpointEvent.REMOVED, endpoint2)); c.verify(); List<EndpointEvent> expected = Arrays.asList( new EndpointEvent(EndpointEvent.ADDED, endpoint1), new EndpointEvent(EndpointEvent.REMOVED, endpoint1) ); MatcherAssert.assertThat(capturedEvents.getValues(), Matchers.sameBeanAs(expected)); }