use of org.neo4j.kernel.impl.util.DefaultValueMapper 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;
}
Aggregations