Search in sources :

Example 96 with MethodSource

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

the class IndexTxStateLookupTest method shouldRemoveDeletedNodeCreatedInSameTransactionFromIndexTxStateEvenWithMultipleProperties.

@ParameterizedTest(name = "store=<{0}> lookup=<{1}>")
@MethodSource("argumentsProvider")
void shouldRemoveDeletedNodeCreatedInSameTransactionFromIndexTxStateEvenWithMultipleProperties(Object store, Object lookup) {
    init(store, lookup);
    try (Transaction tx = db.beginTx()) {
        // given
        Label label = label("Node");
        String key = "prop";
        String key2 = "prop2";
        Node node = tx.createNode(label);
        node.setProperty(key, this.store);
        node.setProperty(key2, this.store);
        assertTrue(tx.findNodes(label, key, this.lookup).hasNext());
        // when
        node.delete();
        // then
        assertFalse(tx.findNodes(label, key, this.lookup).hasNext());
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) Label(org.neo4j.graphdb.Label) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 97 with MethodSource

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

the class IndexTxStateLookupTest method shouldRemoveDeletedRelationshipCreatedInSameTransactionFromIndexTxStateEvenWithMultipleProperties.

@ParameterizedTest(name = "store=<{0}> lookup=<{1}>")
@MethodSource("argumentsProvider")
void shouldRemoveDeletedRelationshipCreatedInSameTransactionFromIndexTxStateEvenWithMultipleProperties(Object store, Object lookup) {
    init(store, lookup);
    try (Transaction tx = db.beginTx()) {
        // given
        RelationshipType type = RelationshipType.withName("Rel");
        String key = "prop";
        String key2 = "prop2";
        Relationship relationship = tx.createNode().createRelationshipTo(tx.createNode(), type);
        relationship.setProperty(key, this.store);
        relationship.setProperty(key2, this.store);
        assertTrue(tx.findRelationships(type, key, this.lookup).hasNext());
        // when
        relationship.delete();
        // then
        assertFalse(tx.findRelationships(type, key, this.lookup).hasNext());
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Relationship(org.neo4j.graphdb.Relationship) RelationshipType(org.neo4j.graphdb.RelationshipType) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 98 with MethodSource

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

the class IndexTxStateLookupTest method lookupWithoutTransaction.

@ParameterizedTest(name = "store=<{0}> lookup=<{1}>")
@MethodSource("argumentsProvider")
public void lookupWithoutTransaction(Object store, Object lookup) {
    init(store, lookup);
    // when
    Node node;
    try (Transaction tx = db.beginTx()) {
        (node = tx.createNode(label("Node"))).setProperty("prop", this.store);
        tx.commit();
    }
    // then
    try (Transaction tx = db.beginTx()) {
        assertEquals(1, count(tx.findNodes(label("Node"), "prop", this.lookup)));
        tx.commit();
    }
    deleteNode(node);
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 99 with MethodSource

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

the class IndexTxStateLookupTest method lookupWithinTransaction.

@ParameterizedTest(name = "store=<{0}> lookup=<{1}>")
@MethodSource("argumentsProvider")
public void lookupWithinTransaction(Object store, Object lookup) {
    init(store, lookup);
    try (Transaction tx = db.beginTx()) {
        // when
        tx.createNode(label("Node")).setProperty("prop", this.store);
        // then
        assertEquals(1, count(tx.findNodes(label("Node"), "prop", this.lookup)));
    // no need to actually commit this node
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 100 with MethodSource

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

the class FulltextIndexSkipAndLimitTest method queryEntitiesMustApplySkip.

@MethodSource("entityTypeProvider")
@ParameterizedTest
void queryEntitiesMustApplySkip(EntityUtil entityUtil) {
    setUp(entityUtil);
    try (Transaction tx = db.beginTx();
        ResourceIterator<Entity> iterator = entityUtil.queryIndexWithOptions(tx, "zebra", "{skip:1}")) {
        assertThat(iterator.next().getId()).isEqualTo(middleEntity);
        assertThat(iterator.next().getId()).isEqualTo(bottomEntity);
        assertFalse(iterator.hasNext());
        tx.commit();
    }
}
Also used : Entity(org.neo4j.graphdb.Entity) Transaction(org.neo4j.graphdb.Transaction) MethodSource(org.junit.jupiter.params.provider.MethodSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

MethodSource (org.junit.jupiter.params.provider.MethodSource)1199 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1184 Transaction (org.neo4j.graphdb.Transaction)103 Stream (java.util.stream.Stream)70 Test (org.junit.jupiter.api.Test)67 ArrayList (java.util.ArrayList)63 InterruptAfter (io.aeron.test.InterruptAfter)60 List (java.util.List)60 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)58 TimeUnit (java.util.concurrent.TimeUnit)54 IOException (java.io.IOException)52 CountDownLatch (java.util.concurrent.CountDownLatch)52 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)52 lombok.val (lombok.val)52 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)51 Arguments (org.junit.jupiter.params.provider.Arguments)47 AfterEach (org.junit.jupiter.api.AfterEach)46 SSLEngine (javax.net.ssl.SSLEngine)44 AtomicReference (java.util.concurrent.atomic.AtomicReference)43 Path (java.nio.file.Path)42