Search in sources :

Example 31 with BoltStateMachineV3

use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.

the class StreamingStateIT method shouldMoveFromStreamingToReadyOnDiscardAll_succ.

@Test
void shouldMoveFromStreamingToReadyOnDiscardAll_succ() throws Throwable {
    // Given
    BoltStateMachineV3 machine = getBoltStateMachineInStreamingState();
    // When
    BoltResponseRecorder recorder = new BoltResponseRecorder();
    machine.process(DiscardAllMessage.INSTANCE, recorder);
    // Then
    RecordedBoltResponse response = recorder.nextResponse();
    assertThat(response).satisfies(succeeded());
    assertTrue(response.hasMetadata("bookmark"));
    assertThat(machine.state()).isInstanceOf(ReadyState.class);
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) RecordedBoltResponse(org.neo4j.bolt.testing.RecordedBoltResponse) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 32 with BoltStateMachineV3

use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.

the class StreamingStateIT method shouldMoveFromStreamingToInterruptedOnInterrupt.

@Test
void shouldMoveFromStreamingToInterruptedOnInterrupt() throws Throwable {
    // Given
    BoltStateMachineV3 machine = getBoltStateMachineInStreamingState();
    // When
    BoltResponseRecorder recorder = new BoltResponseRecorder();
    machine.process(InterruptSignal.INSTANCE, recorder);
    // Then
    assertThat(machine.state()).isInstanceOf(InterruptedState.class);
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 33 with BoltStateMachineV3

use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.

the class StreamingStateIT method shouldMoveFromStreamingToReadyOnPullAll_succ.

@Test
void shouldMoveFromStreamingToReadyOnPullAll_succ() throws Throwable {
    // Given
    BoltStateMachineV3 machine = getBoltStateMachineInStreamingState();
    // When
    BoltResponseRecorder recorder = new BoltResponseRecorder();
    machine.process(PullAllMessage.INSTANCE, recorder);
    // Then
    RecordedBoltResponse response = recorder.nextResponse();
    assertThat(response).satisfies(succeeded());
    assertTrue(response.hasMetadata("type"));
    assertTrue(response.hasMetadata("t_last"));
    assertTrue(response.hasMetadata("bookmark"));
    assertThat(machine.state()).isInstanceOf(ReadyState.class);
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) RecordedBoltResponse(org.neo4j.bolt.testing.RecordedBoltResponse) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 34 with BoltStateMachineV3

use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.

the class TransactionStreamingStateIT method shouldMoveFromTxStreamingStateToFailedStateOnPullAllOrDiscardAll_fail.

@ParameterizedTest
@MethodSource("pullAllDiscardAllMessages")
void shouldMoveFromTxStreamingStateToFailedStateOnPullAllOrDiscardAll_fail(RequestMessage message) throws Throwable {
    // Given
    BoltStateMachineV3 machine = getBoltStateMachineInTxStreamingState();
    // 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);
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseHandler(org.neo4j.bolt.runtime.BoltResponseHandler) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 35 with BoltStateMachineV3

use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.

the class TransactionStreamingStateIT method shouldMoveFromTxStreamingToInterruptedOnInterrupt.

@Test
void shouldMoveFromTxStreamingToInterruptedOnInterrupt() throws Throwable {
    // Given
    BoltStateMachineV3 machine = getBoltStateMachineInTxStreamingState();
    // When
    BoltResponseRecorder recorder = new BoltResponseRecorder();
    machine.process(InterruptSignal.INSTANCE, recorder);
    // Then
    assertThat(machine.state()).isInstanceOf(InterruptedState.class);
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BoltStateMachineV3 (org.neo4j.bolt.v3.BoltStateMachineV3)36 BoltResponseRecorder (org.neo4j.bolt.testing.BoltResponseRecorder)29 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 Test (org.junit.jupiter.api.Test)21 RecordedBoltResponse (org.neo4j.bolt.testing.RecordedBoltResponse)9 RunMessage (org.neo4j.bolt.v3.messaging.request.RunMessage)9 BeginMessage (org.neo4j.bolt.v3.messaging.request.BeginMessage)5 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 BoltResponseHandler (org.neo4j.bolt.runtime.BoltResponseHandler)3