use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class ProcedureTest method shouldGiveHelpfulErrorOnNullMessageException.
@Test
void shouldGiveHelpfulErrorOnNullMessageException() throws Throwable {
// Given
CallableProcedure proc = compile(ProcedureThatThrowsNullMsgExceptionAtInvocation.class).get(0);
ProcedureException exception = assertThrows(ProcedureException.class, () -> proc.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER));
assertThat(exception.getMessage()).isEqualTo("Failed to invoke procedure `org.neo4j.procedure.impl.throwsAtInvocation`: Caused by: java.lang.IndexOutOfBoundsException");
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class UserFunctionsTest method shouldMakeContextAvailable.
@Test
void shouldMakeContextAvailable() throws Throwable {
// Given
procs.register(new CallableUserFunction.BasicUserFunction(signature) {
@Override
public AnyValue apply(Context ctx, AnyValue[] input) throws ProcedureException {
return Values.stringValue(ctx.thread().getName());
}
});
Context ctx = prepareContext();
int functionId = procs.function(signature.name()).id();
// When
Object result = procs.callFunction(ctx, functionId, new AnyValue[0]);
// Then
assertThat(result).isEqualTo(Values.stringValue(Thread.currentThread().getName()));
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class UserFunctionsTest method shouldNotAllowCallingNonExistingFunction.
@Test
void shouldNotAllowCallingNonExistingFunction() {
UserFunctionHandle functionHandle = procs.function(signature.name());
ProcedureException exception = assertThrows(ProcedureException.class, () -> procs.callFunction(prepareContext(), functionHandle != null ? functionHandle.id() : -1, new AnyValue[] { numberValue(1337) }));
assertThat(exception.getMessage()).isEqualTo("There is no function with the internal id `-1` registered for this database instance.");
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class SplittableRandomValuesTest method nextArray.
@Test
void nextArray() {
assertTimeoutPreemptively(Duration.ofMillis(10_000), () -> {
Set<Class<? extends AnyValue>> seen = new HashSet<>(TYPES);
while (!seen.isEmpty()) {
ArrayValue arrayValue = randomValues.nextArray();
assertThat(arrayValue.length()).isGreaterThanOrEqualTo(1);
AnyValue value = arrayValue.value(0);
assertKnownType(value.getClass(), TYPES);
markSeen(value.getClass(), seen);
}
});
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class SplittableRandomValuesTest method nextValueOfTypes.
@Test
void nextValueOfTypes() {
assertTimeoutPreemptively(Duration.ofMillis(10_000), () -> {
ValueType[] allTypes = ValueType.values();
ValueType[] including = randomValues.selection(allTypes, 1, allTypes.length, false);
Set<Class<? extends AnyValue>> seen = new HashSet<>();
for (ValueType type : including) {
seen.add(type.valueClass);
}
while (!seen.isEmpty()) {
Value value = randomValues.nextValueOfTypes(including);
assertValueAmongTypes(including, value);
markSeen(value.getClass(), seen);
}
});
}
Aggregations