use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class AbstractCypherAdapterStreamTest method metadataOf.
private MapValue metadataOf(AbstractCypherAdapterStream stream) throws Throwable {
final MapValueBuilder meta = new MapValueBuilder();
stream.handleRecords(new BoltResult.DiscardingRecordConsumer() {
@Override
public void addMetadata(String key, AnyValue value) {
meta.add(key, value);
}
}, STREAM_LIMIT_UNLIMITED);
return meta.build();
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class BuiltInProceduresTest method call.
private List<Object[]> call(String name, Object... args) throws ProcedureException, IndexNotFoundKernelException {
DefaultValueMapper valueMapper = new DefaultValueMapper(mock(InternalTransaction.class));
Context ctx = buildContext(resolver, valueMapper).withTransaction(transaction).withProcedureCallContext(callContext).context();
when(graphDatabaseAPI.getDependencyResolver()).thenReturn(resolver);
when(resolver.resolveDependency(GraphDatabaseAPI.class)).thenReturn(graphDatabaseAPI);
when(resolver.resolveDependency(GlobalProcedures.class)).thenReturn(procs);
when(resolver.resolveDependency(IndexingService.class)).thenReturn(indexingService);
when(schemaReadCore.indexGetPopulationProgress(any(IndexDescriptor.class))).thenReturn(PopulationProgress.DONE);
AnyValue[] input = Arrays.stream(args).map(ValueUtils::of).toArray(AnyValue[]::new);
int procId = procs.procedure(ProcedureSignature.procedureName(name.split("\\."))).id();
List<AnyValue[]> anyValues = Iterators.asList(procs.callProcedure(ctx, procId, input, EMPTY_RESOURCE_TRACKER));
List<Object[]> toReturn = new ArrayList<>(anyValues.size());
for (AnyValue[] anyValue : anyValues) {
Object[] values = new Object[anyValue.length];
for (int i = 0; i < anyValue.length; i++) {
AnyValue value = anyValue[i];
values[i] = value.map(valueMapper);
}
toReturn.add(values);
}
return toReturn;
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class ProcedureCompilationTest method shouldCallMethodWithCompositeParameters.
@Test
void shouldCallMethodWithCompositeParameters() throws ProcedureException {
// Given
UserFunctionSignature signature = functionSignature("test", "foo").in("l", NTList(NTAny)).out(NTString).build();
// When
CallableUserFunction concatMethod = compileFunction(signature, emptyList(), method("concat", List.class));
// Then
assertEquals(stringValue("421.1true"), concatMethod.apply(ctx, new AnyValue[] { list(longValue(42), doubleValue(1.1), TRUE) }));
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class ProcedureCompilationTest method shouldHandleByteArrays.
@Test
void shouldHandleByteArrays() throws ProcedureException {
// Given
UserFunctionSignature signature = functionSignature("test", "foo").in("bytes", NTByteArray).out(NTByteArray).build();
// When
CallableUserFunction bytesMethod = compileFunction(signature, emptyList(), method("testMethod", byte[].class));
// Then
assertEquals(byteArray(new byte[] { 1, 2, 3 }), bytesMethod.apply(ctx, new AnyValue[] { byteArray(new byte[] { 1, 2, 3 }) }));
assertEquals(byteArray(new byte[] { 1, 2, 3 }), bytesMethod.apply(ctx, new AnyValue[] { list(byteValue((byte) 1), byteValue((byte) 2), byteValue((byte) 3)) }));
assertEquals(NO_VALUE, bytesMethod.apply(ctx, new AnyValue[] { NO_VALUE }));
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class ProcedureCompilationTest method shouldCallMethodWithParameters.
@Test
void shouldCallMethodWithParameters() throws ProcedureException {
// Given
UserFunctionSignature signature = functionSignature("test", "foo").in("l", NTInteger).in("d", NTFloat).in("b", NTBoolean).out(NTString).build();
// When
CallableUserFunction concatMethod = compileFunction(signature, emptyList(), method("concat", long.class, Double.class, boolean.class));
// Then
assertEquals(stringValue("421.1true"), concatMethod.apply(ctx, new AnyValue[] { longValue(42), doubleValue(1.1), booleanValue(true) }));
}
Aggregations