Search in sources :

Example 1 with DefaultValueMapper

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;
}
Also used : SecurityContext(org.neo4j.internal.kernel.api.security.SecurityContext) BasicContext.buildContext(org.neo4j.kernel.api.procedure.BasicContext.buildContext) Context(org.neo4j.kernel.api.procedure.Context) ProcedureCallContext(org.neo4j.internal.kernel.api.procs.ProcedureCallContext) AnyValue(org.neo4j.values.AnyValue) ArrayList(java.util.ArrayList) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) DefaultValueMapper(org.neo4j.kernel.impl.util.DefaultValueMapper)

Aggregations

ArrayList (java.util.ArrayList)1 ProcedureCallContext (org.neo4j.internal.kernel.api.procs.ProcedureCallContext)1 SecurityContext (org.neo4j.internal.kernel.api.security.SecurityContext)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 BasicContext.buildContext (org.neo4j.kernel.api.procedure.BasicContext.buildContext)1 Context (org.neo4j.kernel.api.procedure.Context)1 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)1 DefaultValueMapper (org.neo4j.kernel.impl.util.DefaultValueMapper)1 AnyValue (org.neo4j.values.AnyValue)1