use of org.neo4j.bolt.packstream.PackOutput in project neo4j by neo4j.
the class BoltResponseMessageWriterV3Test method shouldWriteSuccessMessage.
@Test
void shouldWriteSuccessMessage() throws Exception {
PackOutput output = mock(PackOutput.class);
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
var writer = newWriter(output, packer);
MapValue metadata = map(new String[] { "a", "b", "c" }, new AnyValue[] { intValue(1), stringValue("2"), date(2010, 02, 02) });
writer.write(new SuccessMessage(metadata));
InOrder inOrder = inOrder(output, packer);
inOrder.verify(output).beginMessage();
inOrder.verify(packer).pack(metadata);
inOrder.verify(output).messageSucceeded();
}
use of org.neo4j.bolt.packstream.PackOutput in project neo4j by neo4j.
the class BoltResponseMessageWriterV3Test method shouldFlush.
@Test
void shouldFlush() throws Exception {
PackOutput output = mock(PackOutput.class);
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
var writer = newWriter(output, packer);
writer.flush();
verify(output).flush();
}
use of org.neo4j.bolt.packstream.PackOutput in project neo4j by neo4j.
the class BoltResponseMessageWriterV3Test method shouldNotifyOutputAboutFailedRecordMessage.
@Test
void shouldNotifyOutputAboutFailedRecordMessage() throws Exception {
PackOutput output = mock(PackOutput.class);
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
IOException error = new IOException("Unable to pack 42");
doThrow(error).when(packer).pack(longValue(42));
var writer = newWriter(output, packer);
var e = assertThrows(IOException.class, () -> writer.write(new RecordMessage(new AnyValue[] { stringValue("42"), longValue(42) })));
assertEquals(error, e);
InOrder inOrder = inOrder(output, packer);
inOrder.verify(output).beginMessage();
inOrder.verify(packer).pack(stringValue("42"));
inOrder.verify(packer).pack(longValue(42));
inOrder.verify(output).messageFailed();
}
Aggregations