Search in sources :

Example 16 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.

the class IndexTransactionStateTestBase method shouldPerformStringSuffixSearch.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformStringSuffixSearch(boolean needsValues) throws Exception {
    // given
    Set<Pair<Long, Value>> expected = new HashSet<>();
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "1suff"));
        entityWithProp(tx, "pluff");
        tx.commit();
    }
    createIndex();
    // when
    try (KernelTransaction tx = beginTransaction()) {
        int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
        expected.add(entityWithProp(tx, "2suff"));
        entityWithPropId(tx, "skruff");
        IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_NAME);
        assertEntityAndValueForSeek(expected, tx, index, needsValues, "pasuff", PropertyIndexQuery.stringSuffix(prop, stringValue("suff")));
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Pair(org.neo4j.internal.helpers.collection.Pair) HashSet(java.util.HashSet) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.

the class IndexTransactionStateTestBase method shouldPerformStringContainsSearch.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformStringContainsSearch(boolean needsValues) throws Exception {
    // given
    Set<Pair<Long, Value>> expected = new HashSet<>();
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "gnomebat"));
        entityWithPropId(tx, "fishwombat");
        tx.commit();
    }
    createIndex();
    // when
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "homeopatic"));
        entityWithPropId(tx, "telephonecompany");
        IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_NAME);
        int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
        assertEntityAndValueForSeek(expected, tx, index, needsValues, "immense", PropertyIndexQuery.stringContains(prop, stringValue("me")));
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Pair(org.neo4j.internal.helpers.collection.Pair) HashSet(java.util.HashSet) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.

the class DuplicatingLogTest method shouldOutputToMultipleLogs.

@ParameterizedTest
@ValueSource(strings = { "debug", "info", "warn", "error" })
void shouldOutputToMultipleLogs(String type) throws Exception {
    // Given
    DuplicatingLog log = new DuplicatingLog(log1, log2);
    Method m = Log.class.getMethod(type, String.class);
    // When
    m.invoke(log, "When the going gets weird");
    // Then
    m.invoke(verify(log1), "When the going gets weird");
    m.invoke(verify(log2), "When the going gets weird");
    verifyNoMoreInteractions(log1);
    verifyNoMoreInteractions(log2);
}
Also used : Method(java.lang.reflect.Method) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 19 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.

the class LatchMapTest method takeOrAwaitLatchMustAwaitExistingLatchAndReturnNull.

@ValueSource(ints = { LatchMap.DEFAULT_FAULT_LOCK_STRIPING, 1 << 10, 1 << 11 })
@ParameterizedTest
void takeOrAwaitLatchMustAwaitExistingLatchAndReturnNull(int size) throws Exception {
    LatchMap latches = new LatchMap(size);
    AtomicReference<Thread> threadRef = new AtomicReference<>();
    BinaryLatch latch = latches.takeOrAwaitLatch(42);
    assertThat(latch).isNotNull();
    ExecutorService executor = null;
    try {
        executor = Executors.newSingleThreadExecutor();
        Future<BinaryLatch> future = executor.submit(() -> {
            threadRef.set(Thread.currentThread());
            return latches.takeOrAwaitLatch(42);
        });
        Thread th;
        do {
            th = threadRef.get();
        } while (th == null);
        ThreadTestUtils.awaitThreadState(th, 10_000, Thread.State.WAITING);
        latch.release();
        assertThat(future.get(1, TimeUnit.SECONDS)).isNull();
    } finally {
        if (executor != null) {
            executor.shutdown();
        }
    }
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) AtomicReference(java.util.concurrent.atomic.AtomicReference) BinaryLatch(org.neo4j.util.concurrent.BinaryLatch) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 20 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.

the class LatchMapTest method takeOrAwaitLatchMustReturnLatchIfAvailable.

@ValueSource(ints = { LatchMap.DEFAULT_FAULT_LOCK_STRIPING, 1 << 10, 1 << 11 })
@ParameterizedTest
void takeOrAwaitLatchMustReturnLatchIfAvailable(int size) {
    LatchMap latches = new LatchMap(size);
    BinaryLatch latch = latches.takeOrAwaitLatch(0);
    assertThat(latch).isNotNull();
    latch.release();
}
Also used : BinaryLatch(org.neo4j.util.concurrent.BinaryLatch) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)266 ValueSource (org.junit.jupiter.params.provider.ValueSource)266 HashSet (java.util.HashSet)23 HistogramTestUtils.constructDoubleHistogram (org.HdrHistogram.HistogramTestUtils.constructDoubleHistogram)23 ArrayList (java.util.ArrayList)22 HashMap (java.util.HashMap)20 ApiResponse (org.hisp.dhis.dto.ApiResponse)15 UpdateModel (com.synopsys.integration.alert.update.model.UpdateModel)13 File (java.io.File)13 List (java.util.List)13 OffsetDateTime (java.time.OffsetDateTime)10 Map (java.util.Map)10 TimeUnit (java.util.concurrent.TimeUnit)10 TopicPartition (org.apache.kafka.common.TopicPartition)9 ListenerSubscribeMessage (io.nem.symbol.sdk.infrastructure.ListenerSubscribeMessage)8 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)8 ZooKeeper (org.apache.zookeeper.ZooKeeper)8 JsonObject (com.google.gson.JsonObject)7 IOException (java.io.IOException)7 CountDownLatch (java.util.concurrent.CountDownLatch)7