Search in sources :

Example 21 with Theory

use of org.junit.experimental.theories.Theory in project neo4j by neo4j.

the class PrimitiveCollectionEqualityTest method addingTheSameValuesMustProduceEqualCollections.

@Theory
public void addingTheSameValuesMustProduceEqualCollections(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
    assumeTrue(values.isApplicable(factoryA));
    assumeTrue(values.isApplicable(factoryB));
    try (PrimitiveCollection a = factoryA.newInstance();
        PrimitiveCollection b = factoryB.newInstance()) {
        Value value = values.randomValue();
        value.add(a);
        value.add(b);
        assertEquals(a, b);
    }
}
Also used : PrimitiveCollection(org.neo4j.collection.primitive.PrimitiveCollection) Theory(org.junit.experimental.theories.Theory)

Example 22 with Theory

use of org.junit.experimental.theories.Theory in project neo4j by neo4j.

the class PrimitiveCollectionEqualityTest method capacityDifferencesMustNotInfluenceEquality.

@Theory
public void capacityDifferencesMustNotInfluenceEquality(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
    assumeTrue(values.isApplicable(factoryA));
    assumeTrue(values.isApplicable(factoryB));
    try (PrimitiveCollection a = factoryA.newInstance();
        PrimitiveCollection b = factoryB.newInstance()) {
        List<Value> tmps = new ArrayList<>();
        for (int i = 0; i < 5000; i++) {
            Value value = values.randomValue();
            value.add(b);
            tmps.add(value);
        }
        Value specificValue = values.randomValue();
        specificValue.add(a);
        specificValue.add(b);
        for (int i = 0; i < 5000; i++) {
            Value value = values.randomValue();
            value.add(b);
            tmps.add(value);
        }
        Collections.shuffle(tmps);
        for (Value value : tmps) {
            value.remove(b);
        }
        assertEquals(a, b);
    }
}
Also used : ArrayList(java.util.ArrayList) PrimitiveCollection(org.neo4j.collection.primitive.PrimitiveCollection) DataPoint(org.junit.experimental.theories.DataPoint) Theory(org.junit.experimental.theories.Theory)

Example 23 with Theory

use of org.junit.experimental.theories.Theory in project neo4j by neo4j.

the class PrimitiveCollectionEqualityTest method emptyCollectionsAreEqual.

@Theory
public void emptyCollectionsAreEqual(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
    assumeTrue(values.isApplicable(factoryA));
    assumeTrue(values.isApplicable(factoryB));
    try (PrimitiveCollection a = factoryA.newInstance();
        PrimitiveCollection b = factoryB.newInstance()) {
        assertEquals(a, b);
    }
}
Also used : PrimitiveCollection(org.neo4j.collection.primitive.PrimitiveCollection) Theory(org.junit.experimental.theories.Theory)

Example 24 with Theory

use of org.junit.experimental.theories.Theory in project neo4j by neo4j.

the class PrimitiveCollectionEqualityTest method differentButEquivalentMutationsShouldProduceEqualCollections.

@Theory
public void differentButEquivalentMutationsShouldProduceEqualCollections(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
    // Note that this test, cute as it is, also verifies that the hashCode implementation is order-invariant :)
    assumeTrue(values.isApplicable(factoryA));
    assumeTrue(values.isApplicable(factoryB));
    try (PrimitiveCollection a = factoryA.newInstance();
        PrimitiveCollection b = factoryB.newInstance()) {
        Value x = values.randomValue();
        Value y = values.randomValue();
        Value z = values.randomValue();
        x.add(a);
        z.add(a);
        z.add(b);
        y.add(b);
        x.add(b);
        y.remove(b);
        assertEquals(a, b);
    }
}
Also used : PrimitiveCollection(org.neo4j.collection.primitive.PrimitiveCollection) Theory(org.junit.experimental.theories.Theory)

Example 25 with Theory

use of org.junit.experimental.theories.Theory in project neo4j by neo4j.

the class LegacyIndexIT method shouldNotRejectIndexValueThatIsJustSmallerThanConfiguredSize.

@Theory
public void shouldNotRejectIndexValueThatIsJustSmallerThanConfiguredSize(String uniqueness) throws Exception {
    //Given
    server.start();
    // When
    String nodeURI = HTTP.POST(server.baseUri().toString() + "db/data/node").header("Location");
    Random r = new Random();
    String value = "";
    for (int i = 0; i < 4_000; i++) {
        value += (char) (r.nextInt(26) + 'a');
    }
    HTTP.Response response = HTTP.POST(server.baseUri().toString() + "db/data/index/node/favorites?uniqueness=" + uniqueness, quotedJson("{ 'value': '" + value + " ', 'uri':'" + nodeURI + "', 'key': 'some-key' }"));
    // Then
    assertThat(response.status(), is(201));
}
Also used : Random(java.util.Random) HTTP(org.neo4j.test.server.HTTP) Theory(org.junit.experimental.theories.Theory)

Aggregations

Theory (org.junit.experimental.theories.Theory)97 DataPoint (org.junit.experimental.theories.DataPoint)23 Test (org.junit.Test)22 Header (io.aeron.logbuffer.Header)15 DirectBuffer (org.agrona.DirectBuffer)15 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 DebugReceiveChannelEndpoint (io.aeron.driver.ext.DebugReceiveChannelEndpoint)11 DebugSendChannelEndpoint (io.aeron.driver.ext.DebugSendChannelEndpoint)11 UdpChannel (io.aeron.driver.media.UdpChannel)11 MediaDriver (io.aeron.driver.MediaDriver)8 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)7 LongAdder (java.util.concurrent.atomic.LongAdder)6 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)6 PrimitiveCollection (org.neo4j.collection.primitive.PrimitiveCollection)6 InOrder (org.mockito.InOrder)5 InputStream (java.io.InputStream)4 BaseStream (java.util.stream.BaseStream)4 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)4 Metric (org.springframework.boot.actuate.metrics.Metric)4 BufferClaim (io.aeron.logbuffer.BufferClaim)3