Search in sources :

Example 11 with StatementProcessor

use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.

the class MutableConnectionStateTest method shouldSetAndGetStatementProcessor.

@Test
void shouldSetAndGetStatementProcessor() throws Throwable {
    StatementProcessor processor = mock(StatementProcessor.class);
    state.setStatementProcessor(processor);
    assertThat(state.getStatementProcessor()).isEqualTo(processor);
}
Also used : StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor) Test(org.junit.jupiter.api.Test)

Example 12 with StatementProcessor

use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.

the class ReadyState method processBeginMessage.

private BoltStateMachineState processBeginMessage(BeginMessage message, StateMachineContext context) throws Exception {
    StatementProcessor statementProcessor = getStatementProcessor(message, context);
    statementProcessor.beginTransaction(message.bookmarks(), message.transactionTimeout(), message.getAccessMode(), message.transactionMetadata());
    return txReadyState;
}
Also used : StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor)

Example 13 with StatementProcessor

use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.

the class BoltStateMachineContextImplTest method boltStateMachineContextWithStatementProcessor.

private static BoltStateMachineContextImpl boltStateMachineContextWithStatementProcessor(StatementProcessor txStateMachine, String databaseName) throws BoltProtocolBreachFatality, BoltIOException {
    StatementProcessorProvider provider = mock(StatementProcessorProvider.class);
    when(provider.getStatementProcessor(databaseName)).thenReturn(txStateMachine);
    when(txStateMachine.databaseName()).thenReturn(databaseName);
    BoltStateMachineContextImpl context = newContext(mock(BoltStateMachine.class), mock(BoltStateMachineSPI.class));
    context.setStatementProcessorProvider(provider);
    assertThat(context.connectionState().getStatementProcessor()).isEqualTo(EMPTY);
    StatementProcessor processor = context.setCurrentStatementProcessorForDatabase(databaseName);
    assertThat(processor).isEqualTo(txStateMachine);
    assertThat(context.connectionState().getStatementProcessor()).isEqualTo(txStateMachine);
    return context;
}
Also used : BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor) BoltStateMachineSPI(org.neo4j.bolt.runtime.statemachine.BoltStateMachineSPI)

Example 14 with StatementProcessor

use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.

the class BoltStateMachineContextImplTest method shouldReturnTheSameStatementProcessorIfDatabaseNameAreTheSame.

@Test
void shouldReturnTheSameStatementProcessorIfDatabaseNameAreTheSame() throws Throwable {
    // Given a context that has a active tx state machine set.
    StatementProcessor txStateMachine = mock(StatementProcessor.class);
    BoltStateMachineContextImpl context = boltStateMachineContextWithStatementProcessor(txStateMachine, DB_NAME);
    StatementProcessor molly = context.connectionState().getStatementProcessor();
    // When & Then
    StatementProcessor processor = context.setCurrentStatementProcessorForDatabase(DB_NAME);
    assertThat(processor).isEqualTo(molly);
}
Also used : StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor) Test(org.junit.jupiter.api.Test)

Example 15 with StatementProcessor

use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.

the class BoltStateMachineContextImplTest method releaseShouldResetStatementProcessorBackToEmpty.

@Test
void releaseShouldResetStatementProcessorBackToEmpty() throws Throwable {
    // Given a context that has a active tx state machine set.
    StatementProcessor txStateMachine = mock(StatementProcessor.class);
    BoltStateMachineContextImpl context = boltStateMachineContextWithStatementProcessor(txStateMachine, DB_NAME);
    // When
    context.releaseStatementProcessor();
    // Then
    assertThat(context.connectionState().getStatementProcessor()).isEqualTo(EMPTY);
}
Also used : StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor) Test(org.junit.jupiter.api.Test)

Aggregations

StatementProcessor (org.neo4j.bolt.runtime.statemachine.StatementProcessor)17 Test (org.junit.jupiter.api.Test)7 StatementMetadata (org.neo4j.bolt.runtime.statemachine.StatementMetadata)3 Bookmark (org.neo4j.bolt.runtime.Bookmark)2 BoltProtocolBreachFatality (org.neo4j.bolt.runtime.BoltProtocolBreachFatality)1 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)1 BoltStateMachineSPI (org.neo4j.bolt.runtime.statemachine.BoltStateMachineSPI)1 TransactionTerminatedException (org.neo4j.graphdb.TransactionTerminatedException)1