use of org.eclipse.smarthome.core.service.ReadyMarker in project smarthome by eclipse.
the class ReadyServiceImplTest method testTrackersAreInformedInitially.
@Test
public void testTrackersAreInformedInitially() {
ReadyTracker tracker = mock(ReadyTracker.class);
ReadyServiceImpl rs = new ReadyServiceImpl();
rs.markReady(new ReadyMarker("test", "id"));
rs.registerTracker(tracker);
verify(tracker).onReadyMarkerAdded(isA(ReadyMarker.class));
verifyNoMoreInteractions(tracker);
}
use of org.eclipse.smarthome.core.service.ReadyMarker in project smarthome by eclipse.
the class ReadyServiceImplTest method testTrackersAreInformedOnChange.
@Test
public void testTrackersAreInformedOnChange() {
ReadyTracker tracker = mock(ReadyTracker.class);
ReadyServiceImpl rs = new ReadyServiceImpl();
rs.registerTracker(tracker);
rs.markReady(new ReadyMarker("test", "id"));
verify(tracker).onReadyMarkerAdded(isA(ReadyMarker.class));
rs.unmarkReady(new ReadyMarker("test", "id"));
verify(tracker).onReadyMarkerRemoved(isA(ReadyMarker.class));
verifyNoMoreInteractions(tracker);
}
use of org.eclipse.smarthome.core.service.ReadyMarker in project smarthome by eclipse.
the class XmlDocumentBundleTracker method registerReadyMarker.
private void registerReadyMarker(Bundle bundle) {
String bsn = bundle.getSymbolicName();
if (!bundleReadyMarkerRegistrations.containsKey(bsn)) {
ReadyMarker readyMarker = new ReadyMarker(readyMarkerKey, bsn);
readyService.markReady(readyMarker);
bundleReadyMarkerRegistrations.put(bsn, readyMarker);
}
}
use of org.eclipse.smarthome.core.service.ReadyMarker in project smarthome by eclipse.
the class ReadyServiceImpl method notifyTracker.
private void notifyTracker(ReadyTracker readyTracker, Consumer<ReadyMarker> action) {
ReadyMarkerFilter f = trackers.get(readyTracker);
markers.stream().filter(marker -> f.apply(marker)).forEach(action);
}
use of org.eclipse.smarthome.core.service.ReadyMarker in project smarthome by eclipse.
the class ReadyServiceImplTest method testUnregisterTracker.
@Test
public void testUnregisterTracker() {
ReadyTracker tracker = mock(ReadyTracker.class);
ReadyServiceImpl rs = new ReadyServiceImpl();
rs.markReady(new ReadyMarker("foo", "id"));
rs.registerTracker(tracker, new ReadyMarkerFilter());
verify(tracker).onReadyMarkerAdded(isA(ReadyMarker.class));
rs.unregisterTracker(tracker);
verify(tracker).onReadyMarkerRemoved(isA(ReadyMarker.class));
verifyNoMoreInteractions(tracker);
}
Aggregations