Search in sources :

Example 11 with IntSupplier

use of java.util.function.IntSupplier in project geode by apache.

the class StatisticsImplTest method invokeSuppliersShouldCatchSupplierErrorsAndReturnCount.

@Test
public void invokeSuppliersShouldCatchSupplierErrorsAndReturnCount() {
    IntSupplier supplier1 = mock(IntSupplier.class);
    when(supplier1.getAsInt()).thenThrow(NullPointerException.class);
    stats.setIntSupplier(4, supplier1);
    assertEquals(1, stats.invokeSuppliers());
    verify(supplier1).getAsInt();
}
Also used : IntSupplier(java.util.function.IntSupplier) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 12 with IntSupplier

use of java.util.function.IntSupplier in project geode by apache.

the class StatisticsImplTest method getSupplierCountShouldReturnCorrectCount.

@Test
public void getSupplierCountShouldReturnCorrectCount() {
    IntSupplier supplier1 = mock(IntSupplier.class);
    stats.setIntSupplier(4, supplier1);
    assertEquals(1, stats.getSupplierCount());
}
Also used : IntSupplier(java.util.function.IntSupplier) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 13 with IntSupplier

use of java.util.function.IntSupplier in project geode by apache.

the class StatisticsImplTest method invokeIntSuppliersShouldUpdateStats.

@Test
public void invokeIntSuppliersShouldUpdateStats() {
    IntSupplier supplier1 = mock(IntSupplier.class);
    when(supplier1.getAsInt()).thenReturn(23);
    stats.setIntSupplier(4, supplier1);
    assertEquals(0, stats.invokeSuppliers());
    verify(supplier1).getAsInt();
    assertEquals(23, stats.getInt(4));
}
Also used : IntSupplier(java.util.function.IntSupplier) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 14 with IntSupplier

use of java.util.function.IntSupplier in project geode by apache.

the class IndexRepositoryImplJUnitTest method addingDocumentsShouldUpdateDocumentsStat.

@Test
public void addingDocumentsShouldUpdateDocumentsStat() throws IOException {
    repo.create("key1", new Type2("bar", 1, 2L, 3.0, 4.0f, "Grape Ape doughnut"));
    repo.commit();
    ArgumentCaptor<IntSupplier> captor = ArgumentCaptor.forClass(IntSupplier.class);
    verify(stats).addDocumentsSupplier(captor.capture());
    IntSupplier supplier = captor.getValue();
    assertEquals(1, supplier.getAsInt());
}
Also used : Type2(org.apache.geode.cache.lucene.internal.repository.serializer.Type2) IntSupplier(java.util.function.IntSupplier) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 15 with IntSupplier

use of java.util.function.IntSupplier in project geode by apache.

the class LuceneIndexStatsJUnitTest method shouldPollSuppliersForDocumentStat.

@Test
public void shouldPollSuppliersForDocumentStat() {
    stats.addDocumentsSupplier(() -> 5);
    stats.addDocumentsSupplier(() -> 3);
    int documentsId = type.nameToId("documents");
    ArgumentCaptor<IntSupplier> documentsSupplierCaptor = ArgumentCaptor.forClass(IntSupplier.class);
    verify(statistics).setIntSupplier(eq(documentsId), documentsSupplierCaptor.capture());
    IntSupplier documentsSuppler = documentsSupplierCaptor.getValue();
    assertEquals(8, documentsSuppler.getAsInt());
}
Also used : IntSupplier(java.util.function.IntSupplier) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

IntSupplier (java.util.function.IntSupplier)15 Test (org.junit.Test)7 UnitTest (org.apache.geode.test.junit.categories.UnitTest)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 IOException (java.io.IOException)2 InetSocketAddress (java.net.InetSocketAddress)2 ByteBuffer (java.nio.ByteBuffer)2 DatagramChannel (java.nio.channels.DatagramChannel)2 SelectionKey (java.nio.channels.SelectionKey)2 Selector (java.nio.channels.Selector)2 Async (br.com.brjdevs.java.utils.async.Async)1 CollectionUtils.random (br.com.brjdevs.java.utils.collections.CollectionUtils.random)1 Interpreter (bsh.Interpreter)1 Color (java.awt.Color)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ResultSet (java.sql.ResultSet)1 ResultSetMetaData (java.sql.ResultSetMetaData)1 SQLException (java.sql.SQLException)1 Duration (java.time.Duration)1