// 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 kotlin.test.assertEquals
import kotlin.test.assertTrue
import kotlin.test.assertFalse
import kotlin.test.assertFailsWith
import kotlinx.coroutines.runBlocking
import dev.kreuzberg.Kreuzberg
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import dev.kreuzberg.ExtractionConfig
import dev.kreuzberg.BatchBytesItem
import dev.kreuzberg.BatchFileItem

/** E2e tests for category: batch. */
class BatchTest {

    companion object {
        private val MAPPER = ObjectMapper().registerModule(Jdk8Module()).registerKotlinModule().setPropertyNamingStrategy(com.fasterxml.jackson.databind.PropertyNamingStrategies.SNAKE_CASE)
    }
    @Test
    fun testBatchBytesInvalidMime() = runBlocking {
        // batch_extract_bytes_sync invalid MIME
        val result = Kreuzberg.batchExtractBytesSync(listOf(BatchBytesItem(byteArrayOf(72, 101, 108, 108, 111), "application/x-nonexistent", null)), ExtractionConfig())
    }

    @Test
    fun testBatchExtractBytesHappy() = runBlocking {
        // batch_extract_bytes: happy path with mixed inputs
        val result = Kreuzberg.batchExtractBytes(listOf(BatchBytesItem(byteArrayOf(72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33), "text/plain", null), BatchBytesItem(byteArrayOf(60, 104, 116, 109, 108, 62, 60, 98, 111, 100, 121, 62, 84, 101, 115, 116, 60, 47, 98, 111, 100, 121, 62, 60, 47, 104, 116, 109, 108, 62), "text/html", null)), ExtractionConfig())
        assertTrue(result.size >= 1, "expected at least 1 elements")
    }

    @Test
    fun testBatchExtractBytesMixedFormat() = runBlocking {
        // batch_extract_bytes: handles unsupported MIME gracefully
        val result = Kreuzberg.batchExtractBytes(listOf(BatchBytesItem(byteArrayOf(80, 68, 70, 32, 112, 108, 97, 99, 101, 104, 111, 108, 100, 101, 114), "application/x-unknown", null)), ExtractionConfig())
    }

    @Test
    fun testBatchExtractBytesSyncEmptyList() = runBlocking {
        // batch_extract_bytes_sync: empty batch
        val result = Kreuzberg.batchExtractBytesSync(listOf(), ExtractionConfig())
        assertEquals(0, result.size, "expected exactly 0 elements")
    }

    @Test
    fun testBatchExtractBytesSyncInvalidMime() = runBlocking {
        // batch_extract_bytes_sync: unsupported MIME
        val result = Kreuzberg.batchExtractBytesSync(listOf(BatchBytesItem(byteArrayOf(100, 97, 116, 97), "application/x-unknown", null)), ExtractionConfig())
    }

    @Test
    fun testBatchFileAsyncBasic() = runBlocking {
        // Extract text from multiple files asynchronously
        val result = Kreuzberg.batchExtractFiles(listOf(BatchFileItem(java.nio.file.Paths.get("pdf/fake_memo.pdf"), null), BatchFileItem(java.nio.file.Paths.get("text/fake_text.txt"), null)), ExtractionConfig())
    }

    @Test
    fun testBatchFileAsyncNotFound() = runBlocking {
        // batch_extract_file async nonexistent
        val result = Kreuzberg.batchExtractFiles(listOf(BatchFileItem(java.nio.file.Paths.get("/nonexistent/a.pdf"), null)), ExtractionConfig())
    }

    @Test
    fun testBatchFileNotFound() = runBlocking {
        // batch_extract_file_sync nonexistent
        val result = Kreuzberg.batchExtractFilesSync(listOf(BatchFileItem(java.nio.file.Paths.get("/nonexistent/a.pdf"), null), BatchFileItem(java.nio.file.Paths.get("/nonexistent/b.txt"), null)), ExtractionConfig())
    }

    @Test
    fun testBatchFilePartial() = runBlocking {
        // batch_extract_file_sync mixed
        val result = Kreuzberg.batchExtractFilesSync(listOf(BatchFileItem(java.nio.file.Paths.get("text/plain.txt"), null), BatchFileItem(java.nio.file.Paths.get("/nonexistent/missing.pdf"), null)), ExtractionConfig())
    }

    @Test
    fun testBatchFileSyncBasic() = runBlocking {
        // Extract text from multiple files synchronously
        val result = Kreuzberg.batchExtractFilesSync(listOf(BatchFileItem(java.nio.file.Paths.get("pdf/fake_memo.pdf"), null), BatchFileItem(java.nio.file.Paths.get("text/fake_text.txt"), null)), ExtractionConfig())
    }

}
