// 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

package dev.kreuzberg.e2e;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import dev.kreuzberg.Kreuzberg;
import dev.kreuzberg.ExtractionConfig;
import java.util.Optional;
import dev.kreuzberg.JsonUtil;

/** E2e tests for category: async. */
class AsyncTest {

    @Test
    void testAsyncExtractBytes() throws Exception {
        // Async extract_bytes call on PDF document
        var result = Kreuzberg.extractBytes(java.nio.file.Files.readAllBytes(java.nio.file.Path.of("pdf/fake_memo.pdf")), "application/pdf", ExtractionConfig.builder().build());
assertEquals("application/pdf", result.mimeType().trim());assertTrue(result.content().length() >= 50, "expected length >= 50");

    }


    @Test
    void testAsyncExtractBytesEmptyMime() throws Exception {
        // extract_bytes empty MIME async
        // Wrap setup_lines + call_expr inside the lambda so error fixtures
        // catch failures at *any* step — including `<Type>.fromJson(...)`
        // calls that throw on malformed JSON (e.g. error fixtures with an
        // invalid enum value like `"purpose":"invalid-purpose"`). Mirrors
        // the C# `Assert.ThrowsAnyAsync(() => client.X(Type.FromJson(...)))`
        // pattern.
        assertThrows(Exception.class, () -> {
        var config = JsonUtil.fromJson("{}", ExtractionConfig.class);

            Kreuzberg.extractBytes(java.nio.file.Files.readAllBytes(java.nio.file.Path.of("text/plain.txt")), "", config);
        });

    }


    @Test
    void testAsyncExtractBytesInvalidMime() throws Exception {
        // extract_bytes unsupported MIME async
        // Wrap setup_lines + call_expr inside the lambda so error fixtures
        // catch failures at *any* step — including `<Type>.fromJson(...)`
        // calls that throw on malformed JSON (e.g. error fixtures with an
        // invalid enum value like `"purpose":"invalid-purpose"`). Mirrors
        // the C# `Assert.ThrowsAnyAsync(() => client.X(Type.FromJson(...)))`
        // pattern.
        assertThrows(Exception.class, () -> {
        var config = JsonUtil.fromJson("{}", ExtractionConfig.class);

            Kreuzberg.extractBytes(java.nio.file.Files.readAllBytes(java.nio.file.Path.of("text/plain.txt")), "application/x-nonexistent", config);
        });

    }

}
