use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class StreamingStateIT method shouldMoveFromStreamingStateToFailedStateOnPullAllOrDiscardAll_fail.
@ParameterizedTest
@MethodSource("pullAllDiscardAllMessages")
void shouldMoveFromStreamingStateToFailedStateOnPullAllOrDiscardAll_fail(RequestMessage message) throws Throwable {
// Given
BoltStateMachineV3 machine = getBoltStateMachineInStreamingState();
// When
BoltResponseHandler handler = mock(BoltResponseHandler.class);
doThrow(new RuntimeException("Fail")).when(handler).onPullRecords(any(), anyLong());
doThrow(new RuntimeException("Fail")).when(handler).onDiscardRecords(any(), anyLong());
machine.process(message, handler);
// Then
assertThat(machine.state()).isInstanceOf(FailedState.class);
}
use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class StreamingStateIT method getBoltStateMachineInStreamingState.
private BoltStateMachineV3 getBoltStateMachineInStreamingState() throws BoltConnectionFatality {
BoltStateMachineV3 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k", EMPTY_PARAMS), nullResponseHandler());
assertThat(machine.state()).isInstanceOf(StreamingState.class);
return machine;
}
use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class TransactionStreamingStateIT method getBoltStateMachineInTxStreamingState.
private BoltStateMachineV3 getBoltStateMachineInTxStreamingState() throws BoltConnectionFatality {
BoltStateMachineV3 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
machine.process(new BeginMessage(), nullResponseHandler());
assertThat(machine.state()).isInstanceOf(TransactionReadyState.class);
machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k"), nullResponseHandler());
// tx streaming state
assertThat(machine.state()).isInstanceOf(TransactionStreamingState.class);
return machine;
}
use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class TransactionStreamingStateIT method shouldMoveFromTxStreamingToTxReadyOnDiscardAll_succ.
@Test
void shouldMoveFromTxStreamingToTxReadyOnDiscardAll_succ() throws Throwable {
// Given
BoltStateMachineV3 machine = getBoltStateMachineInTxStreamingState();
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(DiscardAllMessage.INSTANCE, recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertThat(response).satisfies(succeeded());
assertFalse(response.hasMetadata("bookmark"));
assertThat(machine.state()).isInstanceOf(TransactionReadyState.class);
}
use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class TransactionStreamingStateIT method shouldThrowExceptionOnIllegalMessagesInTxStreamingState.
private void shouldThrowExceptionOnIllegalMessagesInTxStreamingState(RequestMessage message) throws Throwable {
// Given
BoltStateMachineV3 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
machine.process(new BeginMessage(), nullResponseHandler());
machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k"), nullResponseHandler());
assertThat(machine.state()).isInstanceOf(TransactionStreamingState.class);
// when
BoltResponseRecorder recorder = new BoltResponseRecorder();
verifyKillsConnection(() -> machine.process(message, recorder));
// then
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.Request.Invalid));
assertNull(machine.state());
}
Aggregations