use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.
the class UserAggregationFunctionTest method shouldRunClassWithMultipleFunctionsDeclared.
@Test
void shouldRunClassWithMultipleFunctionsDeclared() throws Throwable {
// Given
List<CallableUserAggregationFunction> compiled = compile(MultiFunction.class);
CallableUserAggregationFunction f1 = compiled.get(0);
CallableUserAggregationFunction f2 = compiled.get(1);
// When
UserAggregator f1Aggregator = f1.create(prepareContext());
f1Aggregator.update(new AnyValue[] { stringValue("Bonnie") });
f1Aggregator.update(new AnyValue[] { stringValue("Clyde") });
UserAggregator f2Aggregator = f2.create(prepareContext());
f2Aggregator.update(new AnyValue[] { stringValue("Bonnie"), longValue(1337L) });
f2Aggregator.update(new AnyValue[] { stringValue("Bonnie"), longValue(42L) });
// Then
assertThat(f1Aggregator.result()).isEqualTo(VirtualValues.list(stringValue("Bonnie"), stringValue("Clyde")));
assertThat(((MapValue) f2Aggregator.result()).get("Bonnie")).isEqualTo(longValue(1337L));
}
use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.
the class DiscardMessageTest method shouldThrowExceptionIfFailedToParseTransactionMetadataCorrectly.
@Test
void shouldThrowExceptionIfFailedToParseTransactionMetadataCorrectly() throws Throwable {
// Given
Map<String, Object> msgMetadata = map("n", "invalid value type");
MapValue meta = ValueUtils.asMapValue(msgMetadata);
// When & Then
BoltIOException exception = assertThrows(BoltIOException.class, () -> new DiscardMessage(meta));
assertThat(exception.getMessage()).startsWith("Expecting DISCARD size n to be a Long value, but got: String(\"invalid value type\")");
}
use of org.neo4j.values.virtual.MapValue 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);
}
use of org.neo4j.values.virtual.MapValue 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.values.virtual.MapValue in project neo4j by neo4j.
the class PullMessageTest method shouldThrowExceptionIfFailedToParseTransactionMetadataCorrectly.
@Test
void shouldThrowExceptionIfFailedToParseTransactionMetadataCorrectly() throws Throwable {
// Given
Map<String, Object> msgMetadata = map("n", "invalid value type");
MapValue meta = asMapValue(msgMetadata);
// When & Then
BoltIOException exception = assertThrows(BoltIOException.class, () -> new PullMessage(meta));
assertThat(exception.getMessage()).startsWith("Expecting PULL size n to be a Long value, but got: String(\"invalid value type\")");
}
Aggregations