use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class InTransactionStateIT method shouldStayInTxOnPull_succ.
@Test
void shouldStayInTxOnPull_succ() throws Throwable {
// Given
BoltStateMachineV4 machine = getBoltStateMachineInTxState();
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(newPullMessage(100), recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertThat(response).satisfies(succeeded());
assertTrue(response.hasMetadata("type"));
assertTrue(response.hasMetadata("t_last"));
assertFalse(response.hasMetadata("bookmark"));
assertTrue(response.hasMetadata("db"));
assertThat(machine.state()).isInstanceOf(InTransactionState.class);
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class InTransactionStateIT method shouldMoveFromInTxToInterruptedOnInterrupt.
@Test
void shouldMoveFromInTxToInterruptedOnInterrupt() throws Throwable {
// Given
BoltStateMachineV4 machine = getBoltStateMachineInTxState();
// 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 shouldMoveFromInTxStateToFailedStateOnfail.
@ParameterizedTest
@MethodSource("pullAllDiscardAllMessages")
void shouldMoveFromInTxStateToFailedStateOnfail(RequestMessage message) throws Throwable {
// Given
BoltStateMachineV4 machine = getBoltStateMachineInTxState();
// 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.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class InTransactionStateIT method getBoltStateMachineInTxState.
private BoltStateMachineV4 getBoltStateMachineInTxState(String query) throws BoltConnectionFatality {
BoltStateMachineV4 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
machine.process(new BeginMessage(), nullResponseHandler());
assertThat(machine.state()).isInstanceOf(InTransactionState.class);
machine.process(new RunMessage(query, EMPTY_PARAMS), nullResponseHandler());
// tx streaming state
assertThat(machine.state()).isInstanceOf(InTransactionState.class);
return machine;
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class InTransactionStateIT method shouldStayInTxOnPull_succ_hasMore.
@Test
void shouldStayInTxOnPull_succ_hasMore() throws Throwable {
// Given
BoltStateMachineV4 machine = getBoltStateMachineInTxState("Unwind [1, 2, 3] as n return n");
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(newPullMessage(2), recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertThat(response).satisfies(containsRecord(1L));
assertThat(response).satisfies(succeededWithMetadata("has_more", BooleanValue.TRUE));
assertFalse(response.hasMetadata("db"));
machine.process(newPullMessage(2), recorder);
response = recorder.nextResponse();
assertThat(response).satisfies(containsRecord(3L));
assertTrue(response.hasMetadata("type"));
assertTrue(response.hasMetadata("t_last"));
assertFalse(response.hasMetadata("bookmark"));
assertTrue(response.hasMetadata("db"));
assertThat(machine.state()).isInstanceOf(InTransactionState.class);
}
Aggregations