use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class ReadyStateIT method shouldMoveToInTransactionOnBegin_succ.
@Test
void shouldMoveToInTransactionOnBegin_succ() throws Throwable {
// Given
BoltStateMachineV4 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(new BeginMessage(), recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertThat(response).satisfies(succeeded());
assertThat(machine.state()).isInstanceOf(InTransactionState.class);
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class ReadyStateIT method shouldMoveToFailedStateOnBegin_fail.
@Test
void shouldMoveToFailedStateOnBegin_fail() throws Throwable {
// Given
BoltStateMachineV4 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
BeginMessage beginMessage = mock(BeginMessage.class);
when(beginMessage.databaseName()).thenReturn(ABSENT_DB_NAME);
when(beginMessage.bookmarks()).thenThrow(new RuntimeException("Fail"));
machine.process(beginMessage, recorder);
// Then
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.General.UnknownError));
assertThat(machine.state()).isInstanceOf(FailedState.class);
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class ReadyStateIT method shouldMoveToInterruptedOnInterrupt.
@Test
void shouldMoveToInterruptedOnInterrupt() throws Throwable {
// Given
BoltStateMachineV4 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(InterruptSignal.INSTANCE, recorder);
// Then
assertThat(machine.state()).isInstanceOf(InterruptedState.class);
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class InTransactionStateIT method shouldMoveFromInTxToReadyOnCommit_succ.
@Test
void shouldMoveFromInTxToReadyOnCommit_succ() throws Throwable {
// Given
BoltStateMachineV4 machine = getBoltStateMachineInTxState();
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(COMMIT_MESSAGE, recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertThat(response).satisfies(succeeded());
assertTrue(response.hasMetadata("bookmark"));
assertThat(machine.state()).isInstanceOf(ReadyState.class);
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class InTransactionStateIT method shouldStayInTxOnDiscard_succ.
@Test
void shouldStayInTxOnDiscard_succ() throws Throwable {
// Given
BoltStateMachineV4 machine = getBoltStateMachineInTxState();
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(newDiscardMessage(100L), recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertThat(response).satisfies(succeeded());
assertFalse(response.hasMetadata("bookmark"));
assertTrue(response.hasMetadata("db"));
assertThat(machine.state()).isInstanceOf(InTransactionState.class);
}
Aggregations