use of org.neo4j.internal.kernel.api.procs.QualifiedName in project neo4j by neo4j.
the class SingleInstanceRoutingProcedureInstallerTest method shouldRegisterRoutingProcedures.
@Test
void shouldRegisterRoutingProcedures() throws Exception {
DatabaseManager<?> databaseManager = mock(DatabaseManager.class);
ConnectorPortRegister portRegister = mock(ConnectorPortRegister.class);
ClientRoutingDomainChecker clientRoutingDomainChecker = mock(ClientRoutingDomainChecker.class);
Config config = Config.defaults();
LogProvider logProvider = nullLogProvider();
SingleInstanceRoutingProcedureInstaller installer = new SingleInstanceRoutingProcedureInstaller(databaseManager, clientRoutingDomainChecker, portRegister, config, logProvider);
GlobalProcedures procedures = spy(new GlobalProceduresRegistry());
installer.install(procedures);
verify(procedures, times(2)).register(any(GetRoutingTableProcedure.class));
Set<QualifiedName> expectedNames = newSetWith(new QualifiedName(new String[] { "dbms", "routing" }, "getRoutingTable"), new QualifiedName(new String[] { "dbms", "cluster", "routing" }, "getRoutingTable"));
Set<QualifiedName> actualNames = procedures.getAllProcedures().stream().map(ProcedureSignature::name).collect(toSet());
assertEquals(expectedNames, actualNames);
}
use of org.neo4j.internal.kernel.api.procs.QualifiedName in project neo4j by neo4j.
the class BuiltInDbmsProceduresIT method listAllCapabilitiesShouldNotReturnBlocked.
@Test
void listAllCapabilitiesShouldNotReturnBlocked() throws KernelException {
// set blocked capabilities
Config config = dependencyResolver.resolveDependency(Config.class);
config.set(CapabilitiesSettings.dbms_capabilities_blocked, List.of("my.custom.**"));
QualifiedName procedureName = procedureName("dbms", "listAllCapabilities");
int procedureId = procs().procedureGet(procedureName).id();
RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, new AnyValue[] {}, ProcedureCallContext.EMPTY);
List<AnyValue[]> capabilities = asList(callResult);
List<String> capabilityNames = capabilities.stream().map(c -> ((TextValue) c[0]).stringValue()).collect(Collectors.toList());
assertThat(capabilityNames).containsExactlyInAnyOrder(DBMSCapabilities.dbms_instance_version.name().fullName(), DBMSCapabilities.dbms_instance_kernel_version.name().fullName(), DBMSCapabilities.dbms_instance_edition.name().fullName(), DBMSCapabilities.dbms_instance_operational_mode.name().fullName(), TestCapabilities.my_dynamic_capability.name().fullName(), TestCapabilities.my_internal_capability.name().fullName());
}
use of org.neo4j.internal.kernel.api.procs.QualifiedName in project neo4j by neo4j.
the class BuiltInDbmsProceduresIT method listAllCapabilities.
@Test
void listAllCapabilities() throws KernelException {
QualifiedName procedureName = procedureName("dbms", "listAllCapabilities");
int procedureId = procs().procedureGet(procedureName).id();
RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, new AnyValue[] {}, ProcedureCallContext.EMPTY);
List<AnyValue[]> capabilities = asList(callResult);
List<String> capabilityNames = capabilities.stream().map(c -> ((TextValue) c[0]).stringValue()).collect(Collectors.toList());
assertThat(capabilityNames).containsExactlyInAnyOrder(DBMSCapabilities.dbms_instance_version.name().fullName(), DBMSCapabilities.dbms_instance_kernel_version.name().fullName(), DBMSCapabilities.dbms_instance_edition.name().fullName(), DBMSCapabilities.dbms_instance_operational_mode.name().fullName(), TestCapabilities.my_custom_capability.name().fullName(), TestCapabilities.my_internal_capability.name().fullName(), TestCapabilities.my_dynamic_capability.name().fullName());
}
use of org.neo4j.internal.kernel.api.procs.QualifiedName in project neo4j by neo4j.
the class BuiltInDbmsProceduresIT method callListConfig.
private List<AnyValue[]> callListConfig(String searchString) throws KernelException {
QualifiedName procedureName = procedureName("dbms", "listConfig");
int procedureId = procs().procedureGet(procedureName).id();
RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, toArray(stringValue(searchString)), ProcedureCallContext.EMPTY);
return asList(callResult);
}
use of org.neo4j.internal.kernel.api.procs.QualifiedName in project neo4j by neo4j.
the class ProcedureCompiler method compileProcedure.
List<CallableProcedure> compileProcedure(Class<?> procDefinition, String warning, boolean fullAccess) throws KernelException {
try {
List<Method> procedureMethods = Arrays.stream(procDefinition.getDeclaredMethods()).filter(m -> m.isAnnotationPresent(Procedure.class)).collect(Collectors.toList());
if (procedureMethods.isEmpty()) {
return emptyList();
}
assertValidConstructor(procDefinition);
List<CallableProcedure> out = new ArrayList<>(procedureMethods.size());
for (Method method : procedureMethods) {
String valueName = method.getAnnotation(Procedure.class).value();
String definedName = method.getAnnotation(Procedure.class).name();
QualifiedName procName = extractName(procDefinition, method, valueName, definedName);
if (fullAccess || config.isWhitelisted(procName.toString())) {
out.add(compileProcedure(procDefinition, method, warning, fullAccess, procName));
} else {
log.warn(String.format("The procedure '%s' is not on the allowlist and won't be loaded.", procName.toString()));
}
}
out.sort(Comparator.comparing(a -> a.signature().name().toString()));
return out;
} catch (KernelException e) {
throw e;
} catch (Exception e) {
throw new ProcedureException(Status.Procedure.ProcedureRegistrationFailed, e, "Failed to compile procedure defined in `%s`: %s", procDefinition.getSimpleName(), e.getMessage());
}
}
Aggregations