Search in sources :

Example 21 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)

Example 22 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 23 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 24 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 25 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)

Aggregations

IntSupplier (java.util.function.IntSupplier)39 Test (org.junit.Test)13 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 UnitTest (org.apache.geode.test.junit.categories.UnitTest)6 IOException (java.io.IOException)5 ByteBuffer (java.nio.ByteBuffer)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 InetSocketAddress (java.net.InetSocketAddress)4 DatagramChannel (java.nio.channels.DatagramChannel)4 Selector (java.nio.channels.Selector)4 IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)3 SelectionKey (java.nio.channels.SelectionKey)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Supplier (java.util.function.Supplier)3 Collectors (java.util.stream.Collectors)3 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)2 ButtonID (de.mossgrabers.framework.controller.ButtonID)2 IHwLight (de.mossgrabers.framework.controller.hardware.IHwLight)2 WeakReference (java.lang.ref.WeakReference)2