Search in sources :

Example 1 with RecordMessage

use of org.neo4j.bolt.v3.messaging.response.RecordMessage in project neo4j by neo4j.

the class BoltResponseMessageRecorder method endRecord.

@Override
public void endRecord() {
    currentOffset = -1;
    messages.add(new RecordMessage(fields));
}
Also used : RecordMessage(org.neo4j.bolt.v3.messaging.response.RecordMessage)

Example 2 with RecordMessage

use of org.neo4j.bolt.v3.messaging.response.RecordMessage in project neo4j by neo4j.

the class BoltResponseMessageWriterV3Test method shouldNotNotifyOutputWhenOutputItselfFails.

@Test
void shouldNotNotifyOutputWhenOutputItselfFails() throws Exception {
    PackOutput output = mock(PackOutput.class);
    Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
    IOException error = new IOException("Unable to flush");
    doThrow(error).when(output).messageSucceeded();
    var writer = newWriter(output, packer);
    var e = assertThrows(IOException.class, () -> writer.write(new RecordMessage(new AnyValue[] { longValue(1), longValue(2) })));
    assertEquals(error, e);
    InOrder inOrder = inOrder(output, packer);
    inOrder.verify(output).beginMessage();
    inOrder.verify(packer).pack(longValue(1));
    inOrder.verify(packer).pack(longValue(2));
    inOrder.verify(output).messageSucceeded();
    verify(output, never()).messageFailed();
}
Also used : InOrder(org.mockito.InOrder) IOException(java.io.IOException) PackOutput(org.neo4j.bolt.packstream.PackOutput) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) RecordMessage(org.neo4j.bolt.v3.messaging.response.RecordMessage) Test(org.junit.jupiter.api.Test)

Example 3 with RecordMessage

use of org.neo4j.bolt.v3.messaging.response.RecordMessage in project neo4j by neo4j.

the class BoltResponseMessageWriterV3Test method shouldWriteRecordMessage.

@Test
void shouldWriteRecordMessage() throws Exception {
    PackOutput output = mock(PackOutput.class);
    Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
    var writer = newWriter(output, packer);
    writer.write(new RecordMessage(new AnyValue[] { longValue(42), stringValue("42") }));
    InOrder inOrder = inOrder(output, packer);
    inOrder.verify(output).beginMessage();
    inOrder.verify(packer).pack(longValue(42));
    inOrder.verify(packer).pack(stringValue("42"));
    inOrder.verify(output).messageSucceeded();
}
Also used : InOrder(org.mockito.InOrder) AnyValue(org.neo4j.values.AnyValue) PackOutput(org.neo4j.bolt.packstream.PackOutput) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) RecordMessage(org.neo4j.bolt.v3.messaging.response.RecordMessage) Test(org.junit.jupiter.api.Test)

Example 4 with RecordMessage

use of org.neo4j.bolt.v3.messaging.response.RecordMessage in project neo4j by neo4j.

the class ResultHandlerTest method shouldPullTheResult.

@Test
void shouldPullTheResult() throws Throwable {
    BoltResponseMessageRecorder messageWriter = new BoltResponseMessageRecorder();
    ResultHandler handler = new ResultHandler(messageWriter, mock(BoltConnection.class), NullLog.getInstance());
    Value[] record1 = values("a", "b", "c");
    Value[] record2 = values("1", "2", "3");
    BoltResult result = new TestBoltResult(record1, record2);
    handler.onPullRecords(result, STREAM_LIMIT_UNLIMITED);
    handler.onFinish();
    List<ResponseMessage> messages = messageWriter.asList();
    assertThat(messages.size()).isEqualTo(3);
    assertThat(messages.get(0)).isEqualTo(new RecordMessage(record1));
    assertThat(messages.get(1)).isEqualTo(new RecordMessage(record2));
    assertThat(messages.get(2)).isInstanceOf(SuccessMessage.class);
}
Also used : BoltResponseMessageRecorder(org.neo4j.bolt.messaging.BoltResponseMessageRecorder) BoltConnection(org.neo4j.bolt.runtime.BoltConnection) AnyValue(org.neo4j.values.AnyValue) Value(org.neo4j.values.storable.Value) ResponseMessage(org.neo4j.bolt.messaging.ResponseMessage) RecordMessage(org.neo4j.bolt.v3.messaging.response.RecordMessage) BoltResult(org.neo4j.bolt.runtime.BoltResult) Test(org.junit.jupiter.api.Test)

Example 5 with RecordMessage

use of org.neo4j.bolt.v3.messaging.response.RecordMessage in project neo4j by neo4j.

the class RecordMessageEncoderTest method shouldEncodeRecordMessage.

@Test
void shouldEncodeRecordMessage() throws Throwable {
    // Given
    Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
    RecordMessageEncoder encoder = new RecordMessageEncoder();
    // When
    encoder.encode(packer, new RecordMessage(new AnyValue[0]));
    // Then
    verify(packer).packStructHeader(anyInt(), eq(RecordMessage.SIGNATURE));
    verify(packer).packListHeader(0);
}
Also used : AnyValue(org.neo4j.values.AnyValue) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) RecordMessage(org.neo4j.bolt.v3.messaging.response.RecordMessage) Test(org.junit.jupiter.api.Test)

Aggregations

RecordMessage (org.neo4j.bolt.v3.messaging.response.RecordMessage)8 Test (org.junit.jupiter.api.Test)6 AnyValue (org.neo4j.values.AnyValue)5 Neo4jPack (org.neo4j.bolt.packstream.Neo4jPack)4 InOrder (org.mockito.InOrder)3 PackOutput (org.neo4j.bolt.packstream.PackOutput)3 IOException (java.io.IOException)2 FailureMessage (org.neo4j.bolt.v3.messaging.response.FailureMessage)2 SuccessMessage (org.neo4j.bolt.v3.messaging.response.SuccessMessage)2 BoltResponseMessageRecorder (org.neo4j.bolt.messaging.BoltResponseMessageRecorder)1 ResponseMessage (org.neo4j.bolt.messaging.ResponseMessage)1 PackStream (org.neo4j.bolt.packstream.PackStream)1 BoltConnection (org.neo4j.bolt.runtime.BoltConnection)1 BoltResult (org.neo4j.bolt.runtime.BoltResult)1 Value (org.neo4j.values.storable.Value)1 MapValue (org.neo4j.values.virtual.MapValue)1