use of org.neo4j.kernel.api.proc.ProcedureSignature in project neo4j by neo4j.
the class ProcedureJarLoaderTest method shouldLoadUnsafeAllowedProcedureFromJar.
@Test
public void shouldLoadUnsafeAllowedProcedureFromJar() throws Throwable {
// Given
URL jar = createJarFor(ClassWithUnsafeConfiguredComponent.class);
// When
ProcedureJarLoader.Callables callables = jarloader.loadProcedures(jar);
List<CallableUserFunction> functions = callables.functions();
List<CallableProcedure> procedures = callables.procedures();
// Then
List<ProcedureSignature> signatures = procedures.stream().map(CallableProcedure::signature).collect(toList());
assertThat(signatures, contains(procedureSignature("org", "neo4j", "kernel", "impl", "proc", "unsafeFullAccessProcedure").out("someNumber", NTInteger).build()));
assertThat(asList(procedures.get(0).apply(new BasicContext(), new Object[0])), contains(IsEqual.equalTo(new Object[] { 7331L })));
List<UserFunctionSignature> functionsSignatures = functions.stream().map(CallableUserFunction::signature).collect(toList());
assertThat(functionsSignatures, contains(functionSignature("org", "neo4j", "kernel", "impl", "proc", "unsafeFullAccessFunction").out(NTInteger).build()));
assertThat(functions.get(0).apply(new BasicContext(), new Object[0]), equalTo(7331L));
}
use of org.neo4j.kernel.api.proc.ProcedureSignature in project neo4j by neo4j.
the class ProcedureJarLoaderTest method shouldLoadProcedureWithArgumentFromJar.
@Test
public void shouldLoadProcedureWithArgumentFromJar() throws Throwable {
// Given
URL jar = createJarFor(ClassWithProcedureWithArgument.class);
// When
List<CallableProcedure> procedures = jarloader.loadProcedures(jar).procedures();
// Then
List<ProcedureSignature> signatures = procedures.stream().map(CallableProcedure::signature).collect(toList());
assertThat(signatures, contains(procedureSignature("org", "neo4j", "kernel", "impl", "proc", "myProcedure").in("value", NTInteger).out("someNumber", NTInteger).build()));
assertThat(asList(procedures.get(0).apply(new BasicContext(), new Object[] { 42L })), contains(IsEqual.equalTo(new Object[] { 42L })));
}
use of org.neo4j.kernel.api.proc.ProcedureSignature in project neo4j by neo4j.
the class ProcedureSignatureTest method shouldHonorVoidInEquals.
@Test
public void shouldHonorVoidInEquals() {
ProcedureSignature sig1 = procedureSignature("foo").in("a", Neo4jTypes.NTAny).build();
ProcedureSignature sig2 = procedureSignature("foo").in("a", Neo4jTypes.NTAny).out(ProcedureSignature.VOID).build();
ProcedureSignature sig2clone = procedureSignature("foo").in("a", Neo4jTypes.NTAny).out(ProcedureSignature.VOID).build();
assertEquals(sig2, sig2clone);
assertNotEquals(sig1, sig2);
}
use of org.neo4j.kernel.api.proc.ProcedureSignature in project neo4j by neo4j.
the class ProceduresKernelIT method shouldGetBuiltInProcedureByName.
@Test
public void shouldGetBuiltInProcedureByName() throws Throwable {
// When
ProcedureSignature found = readOperationsInNewTransaction().procedureGet(procedureName("db", "labels"));
// Then
assertThat(found, equalTo(procedureSignature(procedureName("db", "labels")).out("label", NTString).build()));
}
use of org.neo4j.kernel.api.proc.ProcedureSignature in project neo4j by neo4j.
the class ConfiguredProceduresTestBase method shouldSetAllowedToConfigSetting.
@Test
public void shouldSetAllowedToConfigSetting() throws Throwable {
configuredSetup(stringMap(SecuritySettings.default_allowed.name(), "nonEmpty"));
Procedures procedures = neo.getLocalGraph().getDependencyResolver().resolveDependency(Procedures.class);
ProcedureSignature numNodes = procedures.procedure(new QualifiedName(new String[] { "test" }, "numNodes"));
assertThat(Arrays.asList(numNodes.allowed()), containsInAnyOrder("nonEmpty"));
}
Aggregations