use of org.apache.ignite.lang.ByteArray in project ignite-3 by apache.
the class WatchAggregatorTest method testOneCriterionInference.
@Test
public void testOneCriterionInference() {
var watchAggregator = new WatchAggregator();
watchAggregator.add(new ByteArray("key"), null);
var keyCriterion = watchAggregator.watch(0, null).get().keyCriterion();
assertEquals(new KeyCriterion.ExactCriterion(new ByteArray("key")), keyCriterion);
}
use of org.apache.ignite.lang.ByteArray in project ignite-3 by apache.
the class WatchAggregatorTest method testCancel.
@Test
public void testCancel() {
var watchAggregator = new WatchAggregator();
var lsnr1 = mock(WatchListener.class);
when(lsnr1.onUpdate(any())).thenReturn(true);
var lsnr2 = mock(WatchListener.class);
when(lsnr2.onUpdate(any())).thenReturn(true);
final 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.cancel(id1);
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.lang.ByteArray in project ignite-3 by apache.
the class WatchAggregatorTest method testNullKeyAsEndOfRangeCriterion.
@Test
public void testNullKeyAsEndOfRangeCriterion() {
var watchAggregator = new WatchAggregator();
watchAggregator.add(new ByteArray("key3"), null);
watchAggregator.add(new ByteArray("key1"), null, null);
var keyCriterion = watchAggregator.watch(0, null).get().keyCriterion();
var expKeyCriterion = new KeyCriterion.RangeCriterion(new ByteArray("key1"), null);
assertEquals(expKeyCriterion, keyCriterion);
}
use of org.apache.ignite.lang.ByteArray in project ignite-3 by apache.
the class WatchAggregatorTest method testExactInTheMiddleAndRangeCriteriaOnTheEdgesUnion.
@Test
public void testExactInTheMiddleAndRangeCriteriaOnTheEdgesUnion() {
var watchAggregator = new WatchAggregator();
watchAggregator.add(new ByteArray("key1"), null);
watchAggregator.add(new ByteArray("key0"), new ByteArray("key2"), null);
var keyCriterion = watchAggregator.watch(0, null).get().keyCriterion();
var expKeyCriterion = new KeyCriterion.RangeCriterion(new ByteArray("key0"), new ByteArray("key2"));
assertEquals(expKeyCriterion, keyCriterion);
}
use of org.apache.ignite.lang.ByteArray 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