use of org.apache.ignite.internal.metastorage.watch.WatchAggregator in project ignite-3 by apache.
the class WatchAggregatorTest method testTwoEqualCollectionCriteriaUnion.
@Test
public void testTwoEqualCollectionCriteriaUnion() {
var watchAggregator = new WatchAggregator();
watchAggregator.add(Arrays.asList(new ByteArray("key1"), new ByteArray("key2")), null);
watchAggregator.add(Arrays.asList(new ByteArray("key1"), new ByteArray("key2")), null);
var keyCriterion = watchAggregator.watch(0, null).get().keyCriterion();
var expKeyCriterion = new KeyCriterion.CollectionCriterion(new HashSet<>(Arrays.asList(new ByteArray("key1"), new ByteArray("key2"))));
assertEquals(expKeyCriterion, keyCriterion);
}
use of org.apache.ignite.internal.metastorage.watch.WatchAggregator in project ignite-3 by apache.
the class WatchAggregatorTest method testTwoExactCriteriaUnion.
@Test
public void testTwoExactCriteriaUnion() {
var watchAggregator = new WatchAggregator();
watchAggregator.add(new ByteArray("key1"), null);
watchAggregator.add(new ByteArray("key2"), null);
var keyCriterion = watchAggregator.watch(0, null).get().keyCriterion();
var expKeyCriterion = new KeyCriterion.CollectionCriterion(new HashSet<>(Arrays.asList(new ByteArray("key1"), new ByteArray("key2"))));
assertEquals(expKeyCriterion, keyCriterion);
}
use of org.apache.ignite.internal.metastorage.watch.WatchAggregator in project ignite-3 by apache.
the class WatchAggregatorTest method testEventsRouting.
@Test
public void testEventsRouting() {
var watchAggregator = new WatchAggregator();
var lsnr1 = mock(WatchListener.class);
var lsnr2 = mock(WatchListener.class);
watchAggregator.add(new ByteArray("1"), lsnr1);
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)));
var watchEvt1Res = ArgumentCaptor.forClass(WatchEvent.class);
verify(lsnr1).onUpdate(watchEvt1Res.capture());
assertEquals(List.of(entryEvt1), watchEvt1Res.getValue().entryEvents());
var watchEvt2Res = ArgumentCaptor.forClass(WatchEvent.class);
verify(lsnr2).onUpdate(watchEvt2Res.capture());
assertEquals(List.of(entryEvt2), watchEvt2Res.getValue().entryEvents());
}
use of org.apache.ignite.internal.metastorage.watch.WatchAggregator in project ignite-3 by apache.
the class WatchAggregatorTest method testHighExactAndLowerRangeCriteriaUnion.
@Test
public void testHighExactAndLowerRangeCriteriaUnion() {
var watchAggregator = new WatchAggregator();
watchAggregator.add(new ByteArray("key3"), 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("key4"));
assertEquals(expKeyCriterion, keyCriterion);
}
use of org.apache.ignite.internal.metastorage.watch.WatchAggregator in project ignite-3 by apache.
the class WatchAggregatorTest method testAllTypesOfCriteriaUnion.
@Test
public void testAllTypesOfCriteriaUnion() {
var watchAggregator = new WatchAggregator();
watchAggregator.add(new ByteArray("key0"), null);
watchAggregator.add(new ByteArray("key1"), new ByteArray("key2"), null);
watchAggregator.add(Arrays.asList(new ByteArray("key0"), new ByteArray("key3")), null);
var keyCriterion = watchAggregator.watch(0, null).get().keyCriterion();
var expKeyCriterion = new KeyCriterion.RangeCriterion(new ByteArray("key0"), new ByteArray("key4"));
assertEquals(expKeyCriterion, keyCriterion);
}
Aggregations