use of org.neo4j.driver.Transaction in project neo4j by neo4j.
the class CommunityEditionEndToEndTest method beforeEach.
@BeforeEach
void beforeEach() {
try (Transaction tx = driver.session().beginTransaction()) {
tx.run("MATCH (n) DETACH DELETE n");
tx.run("CREATE (:Person {name: 'Anna', uid: 0, age: 30})").consume();
tx.run("CREATE (:Person {name: 'Bob', uid: 1, age: 40})").consume();
tx.commit();
}
}
use of org.neo4j.driver.Transaction in project spring-boot by spring-projects.
the class Neo4jAutoConfigurationIntegrationTests method driverCanHandleRequest.
@Test
void driverCanHandleRequest() {
try (Session session = this.driver.session();
Transaction tx = session.beginTransaction()) {
Result statementResult = tx.run("MATCH (n:Thing) RETURN n LIMIT 1");
assertThat(statementResult.hasNext()).isFalse();
tx.commit();
}
}
use of org.neo4j.driver.Transaction in project neo4j by neo4j.
the class SnapshotExecutionTest method beforeEach.
@BeforeEach
void beforeEach() {
try (Transaction tx = driver.session().beginTransaction()) {
tx.run("MATCH (n) DETACH DELETE n");
tx.run("CREATE (:First {number: 0})").consume();
tx.run("CREATE (:Second {number: 0})").consume();
tx.commit();
}
}
use of org.neo4j.driver.Transaction in project neo4j by neo4j.
the class BoltStateHandlerTest method whenInTransactionHandlerLetsTransactionDoTheWork.
@Test
public void whenInTransactionHandlerLetsTransactionDoTheWork() throws CommandException {
Transaction transactionMock = mock(Transaction.class);
Session sessionMock = mock(Session.class);
when(sessionMock.beginTransaction()).thenReturn(transactionMock);
Driver driverMock = stubResultSummaryInAnOpenSession(mock(Result.class), sessionMock, "neo4j-version");
Result result = mock(Result.class);
when(transactionMock.run(any(Query.class))).thenReturn(result);
OfflineBoltStateHandler boltStateHandler = new OfflineBoltStateHandler(driverMock);
boltStateHandler.connect();
boltStateHandler.beginTransaction();
BoltResult boltResult = boltStateHandler.runCypher("UNWIND [1,2] as num RETURN *", Collections.emptyMap()).get();
assertEquals(result, boltResult.iterate());
boltStateHandler.commitTransaction();
assertFalse(boltStateHandler.isTransactionOpen());
}
Aggregations