use of org.apache.ignite.internal.metastorage.watch.WatchAggregator 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());
}
use of org.apache.ignite.internal.metastorage.watch.WatchAggregator in project ignite-3 by apache.
the class WatchAggregatorTest method testTwoEqualExactCriteriaUnion.
@Test
public void testTwoEqualExactCriteriaUnion() {
var watchAggregator = new WatchAggregator();
watchAggregator.add(new ByteArray("key1"), null);
watchAggregator.add(new ByteArray("key1"), null);
var keyCriterion = watchAggregator.watch(0, null).get().keyCriterion();
assertEquals(keyCriterion, keyCriterion);
}
use of org.apache.ignite.internal.metastorage.watch.WatchAggregator in project ignite-3 by apache.
the class WatchAggregatorTest method testNullKeyAsStartOfRangeCriterion.
@Test
public void testNullKeyAsStartOfRangeCriterion() {
var watchAggregator = new WatchAggregator();
watchAggregator.add(new ByteArray("key0"), null);
watchAggregator.add(null, new ByteArray("key2"), null);
var keyCriterion = watchAggregator.watch(0, null).get().keyCriterion();
var expKeyCriterion = new KeyCriterion.RangeCriterion(null, new ByteArray("key2"));
assertEquals(expKeyCriterion, keyCriterion);
}
Aggregations