use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method testMarkFailedShouldYieldIgnoredIfAlreadyFailed.
private static void testMarkFailedShouldYieldIgnoredIfAlreadyFailed(ThrowingBiConsumer<BoltStateMachine, BoltResponseHandler, BoltConnectionFatality> action) throws Exception {
// Given
BoltStateMachine machine = init(newMachine());
machine.markFailed(Neo4jError.from(new RuntimeException()));
BoltResponseHandler responseHandler = mock(BoltResponseHandler.class);
Neo4jError error = Neo4jError.from(Status.Request.NoThreadsAvailable, "no threads");
machine.markFailed(error);
// When
action.accept(machine, responseHandler);
// Expect
assertNull(pendingError(machine));
assertFalse(pendingIgnore(machine));
assertThat(machine).satisfies(inState(FailedState.class));
verify(responseHandler).markIgnored();
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method testMarkFailedOnNextMessage.
private static void testMarkFailedOnNextMessage(ThrowingBiConsumer<BoltStateMachine, BoltResponseHandler, BoltConnectionFatality> action) throws Exception {
// Given
BoltStateMachine machine = init(newMachine());
BoltResponseHandler responseHandler = mock(BoltResponseHandler.class);
Neo4jError error = Neo4jError.from(Status.Request.NoThreadsAvailable, "no threads");
machine.markFailed(error);
// When
action.accept(machine, responseHandler);
// Expect
assertNull(pendingError(machine));
assertFalse(pendingIgnore(machine));
assertThat(machine).satisfies(inState(FailedState.class));
verify(responseHandler).markFailed(error);
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldResetWithOpenTransaction.
@Test
void shouldResetWithOpenTransaction() throws Throwable {
BoltStateMachine machine = newMachineWithTransaction();
assertThat(machine).satisfies(canReset());
assertThat(machine).satisfies(hasNoTransaction());
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldInvokeResponseHandlerOnMarkFailedIfThereIsHandler.
@Test
void shouldInvokeResponseHandlerOnMarkFailedIfThereIsHandler() throws Exception {
BoltStateMachine machine = init(newMachine());
Neo4jError error = Neo4jError.from(Status.Request.NoThreadsAvailable, "no threads");
BoltResponseHandler responseHandler = mock(BoltResponseHandler.class);
((AbstractBoltStateMachine) machine).connectionState().setResponseHandler(responseHandler);
machine.markFailed(error);
assertNull(pendingError(machine));
assertFalse(pendingIgnore(machine));
assertThat(machine).satisfies(inState(FailedState.class));
verify(responseHandler).markFailed(error);
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method actionsDisallowedBeforeInitialized.
@Test
void actionsDisallowedBeforeInitialized() {
// Given
BoltStateMachine machine = newMachine();
// When
try {
machine.process(BoltV4Messages.run(), nullResponseHandler());
fail("Failed to fail fatally");
}// Then
catch (BoltConnectionFatality e) {
// fatality correctly generated
}
}
Aggregations