*** Settings ***
Documentation    Integration tests for A2A local facade wiring to live services
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Wired Facade Session Create
    [Documentation]    Verify session.create routes to SessionService
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    wired-session-create    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-wired-session-create-ok

Wired Facade Session Close
    [Documentation]    Verify session.close routes to SessionService
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    wired-session-close    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-wired-session-close-ok

Wired Facade Plan Create
    [Documentation]    Verify plan.create routes to PlanLifecycleService
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    wired-plan-create    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-wired-plan-create-ok

Wired Facade Plan Status
    [Documentation]    Verify plan.status routes to PlanLifecycleService
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    wired-plan-status    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-wired-plan-status-ok

Wired Facade Registry Tools
    [Documentation]    Verify registry.list_tools routes to ToolRegistry
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    wired-registry-tools    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-wired-registry-tools-ok

Wired Facade Registry Resources
    [Documentation]    Verify registry.list_resources routes to ResourceRegistryService
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    wired-registry-resources    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-wired-registry-resources-ok

Wired Facade Context Stub
    [Documentation]    Verify context.get returns stub while ACMS pipeline is pending
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    wired-context-stub    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-wired-context-stub-ok

Wired Facade Event Subscribe
    [Documentation]    Verify event.subscribe routes to A2aEventQueue
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    wired-event-subscribe    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-wired-event-subscribe-ok

Wired Facade Error Mapping
    [Documentation]    Verify domain exceptions map to correct A2A error codes
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    wired-error-mapping    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-wired-error-mapping-ok
