use of org.neo4j.bolt.messaging.BoltResponseMessageRecorder 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);
}
use of org.neo4j.bolt.messaging.BoltResponseMessageRecorder in project neo4j by neo4j.
the class ResultHandlerTest method shouldDiscardTheResult.
@Test
void shouldDiscardTheResult() 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.onDiscardRecords(result, STREAM_LIMIT_UNLIMITED);
handler.onFinish();
List<ResponseMessage> messages = messageWriter.asList();
assertThat(messages.size()).isEqualTo(1);
assertThat(messages.get(0)).isInstanceOf(SuccessMessage.class);
}
use of org.neo4j.bolt.messaging.BoltResponseMessageRecorder in project neo4j by neo4j.
the class MessageConditions method responseMessage.
public static ResponseMessage responseMessage(Neo4jPack neo4jPack, byte[] bytes) throws IOException {
BoltResponseMessageReader unpacker = responseReader(neo4jPack, bytes);
BoltResponseMessageRecorder consumer = new BoltResponseMessageRecorder();
try {
unpacker.read(consumer);
return consumer.asList().get(0);
} catch (Throwable e) {
throw new IOException("Failed to deserialize response, '" + e.getMessage() + "'.\n" + "Raw data: \n" + HexPrinter.hex(bytes), e);
}
}
Aggregations