public Optional<FunctionDefinition> getFunctionDefinition(String name) {
        for (String moduleName : usedModules) {
            if (loadedModules.get(moduleName).listFunctions(true).stream()
                    .anyMatch(name::equalsIgnoreCase)) {
                LOG.debug("Got FunctionDefinition '{}' from '{}' module.", name, moduleName);
                return loadedModules.get(moduleName).getFunctionDefinition(name);
            }
        }

        LOG.debug("Cannot find FunctionDefinition '{}' from any loaded modules.", name);
        return Optional.empty();
    }
@Test
    void testGetFunctionDefinition() {
        ModuleMock x = new ModuleMock("x");
        manager.loadModule(x.getType(), x);

        assertThat(manager.getFunctionDefinition(ModuleMock.DUMMY_FUNCTION_NAME)).isPresent();

        assertThat(manager.getFunctionDefinition(ModuleMock.INTERNAL_FUNCTION_NAME)).isPresent();

        // should not return function definition of an unused module
        manager.useModules(CoreModuleFactory.IDENTIFIER);
        assertThat(manager.getFunctionDefinition(ModuleMock.DUMMY_FUNCTION_NAME)).isEmpty();
    }