use of org.neo4j.internal.kernel.api.procs.Neo4jTypes.NTList 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.internal.kernel.api.procs.Neo4jTypes.NTList in project neo4j by neo4j.
the class ProcedureCompilationTest method shouldHandleNumberOutput.
@Test
void shouldHandleNumberOutput() throws ProcedureException {
// Given
UserFunctionSignature signature = functionSignature("test", "foo").in("numbers", NTList(NTNumber)).out(NTNumber).build();
// When
CallableUserFunction sumMethod = compileFunction(signature, emptyList(), method("sum", List.class));
// Then
assertEquals(longValue(3), sumMethod.apply(ctx, new AnyValue[] { list(longValue(1), longValue(2)) }));
}
use of org.neo4j.internal.kernel.api.procs.Neo4jTypes.NTList in project neo4j by neo4j.
the class ListConverterTest method shouldHandleNestedLists.
@SuppressWarnings("unchecked")
@Test
void shouldHandleNestedLists() {
// Given
ParameterizedType type = mock(ParameterizedType.class);
when(type.getActualTypeArguments()).thenReturn(new Type[] { Object.class });
ListConverter converter = new ListConverter(type, NTList(NTAny), expressionEvaluator());
String mapString = "[42, [42, 1337]]";
// When
DefaultParameterValue converted = converter.apply(mapString);
// Then
List<Object> list = (List<Object>) converted.value();
assertThat(list.get(0)).isEqualTo(42L);
assertThat(list.get(1)).isEqualTo(asList(42L, 1337L));
}
Aggregations