use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.
the class AbstractCypherAdapterStreamTest method shouldIncludeSystemUpdates.
@Test
void shouldIncludeSystemUpdates() throws Throwable {
// Given
QueryStatistics queryStatistics = mock(QueryStatistics.class);
when(queryStatistics.containsSystemUpdates()).thenReturn(true);
when(queryStatistics.getSystemUpdates()).thenReturn(11);
QueryExecution result = mock(QueryExecution.class);
BoltAdapterSubscriber subscriber = new BoltAdapterSubscriber();
when(result.fieldNames()).thenReturn(new String[0]);
when(result.executionType()).thenReturn(query(READ_WRITE));
subscriber.onResultCompleted(queryStatistics);
when(result.getNotifications()).thenReturn(Collections.emptyList());
Clock clock = mock(Clock.class);
when(clock.millis()).thenReturn(0L, 1337L);
var stream = new TestAbstractCypherAdapterStream(result, subscriber, clock);
// When
MapValue meta = metadataOf(stream);
// Then
assertThat(meta.get("type")).isEqualTo(stringValue("rw"));
assertThat(meta.get("stats")).isEqualTo(mapValues("system-updates", intValue(11)));
}
use of org.neo4j.values.virtual.MapValue 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());
}
use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.
the class AbstractTransactionInitiatingMessage method shouldParseWriteAccessModeCorrectly.
@Test
void shouldParseWriteAccessModeCorrectly() throws Throwable {
// Given
Map<String, Object> msgMetadata = map("mode", "w");
MapValue meta = ValueUtils.asMapValue(msgMetadata);
// When
TransactionInitiatingMessage beginMessage = createMessage(meta);
// Then
assertThat(beginMessage.getAccessMode()).isEqualTo(AccessMode.WRITE);
}
use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.
the class AbstractTransactionInitiatingMessage method shouldThrowExceptionIfFailedToParseAccessModeCorrectly.
@Test
void shouldThrowExceptionIfFailedToParseAccessModeCorrectly() throws Throwable {
// Given
Map<String, Object> msgMetadata = map("mode", 666);
MapValue meta = ValueUtils.asMapValue(msgMetadata);
// When & Then
BoltIOException exception = assertThrows(BoltIOException.class, () -> createMessage(meta));
assertThat(exception.getMessage()).startsWith("Expecting access mode value to be a String value");
}
use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.
the class AbstractTransactionInitiatingMessage method shouldParseTransactionMetadataCorrectly.
@Test
void shouldParseTransactionMetadataCorrectly() throws Throwable {
// Given
Map<String, Object> txMetadata = map("creation-time", Duration.ofMillis(4321L));
Map<String, Object> msgMetadata = map("tx_metadata", txMetadata);
MapValue meta = ValueUtils.asMapValue(msgMetadata);
// When
TransactionInitiatingMessage beginMessage = createMessage(meta);
// Then
assertThat(beginMessage.transactionMetadata().toString()).isEqualTo(txMetadata.toString());
}
Aggregations