Search in sources :

Example 6 with IntPredicate

use of java.util.function.IntPredicate in project j2objc by google.

the class IntPredicateTest method testOr_null.

public void testOr_null() throws Exception {
    IntPredicate alwaysTrue = x -> true;
    try {
        alwaysTrue.or(null);
        fail();
    } catch (NullPointerException expected) {
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestCase(junit.framework.TestCase) IntPredicate(java.util.function.IntPredicate) IntPredicate(java.util.function.IntPredicate)

Example 7 with IntPredicate

use of java.util.function.IntPredicate in project j2objc by google.

the class IntPredicateTest method testOr.

public void testOr() throws Exception {
    int arg = 5;
    AtomicBoolean alwaysTrueInvoked = new AtomicBoolean(false);
    AtomicBoolean alwaysTrue2Invoked = new AtomicBoolean(false);
    AtomicBoolean alwaysFalseInvoked = new AtomicBoolean(false);
    AtomicBoolean alwaysFalse2Invoked = new AtomicBoolean(false);
    AtomicBoolean[] invocationState = { alwaysTrueInvoked, alwaysTrue2Invoked, alwaysFalseInvoked, alwaysFalse2Invoked };
    IntPredicate alwaysTrue = x -> {
        alwaysTrueInvoked.set(true);
        assertEquals(x, arg);
        return true;
    };
    IntPredicate alwaysTrue2 = x -> {
        alwaysTrue2Invoked.set(true);
        assertEquals(x, arg);
        return true;
    };
    IntPredicate alwaysFalse = x -> {
        alwaysFalseInvoked.set(true);
        assertEquals(x, arg);
        return false;
    };
    IntPredicate alwaysFalse2 = x -> {
        alwaysFalse2Invoked.set(true);
        assertEquals(x, arg);
        return false;
    };
    // true || true
    resetToFalse(invocationState);
    assertTrue(alwaysTrue.or(alwaysTrue2).test(arg));
    assertTrue(alwaysTrueInvoked.get() && !alwaysTrue2Invoked.get());
    // true || false
    resetToFalse(invocationState);
    assertTrue(alwaysTrue.or(alwaysFalse).test(arg));
    assertTrue(alwaysTrueInvoked.get() && !alwaysFalseInvoked.get());
    // false || false
    resetToFalse(invocationState);
    assertFalse(alwaysFalse.or(alwaysFalse2).test(arg));
    assertTrue(alwaysFalseInvoked.get() && alwaysFalse2Invoked.get());
    // false || true
    resetToFalse(invocationState);
    assertTrue(alwaysFalse.or(alwaysTrue).test(arg));
    assertTrue(alwaysFalseInvoked.get() && alwaysTrueInvoked.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestCase(junit.framework.TestCase) IntPredicate(java.util.function.IntPredicate) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IntPredicate(java.util.function.IntPredicate)

Example 8 with IntPredicate

use of java.util.function.IntPredicate in project torodb by torodb.

the class SmartRetrierTest method setUp.

@Before
public void setUp() {
    IntPredicate predicate = i -> i >= MAX_EXECUTIONS;
    retrier = new SmartRetrier(predicate, predicate, predicate, predicate, (i, millis) -> 2 * millis);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.Test) Assert(org.junit.Assert) IntPredicate(java.util.function.IntPredicate) Assert.assertEquals(org.junit.Assert.assertEquals) RollbackException(com.torodb.core.transaction.RollbackException) Before(org.junit.Before) IntPredicate(java.util.function.IntPredicate) Before(org.junit.Before)

Example 9 with IntPredicate

use of java.util.function.IntPredicate in project neo4j by neo4j.

the class MultipleIndexPopulator method indexAllNodes.

public StoreScan<IndexPopulationFailedKernelException> indexAllNodes() {
    int[] labelIds = labelIds();
    int[] propertyKeyIds = propertyKeyIds();
    IntPredicate propertyKeyIdFilter = (propertyKeyId) -> contains(propertyKeyIds, propertyKeyId);
    storeScan = storeView.visitNodes(labelIds, propertyKeyIdFilter, new NodePopulationVisitor(), null, false);
    storeScan.configure(populations);
    return storeScan;
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) IndexSample(org.neo4j.storageengine.api.schema.IndexSample) Log(org.neo4j.logging.Log) PrimitiveIntCollections.contains(org.neo4j.collection.primitive.PrimitiveIntCollections.contains) LabelSchemaDescriptor(org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor) IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) LogProvider(org.neo4j.logging.LogProvider) HashMap(java.util.HashMap) IntPredicate(java.util.function.IntPredicate) Pair(org.neo4j.helpers.collection.Pair) IndexEntryConflictException(org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) IndexPopulationFailedKernelException(org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) Map(java.util.Map) FeatureToggles(org.neo4j.unsafe.impl.internal.dragons.FeatureToggles) ThrowingConsumer(org.neo4j.function.ThrowingConsumer) IndexPopulationFailure.failure(org.neo4j.kernel.impl.api.index.IndexPopulationFailure.failure) NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) Collection(java.util.Collection) FlipFailedKernelException(org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException) IndexEntryUpdate(org.neo4j.kernel.api.index.IndexEntryUpdate) IOException(java.io.IOException) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) PropertyAccessor(org.neo4j.kernel.api.index.PropertyAccessor) String.format(java.lang.String.format) List(java.util.List) PrimitiveLongSet(org.neo4j.collection.primitive.PrimitiveLongSet) Descriptor(org.neo4j.kernel.api.index.SchemaIndexProvider.Descriptor) Optional(java.util.Optional) Queue(java.util.Queue) Visitor(org.neo4j.helpers.collection.Visitor) Collections(java.util.Collections) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) IntPredicate(java.util.function.IntPredicate)

Example 10 with IntPredicate

use of java.util.function.IntPredicate in project jdk8u_jdk by JetBrains.

the class MatchOpTest method testIntStream.

@Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class)
public void testIntStream(String name, TestData.OfInt data) {
    for (IntPredicate p : INT_PREDICATES) {
        setContext("p", p);
        for (Kind kind : Kind.values()) {
            setContext("kind", kind);
            exerciseTerminalOps(data, intKinds.get(kind).apply(p));
            exerciseTerminalOps(data, s -> s.filter(ipFalse), intKinds.get(kind).apply(p));
            exerciseTerminalOps(data, s -> s.filter(ipEven), intKinds.get(kind).apply(p));
        }
    }
}
Also used : IntPredicate(java.util.function.IntPredicate) Test(org.testng.annotations.Test)

Aggregations

IntPredicate (java.util.function.IntPredicate)13 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 TestCase (junit.framework.TestCase)5 Test (org.testng.annotations.Test)3 List (java.util.List)2 IntStream (java.util.stream.IntStream)2 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)2 RollbackException (com.torodb.core.transaction.RollbackException)1 Input (io.engineblock.activityapi.input.Input)1 Output (io.engineblock.activityapi.output.Output)1 IOException (java.io.IOException)1 Math.exp (java.lang.Math.exp)1 Math.log10 (java.lang.Math.log10)1 String.format (java.lang.String.format)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1