Search in sources :

Example 6 with RunMessage

use of org.neo4j.bolt.v3.messaging.request.RunMessage 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);
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) RecordedBoltResponse(org.neo4j.bolt.testing.RecordedBoltResponse) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with RunMessage

use of org.neo4j.bolt.v3.messaging.request.RunMessage in project neo4j by neo4j.

the class MessageDecoderTest method testUnpackableStructParametersWithKnownType.

private void testUnpackableStructParametersWithKnownType(Neo4jPack packerForSerialization, AnyValue parameterValue, String expectedMessage) throws Exception {
    String statement = "RETURN $x";
    MapValue parameters = VirtualValues.map(new String[] { "x" }, new AnyValue[] { parameterValue });
    BoltStateMachine stateMachine = mock(BoltStateMachine.class);
    SynchronousBoltConnection connection = new SynchronousBoltConnection(stateMachine);
    channel = new EmbeddedChannel(newDecoder(connection));
    channel.writeInbound(Unpooled.wrappedBuffer(serialize(packerForSerialization, new RunMessage(statement, parameters))));
    channel.finishAndReleaseAll();
    verify(stateMachine).handleExternalFailure(eq(Neo4jError.from(Status.Statement.TypeError, expectedMessage)), any());
}
Also used : BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) SynchronousBoltConnection(org.neo4j.bolt.runtime.SynchronousBoltConnection) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) MapValue(org.neo4j.values.virtual.MapValue) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage)

Example 8 with RunMessage

use of org.neo4j.bolt.v3.messaging.request.RunMessage in project neo4j by neo4j.

the class BoltRequestMessageV3Test method shouldHandleCommonMessages.

@Test
void shouldHandleCommonMessages() throws Throwable {
    assertSerializes(new HelloMessage(map("user_agent", "MyClient/1.0", "scheme", "basic")));
    assertSerializes(new RunMessage("CREATE (n) RETURN åäö"));
    assertSerializes(DiscardAllMessage.INSTANCE);
    assertSerializes(PullAllMessage.INSTANCE);
    assertSerializes(new BeginMessage());
    assertSerializes(COMMIT_MESSAGE);
    assertSerializes(ROLLBACK_MESSAGE);
    assertSerializes(ResetMessage.INSTANCE);
    assertSerializes(GOODBYE_MESSAGE);
}
Also used : HelloMessage(org.neo4j.bolt.v3.messaging.request.HelloMessage) BeginMessage(org.neo4j.bolt.v3.messaging.request.BeginMessage) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage) Test(org.junit.jupiter.api.Test)

Example 9 with RunMessage

use of org.neo4j.bolt.v3.messaging.request.RunMessage in project neo4j by neo4j.

the class BoltRequestMessageV3Test method shouldHandleParameterizedStatements.

@Test
void shouldHandleParameterizedStatements() throws Throwable {
    // Given
    MapValue parameters = ValueUtils.asMapValue(map("n", 12L));
    // When
    RunMessage msg = serializeAndDeserialize(new RunMessage("asd", parameters));
    // Then
    MapValue params = msg.params();
    assertThat(params).isEqualTo(parameters);
}
Also used : MapValue(org.neo4j.values.virtual.MapValue) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage) Test(org.junit.jupiter.api.Test)

Example 10 with RunMessage

use of org.neo4j.bolt.v3.messaging.request.RunMessage in project neo4j by neo4j.

the class RunMessageDecoderTest method shouldDecodeBeginMessage.

@Test
void shouldDecodeBeginMessage() throws Exception {
    RunMessage originalMessage = new RunMessage("A new V3 run messsage");
    assertOriginalMessageEqualsToDecoded(originalMessage, decoder);
}
Also used : RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage) Test(org.junit.jupiter.api.Test)

Aggregations

RunMessage (org.neo4j.bolt.v3.messaging.request.RunMessage)15 BoltStateMachineV3 (org.neo4j.bolt.v3.BoltStateMachineV3)9 Test (org.junit.jupiter.api.Test)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 BoltResponseRecorder (org.neo4j.bolt.testing.BoltResponseRecorder)6 BeginMessage (org.neo4j.bolt.v3.messaging.request.BeginMessage)4 MapValue (org.neo4j.values.virtual.MapValue)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 RecordedBoltResponse (org.neo4j.bolt.testing.RecordedBoltResponse)2 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 BoltResponseHandler (org.neo4j.bolt.runtime.BoltResponseHandler)1 SynchronousBoltConnection (org.neo4j.bolt.runtime.SynchronousBoltConnection)1 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)1 HelloMessage (org.neo4j.bolt.v3.messaging.request.HelloMessage)1 BookmarkWithPrefix (org.neo4j.bolt.v3.runtime.bookmarking.BookmarkWithPrefix)1 KernelTransactionHandle (org.neo4j.kernel.api.KernelTransactionHandle)1 KernelTransactions (org.neo4j.kernel.impl.api.KernelTransactions)1 ValueUtils.asMapValue (org.neo4j.kernel.impl.util.ValueUtils.asMapValue)1 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)1