use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class BoltResponseMessageTest method shouldSerializeNode.
@Test
void shouldSerializeNode() throws Throwable {
NodeValue nodeValue = nodeValue(12L, stringArray("User", "Banana"), VirtualValues.map(new String[] { "name", "age" }, new AnyValue[] { stringValue("Bob"), intValue(14) }));
assertThat(serialized(nodeValue)).isEqualTo("B1 71 91 B3 4E 0C 92 84 55 73 65 72 86 42 61 6E" + lineSeparator() + "61 6E 61 A2 84 6E 61 6D 65 83 42 6F 62 83 61 67" + lineSeparator() + "65 0E");
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class BoltResponseMessageTest method shouldHandleCommonMessages.
@Test
void shouldHandleCommonMessages() throws Throwable {
assertSerializes(new RecordMessage(new AnyValue[] { longValue(1L), stringValue("b"), longValue(2L) }));
assertSerializes(new SuccessMessage(VirtualValues.EMPTY_MAP));
assertSerializes(new FailureMessage(Status.General.UnknownError, "Err"));
assertSerializes(IGNORED_MESSAGE);
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class ProcedureJarLoaderTest method shouldLoadProcedureFromJar.
@Test
void shouldLoadProcedureFromJar() throws Throwable {
// Given
URL jar = createJarFor(ClassWithOneProcedure.class);
// When
List<CallableProcedure> procedures = jarloader.loadProceduresFromDir(parentDir(jar)).procedures();
// Then
List<ProcedureSignature> signatures = procedures.stream().map(CallableProcedure::signature).collect(toList());
assertThat(signatures).containsExactly(procedureSignature("org", "neo4j", "procedure", "impl", "myProcedure").out("someNumber", NTInteger).build());
assertThat(asList(procedures.get(0).apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER))).containsExactly(new AnyValue[] { Values.longValue(1337L) });
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class ProcedureJarLoaderTest method shouldLoadProcedureFromJarWithSpacesInFilename.
@Test
void shouldLoadProcedureFromJarWithSpacesInFilename() throws Throwable {
// Given
URL jar = new JarBuilder().createJarFor(testDirectory.createFile(new Random().nextInt() + " some spaces in filename.jar"), ClassWithOneProcedure.class);
// When
List<CallableProcedure> procedures = jarloader.loadProceduresFromDir(parentDir(jar)).procedures();
// Then
List<ProcedureSignature> signatures = procedures.stream().map(CallableProcedure::signature).collect(toList());
assertThat(signatures).containsExactly(procedureSignature("org", "neo4j", "procedure", "impl", "myProcedure").out("someNumber", NTInteger).build());
assertThat(asList(procedures.get(0).apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER))).containsExactly(new AnyValue[] { Values.longValue(1337L) });
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class ProcedureCompilationTest method shouldHandleStrings.
@Test
void shouldHandleStrings() throws ProcedureException {
// Given
UserFunctionSignature signature = functionSignature("test", "foo").in("string", NTString).out(NTString).build();
// When
CallableUserFunction stringMethod = compileFunction(signature, emptyList(), method("testMethod", String.class));
// Then
assertEquals(stringValue("good"), stringMethod.apply(ctx, new AnyValue[] { stringValue("good") }));
assertEquals(NO_VALUE, stringMethod.apply(ctx, new AnyValue[] { NO_VALUE }));
}
Aggregations