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();
}
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());
}
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));
}
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());
}
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());
}
Aggregations