use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class InTransactionStateIT method shouldMoveFromInTxToReadyOnRollback_succ.
@Test
void shouldMoveFromInTxToReadyOnRollback_succ() throws Throwable {
// Given
BoltStateMachineV4 machine = getBoltStateMachineInTxState();
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(ROLLBACK_MESSAGE, recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertThat(response).satisfies(succeeded());
assertFalse(response.hasMetadata("bookmark"));
assertFalse(response.hasMetadata("db"));
assertThat(machine.state()).isInstanceOf(ReadyState.class);
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class InTransactionStateIT method shouldStayInTxOnDiscard_succ_hasMore.
@Test
void shouldStayInTxOnDiscard_succ_hasMore() throws Throwable {
// Given
BoltStateMachineV4 machine = getBoltStateMachineInTxState("Unwind [1, 2, 3] as n return n");
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(newDiscardMessage(2), recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertThat(response).satisfies(containsNoRecord());
assertThat(response).satisfies(succeededWithMetadata("has_more", BooleanValue.TRUE));
assertFalse(response.hasMetadata("db"));
machine.process(newDiscardMessage(2), recorder);
response = recorder.nextResponse();
assertThat(response).satisfies(containsNoRecord());
assertTrue(response.hasMetadata("type"));
assertTrue(response.hasMetadata("t_last"));
assertFalse(response.hasMetadata("bookmark"));
assertTrue(response.hasMetadata("db"));
assertThat(response).satisfies(succeededWithoutMetadata("has_more"));
assertThat(machine.state()).isInstanceOf(InTransactionState.class);
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class InTransactionStateIT method shouldMoveFromInTxToFailedOnAnotherRun_fail.
@Test
void shouldMoveFromInTxToFailedOnAnotherRun_fail() throws Throwable {
// Given
BoltStateMachineV4 machine = getBoltStateMachineInTxState();
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(new RunMessage("any string"), recorder);
// Then
assertThat(machine.state()).isInstanceOf(FailedState.class);
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class InTransactionStateIT method shouldThrowExceptionOnIllegalMessagesInTxStreamingState.
private void shouldThrowExceptionOnIllegalMessagesInTxStreamingState(RequestMessage message) throws Throwable {
// Given
BoltStateMachineV4 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
machine.process(new BeginMessage(), nullResponseHandler());
machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k", EMPTY_PARAMS), nullResponseHandler());
assertThat(machine.state()).isInstanceOf(InTransactionState.class);
// when
BoltResponseRecorder recorder = new BoltResponseRecorder();
verifyKillsConnection(() -> machine.process(message, recorder));
// then
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.Request.Invalid));
assertNull(machine.state());
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class AutoCommitStateIT method getBoltStateMachineInAutoCommitState.
private BoltStateMachineV4 getBoltStateMachineInAutoCommitState(String query) throws BoltConnectionFatality {
BoltStateMachineV4 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
machine.process(new RunMessage(query, EMPTY_PARAMS), nullResponseHandler());
assertThat(machine.state()).isInstanceOf(AutoCommitState.class);
return machine;
}
Aggregations