use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class TransactionReadyStateIT method shouldMoveToStreamingOnRun_succ.
@Test
void shouldMoveToStreamingOnRun_succ() throws Throwable {
// Given
BoltStateMachineV3 machine = getBoltStateMachineInTxReadyState();
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k", EMPTY_PARAMS), recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertTrue(response.hasMetadata("fields"));
assertTrue(response.hasMetadata("t_first"));
assertThat(machine.state()).isInstanceOf(TransactionStreamingState.class);
}
use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class TransactionReadyStateIT method shouldMoveToFailedOnRun_fail.
@Test
void shouldMoveToFailedOnRun_fail() throws Throwable {
BoltStateMachineV3 machine = getBoltStateMachineInTxReadyState();
// When
BoltResponseHandler handler = mock(BoltResponseHandler.class);
doThrow(new RuntimeException("Error!")).when(handler).onPullRecords(any(), anyLong());
doThrow(new RuntimeException("Error!")).when(handler).onDiscardRecords(any(), anyLong());
machine.process(new RunMessage("A cypher query"), handler);
// Then
assertThat(machine.state()).isInstanceOf(FailedState.class);
}
use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class ConnectedStateIT method shouldHandleHelloMessage.
@Test
void shouldHandleHelloMessage() throws Throwable {
// Given
BoltStateMachineV3 machine = newStateMachine();
BoltResponseRecorder recorder = new BoltResponseRecorder();
// When
machine.process(newHelloMessage(), recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertThat(response).satisfies(succeededWithMetadata("server", BOLT_SERVER_VERSION_PREFIX + Version.getNeo4jVersion()));
assertThat(response).satisfies(succeededWithMetadata("connection_id", "conn-v3-test-boltchannel-id"));
assertThat(machine.state()).isInstanceOf(ReadyState.class);
}
use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class ReadyStateIT method shouldMoveToFailedStateOnBegin_fail.
@Test
void shouldMoveToFailedStateOnBegin_fail() throws Throwable {
// Given
BoltStateMachineV3 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
BeginMessage beginMessage = mock(BeginMessage.class);
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.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class ReadyStateIT method shouldMoveToStreamingOnRun_succ.
@Test
void shouldMoveToStreamingOnRun_succ() throws Throwable {
// Given
BoltStateMachineV3 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k", EMPTY_PARAMS), recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertThat(response).satisfies(succeeded());
assertTrue(response.hasMetadata("fields"));
assertTrue(response.hasMetadata("t_first"));
assertThat(machine.state()).isInstanceOf(StreamingState.class);
}
Aggregations