use of org.apache.ignite.internal.metastorage.client.WatchEvent in project ignite-3 by apache.
the class WatchAggregatorTest method testCancelByFalseFromListener.
@Test
public void testCancelByFalseFromListener() {
var watchAggregator = new WatchAggregator();
var lsnr1 = mock(WatchListener.class);
when(lsnr1.onUpdate(any())).thenReturn(false);
var lsnr2 = mock(WatchListener.class);
when(lsnr2.onUpdate(any())).thenReturn(true);
var id1 = watchAggregator.add(new ByteArray("1"), lsnr1);
var id2 = watchAggregator.add(new ByteArray("2"), lsnr2);
var entryEvt1 = new EntryEvent(entry("1", "value1", 1, 1), entry("1", "value1n", 1, 1));
var entryEvt2 = new EntryEvent(entry("2", "value2", 1, 1), entry("2", "value2n", 1, 1));
watchAggregator.watch(1, (v1, v2) -> {
}).get().listener().onUpdate(new WatchEvent(List.of(entryEvt1, entryEvt2)));
verify(lsnr1, times(1)).onUpdate(any());
verify(lsnr2, times(1)).onUpdate(any());
watchAggregator.watch(1, (v1, v2) -> {
}).get().listener().onUpdate(new WatchEvent(List.of(entryEvt1, entryEvt2)));
verify(lsnr1, times(1)).onUpdate(any());
verify(lsnr2, times(2)).onUpdate(any());
}
Aggregations