# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
# Issues & docs: https://github.com/kreuzberg-dev/alef
# E2e tests for category: plugin_api
unless Code.ensure_loaded?(E2e.TestStubs.TestStubRegisterDocumentExtractorTraitBridge) do
defmodule E2e.TestStubs.TestStubRegisterDocumentExtractorTraitBridge do
def name, do: "test-extractor"
def version, do: "test"
def initialize, do: :ok
def shutdown, do: :ok
def extract_bytes(content, mime_type, config), do: {:ok, %{}}
def extract_file(path, mime_type, config), do: {:ok, %{}}
def supported_mime_types, do: []
def priority, do: 0
def can_handle(_path, _mime_type), do: false
end
end
unless Code.ensure_loaded?(E2e.TestStubs.TestStubRegisterDocumentExtractorTraitBridgeGenServer) do
defmodule E2e.TestStubs.TestStubRegisterDocumentExtractorTraitBridgeGenServer do
use GenServer
def start_link(_opts) do
GenServer.start_link(__MODULE__, nil)
end
@impl true
def init(_), do: {:ok, nil}
@impl true
def handle_info({:trait_call, method_atom, args_json, reply_id}, state) do
args = Jason.decode!(args_json)
method_name = to_string(method_atom)
ordered_args = __alef_ordered_args__(method_name, args)
result = apply(E2e.TestStubs.TestStubRegisterDocumentExtractorTraitBridge, String.to_existing_atom(method_name), ordered_args)
result_json = Jason.encode!(result)
Kreuzberg.Native.complete_trait_call(reply_id, result_json)
{:noreply, state}
end
defp __alef_ordered_args__("extract_bytes", args), do: [args["content"], args["mime_type"], args["config"]]
defp __alef_ordered_args__("extract_file", args), do: [args["path"], args["mime_type"], args["config"]]
defp __alef_ordered_args__("supported_mime_types", args), do: []
defp __alef_ordered_args__("priority", args), do: []
defp __alef_ordered_args__("can_handle", args), do: [args["_path"], args["_mime_type"]]
defp __alef_ordered_args__("version", _args), do: []
defp __alef_ordered_args__("initialize", _args), do: []
defp __alef_ordered_args__("shutdown", _args), do: []
defp __alef_ordered_args__(_method, args) when map_size(args) == 0, do: []
end
end
unless Code.ensure_loaded?(E2e.TestStubs.TestStubRegisterEmbeddingBackendTraitBridge) do
defmodule E2e.TestStubs.TestStubRegisterEmbeddingBackendTraitBridge do
def name, do: "test-embedding-backend"
def version, do: "test"
def initialize, do: :ok
def shutdown, do: :ok
def dimensions, do: 1
def embed(texts), do: {:ok, []}
end
end
unless Code.ensure_loaded?(E2e.TestStubs.TestStubRegisterEmbeddingBackendTraitBridgeGenServer) do
defmodule E2e.TestStubs.TestStubRegisterEmbeddingBackendTraitBridgeGenServer do
use GenServer
def start_link(_opts) do
GenServer.start_link(__MODULE__, nil)
end
@impl true
def init(_), do: {:ok, nil}
@impl true
def handle_info({:trait_call, method_atom, args_json, reply_id}, state) do
args = Jason.decode!(args_json)
method_name = to_string(method_atom)
ordered_args = __alef_ordered_args__(method_name, args)
result = apply(E2e.TestStubs.TestStubRegisterEmbeddingBackendTraitBridge, String.to_existing_atom(method_name), ordered_args)
result_json = Jason.encode!(result)
Kreuzberg.Native.complete_trait_call(reply_id, result_json)
{:noreply, state}
end
defp __alef_ordered_args__("dimensions", args), do: []
defp __alef_ordered_args__("embed", args), do: [args["texts"]]
defp __alef_ordered_args__("version", _args), do: []
defp __alef_ordered_args__("initialize", _args), do: []
defp __alef_ordered_args__("shutdown", _args), do: []
defp __alef_ordered_args__(_method, args) when map_size(args) == 0, do: []
end
end
unless Code.ensure_loaded?(E2e.TestStubs.TestStubRegisterOcrBackendTraitBridge) do
defmodule E2e.TestStubs.TestStubRegisterOcrBackendTraitBridge do
def name, do: "test-backend"
def version, do: "test"
def initialize, do: :ok
def shutdown, do: :ok
def process_image(image_bytes, config), do: {:ok, %{}}
def process_image_file(path, config), do: {:ok, %{}}
def supports_language(lang), do: false
def backend_type, do: %{}
def supported_languages, do: []
def supports_table_detection, do: false
def supports_document_processing, do: false
def process_document(_path, _config), do: {:ok, %{}}
end
end
unless Code.ensure_loaded?(E2e.TestStubs.TestStubRegisterOcrBackendTraitBridgeGenServer) do
defmodule E2e.TestStubs.TestStubRegisterOcrBackendTraitBridgeGenServer do
use GenServer
def start_link(_opts) do
GenServer.start_link(__MODULE__, nil)
end
@impl true
def init(_), do: {:ok, nil}
@impl true
def handle_info({:trait_call, method_atom, args_json, reply_id}, state) do
args = Jason.decode!(args_json)
method_name = to_string(method_atom)
ordered_args = __alef_ordered_args__(method_name, args)
result = apply(E2e.TestStubs.TestStubRegisterOcrBackendTraitBridge, String.to_existing_atom(method_name), ordered_args)
result_json = Jason.encode!(result)
Kreuzberg.Native.complete_trait_call(reply_id, result_json)
{:noreply, state}
end
defp __alef_ordered_args__("process_image", args), do: [args["image_bytes"], args["config"]]
defp __alef_ordered_args__("process_image_file", args), do: [args["path"], args["config"]]
defp __alef_ordered_args__("supports_language", args), do: [args["lang"]]
defp __alef_ordered_args__("backend_type", args), do: []
defp __alef_ordered_args__("supported_languages", args), do: []
defp __alef_ordered_args__("supports_table_detection", args), do: []
defp __alef_ordered_args__("supports_document_processing", args), do: []
defp __alef_ordered_args__("process_document", args), do: [args["_path"], args["_config"]]
defp __alef_ordered_args__("version", _args), do: []
defp __alef_ordered_args__("initialize", _args), do: []
defp __alef_ordered_args__("shutdown", _args), do: []
defp __alef_ordered_args__(_method, args) when map_size(args) == 0, do: []
end
end
unless Code.ensure_loaded?(E2e.TestStubs.TestStubRegisterPostProcessorTraitBridge) do
defmodule E2e.TestStubs.TestStubRegisterPostProcessorTraitBridge do
def name, do: "test-processor"
def version, do: "test"
def initialize, do: :ok
def shutdown, do: :ok
def process(result, config), do: {:ok, nil}
def processing_stage, do: %{}
def should_process(_result, _config), do: false
def estimated_duration_ms(_result), do: 0
def priority, do: 0
end
end
unless Code.ensure_loaded?(E2e.TestStubs.TestStubRegisterPostProcessorTraitBridgeGenServer) do
defmodule E2e.TestStubs.TestStubRegisterPostProcessorTraitBridgeGenServer do
use GenServer
def start_link(_opts) do
GenServer.start_link(__MODULE__, nil)
end
@impl true
def init(_), do: {:ok, nil}
@impl true
def handle_info({:trait_call, method_atom, args_json, reply_id}, state) do
args = Jason.decode!(args_json)
method_name = to_string(method_atom)
ordered_args = __alef_ordered_args__(method_name, args)
result = apply(E2e.TestStubs.TestStubRegisterPostProcessorTraitBridge, String.to_existing_atom(method_name), ordered_args)
result_json = Jason.encode!(result)
Kreuzberg.Native.complete_trait_call(reply_id, result_json)
{:noreply, state}
end
defp __alef_ordered_args__("process", args), do: [args["result"], args["config"]]
defp __alef_ordered_args__("processing_stage", args), do: []
defp __alef_ordered_args__("should_process", args), do: [args["_result"], args["_config"]]
defp __alef_ordered_args__("estimated_duration_ms", args), do: [args["_result"]]
defp __alef_ordered_args__("priority", args), do: []
defp __alef_ordered_args__("version", _args), do: []
defp __alef_ordered_args__("initialize", _args), do: []
defp __alef_ordered_args__("shutdown", _args), do: []
defp __alef_ordered_args__(_method, args) when map_size(args) == 0, do: []
end
end
unless Code.ensure_loaded?(E2e.TestStubs.TestStubRegisterRendererTraitBridge) do
defmodule E2e.TestStubs.TestStubRegisterRendererTraitBridge do
def name, do: "test-renderer"
def version, do: "test"
def initialize, do: :ok
def shutdown, do: :ok
def render(doc), do: {:ok, ""}
end
end
unless Code.ensure_loaded?(E2e.TestStubs.TestStubRegisterRendererTraitBridgeGenServer) do
defmodule E2e.TestStubs.TestStubRegisterRendererTraitBridgeGenServer do
use GenServer
def start_link(_opts) do
GenServer.start_link(__MODULE__, nil)
end
@impl true
def init(_), do: {:ok, nil}
@impl true
def handle_info({:trait_call, method_atom, args_json, reply_id}, state) do
args = Jason.decode!(args_json)
method_name = to_string(method_atom)
ordered_args = __alef_ordered_args__(method_name, args)
result = apply(E2e.TestStubs.TestStubRegisterRendererTraitBridge, String.to_existing_atom(method_name), ordered_args)
result_json = Jason.encode!(result)
Kreuzberg.Native.complete_trait_call(reply_id, result_json)
{:noreply, state}
end
defp __alef_ordered_args__("render", args), do: [args["doc"]]
defp __alef_ordered_args__("version", _args), do: []
defp __alef_ordered_args__("initialize", _args), do: []
defp __alef_ordered_args__("shutdown", _args), do: []
defp __alef_ordered_args__(_method, args) when map_size(args) == 0, do: []
end
end
unless Code.ensure_loaded?(E2e.TestStubs.TestStubRegisterValidatorTraitBridge) do
defmodule E2e.TestStubs.TestStubRegisterValidatorTraitBridge do
def name, do: "test-validator"
def version, do: "test"
def initialize, do: :ok
def shutdown, do: :ok
def validate(result, config), do: {:ok, nil}
def should_validate(_result, _config), do: false
def priority, do: 0
end
end
unless Code.ensure_loaded?(E2e.TestStubs.TestStubRegisterValidatorTraitBridgeGenServer) do
defmodule E2e.TestStubs.TestStubRegisterValidatorTraitBridgeGenServer do
use GenServer
def start_link(_opts) do
GenServer.start_link(__MODULE__, nil)
end
@impl true
def init(_), do: {:ok, nil}
@impl true
def handle_info({:trait_call, method_atom, args_json, reply_id}, state) do
args = Jason.decode!(args_json)
method_name = to_string(method_atom)
ordered_args = __alef_ordered_args__(method_name, args)
result = apply(E2e.TestStubs.TestStubRegisterValidatorTraitBridge, String.to_existing_atom(method_name), ordered_args)
result_json = Jason.encode!(result)
Kreuzberg.Native.complete_trait_call(reply_id, result_json)
{:noreply, state}
end
defp __alef_ordered_args__("validate", args), do: [args["result"], args["config"]]
defp __alef_ordered_args__("should_validate", args), do: [args["_result"], args["_config"]]
defp __alef_ordered_args__("priority", args), do: []
defp __alef_ordered_args__("version", _args), do: []
defp __alef_ordered_args__("initialize", _args), do: []
defp __alef_ordered_args__("shutdown", _args), do: []
defp __alef_ordered_args__(_method, args) when map_size(args) == 0, do: []
end
end
defmodule E2e.PluginApiTest do
  use ExUnit.Case, async: false

  describe "register_document_extractor_trait_bridge" do
    test "register_document_extractor_trait_bridge" do
      {:ok, registerdocumentextractortraitbridge_pid} = E2e.TestStubs.TestStubRegisterDocumentExtractorTraitBridgeGenServer.start_link(nil)

      result = Kreuzberg.register_document_extractor(registerdocumentextractortraitbridge_pid, "test-extractor")
    end
  end

  describe "register_embedding_backend_trait_bridge" do
    test "register_embedding_backend_trait_bridge" do
      {:ok, registerembeddingbackendtraitbridge_pid} = E2e.TestStubs.TestStubRegisterEmbeddingBackendTraitBridgeGenServer.start_link(nil)

      result = Kreuzberg.register_embedding_backend(registerembeddingbackendtraitbridge_pid, "test-embedding-backend")
    end
  end

  describe "register_ocr_backend_trait_bridge" do
    test "register_ocr_backend_trait_bridge" do
      {:ok, registerocrbackendtraitbridge_pid} = E2e.TestStubs.TestStubRegisterOcrBackendTraitBridgeGenServer.start_link(nil)

      result = Kreuzberg.register_ocr_backend(registerocrbackendtraitbridge_pid, "test-backend")
    end
  end

  describe "register_post_processor_trait_bridge" do
    test "register_post_processor_trait_bridge" do
      {:ok, registerpostprocessortraitbridge_pid} = E2e.TestStubs.TestStubRegisterPostProcessorTraitBridgeGenServer.start_link(nil)

      result = Kreuzberg.register_post_processor(registerpostprocessortraitbridge_pid, "test-processor")
    end
  end

  describe "register_renderer_trait_bridge" do
    test "register_renderer_trait_bridge" do
      {:ok, registerrenderertraitbridge_pid} = E2e.TestStubs.TestStubRegisterRendererTraitBridgeGenServer.start_link(nil)

      result = Kreuzberg.register_renderer(registerrenderertraitbridge_pid, "test-renderer")
    end
  end

  describe "register_validator_trait_bridge" do
    test "register_validator_trait_bridge" do
      {:ok, registervalidatortraitbridge_pid} = E2e.TestStubs.TestStubRegisterValidatorTraitBridgeGenServer.start_link(nil)

      result = Kreuzberg.register_validator(registervalidatortraitbridge_pid, "test-validator")
    end
  end

  describe "unregister_document_extractor_after_register" do
    test "unregister_document_extractor_after_register" do
      result = Kreuzberg.unregister_document_extractor("test-extractor")
    end
  end

  describe "unregister_embedding_backend_after_register" do
    test "unregister_embedding_backend_after_register" do
      result = Kreuzberg.unregister_embedding_backend("test-embedding-backend")
    end
  end

  describe "unregister_post_processor_after_register" do
    test "unregister_post_processor_after_register" do
      result = Kreuzberg.unregister_post_processor("test-processor")
    end
  end

  describe "unregister_renderer_after_register" do
    test "unregister_renderer_after_register" do
      result = Kreuzberg.unregister_renderer("test-renderer")
    end
  end

  describe "unregister_validator_after_register" do
    test "unregister_validator_after_register" do
      result = Kreuzberg.unregister_validator("test-validator")
    end
  end
end
