*** Settings ***
Documentation    Smoke tests for UKO Indexer Real-time Index Synchronization
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER}    ${CURDIR}/helper_uko_indexer.py

*** Test Cases ***
Index Resource Pipeline
    [Documentation]    Verify UKOIndexer indexes a resource into graph, text, and vector backends
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    index-resource    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    uko-indexer-index-resource-ok

Remove Resource Cleanup
    [Documentation]    Verify UKOIndexer removes a resource from all indices
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    remove-resource    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    uko-indexer-remove-resource-ok

Reindex Resource Lifecycle
    [Documentation]    Verify reindex_resource removes old data then re-indexes
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    reindex-resource    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    uko-indexer-reindex-resource-ok

Graceful Degradation Without Optional Backends
    [Documentation]    Verify indexing works without text and vector backends
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    graceful-degradation    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    uko-indexer-graceful-degradation-ok

Provenance Metadata Attached
    [Documentation]    Verify provenance metadata is attached to indexed triples
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    provenance    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    uko-indexer-provenance-ok

Index Backend Operations
    [Documentation]    Verify in-memory text, vector, and graph backend CRUD operations
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    index-backends    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    uko-indexer-index-backends-ok

Input Validation Guards
    [Documentation]    Verify validation rejects empty project, empty resource_id, invalid types
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    validation    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    uko-indexer-validation-ok

Protocol Compliance
    [Documentation]    Verify ContentReader and IndexLifecycleHook protocol compliance
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    protocol-compliance    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    uko-indexer-protocol-compliance-ok

File Watching
    [Documentation]    Verify ResourceFileWatcher lifecycle, change detection, and EventBus
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    file-watching    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    uko-indexer-file-watching-ok
