Search in sources :

Example 1 with StartsWithStringFilter

use of com.hazelcast.client.test.ringbuffer.filter.StartsWithStringFilter in project hazelcast by hazelcast.

the class RingbufferTest method readManyAsync_withFilter.

@Test
public void readManyAsync_withFilter() throws Exception {
    serverRingbuffer.add("good1");
    serverRingbuffer.add("bad1");
    serverRingbuffer.add("good2");
    serverRingbuffer.add("bad2");
    serverRingbuffer.add("good3");
    serverRingbuffer.add("bad3");
    Future<ReadResultSet<String>> f = clientRingbuffer.readManyAsync(0, 3, 3, new StartsWithStringFilter("good")).toCompletableFuture();
    ReadResultSet rs = f.get();
    assertInstanceOf(ReadResultSetImpl.class, rs);
    assertEquals(5, rs.readCount());
    assertEquals("good1", rs.get(0));
    assertEquals("good2", rs.get(1));
    assertEquals("good3", rs.get(2));
}
Also used : StartsWithStringFilter(com.hazelcast.client.test.ringbuffer.filter.StartsWithStringFilter) ReadResultSet(com.hazelcast.ringbuffer.ReadResultSet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with StartsWithStringFilter

use of com.hazelcast.client.test.ringbuffer.filter.StartsWithStringFilter in project hazelcast by hazelcast.

the class RingbufferTest method readManyAsync_withFilter_andMaxCount.

// checks if the max count works in combination with a filter.
// So if more results are available than needed, the surplus results should not be read.
@Test
public void readManyAsync_withFilter_andMaxCount() throws Exception {
    serverRingbuffer.add("good1");
    serverRingbuffer.add("bad1");
    serverRingbuffer.add("good2");
    serverRingbuffer.add("bad2");
    serverRingbuffer.add("good3");
    serverRingbuffer.add("bad3");
    serverRingbuffer.add("good4");
    serverRingbuffer.add("bad4");
    Future<ReadResultSet<String>> f = clientRingbuffer.readManyAsync(0, 3, 3, new StartsWithStringFilter("good")).toCompletableFuture();
    ReadResultSet rs = f.get();
    assertInstanceOf(ReadResultSetImpl.class, rs);
    assertEquals(5, rs.readCount());
    assertEquals("good1", rs.get(0));
    assertEquals("good2", rs.get(1));
    assertEquals("good3", rs.get(2));
}
Also used : StartsWithStringFilter(com.hazelcast.client.test.ringbuffer.filter.StartsWithStringFilter) ReadResultSet(com.hazelcast.ringbuffer.ReadResultSet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

StartsWithStringFilter (com.hazelcast.client.test.ringbuffer.filter.StartsWithStringFilter)2 ReadResultSet (com.hazelcast.ringbuffer.ReadResultSet)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2