*** Settings ***
Documentation    Integration tests verifying A2aRequest/A2aResponse produce
...              JSON-RPC 2.0 compliant wire frames end-to-end.
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
A2A Request Wire Frame Is JSON-RPC 2.0 Compliant
    [Documentation]    Verify A2aRequest serialises to JSON-RPC 2.0 wire format
    ...                with jsonrpc, id, method, params fields and no non-standard fields.
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    request-wire-format    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-request-wire-format-ok

A2A Response Success Wire Frame Is JSON-RPC 2.0 Compliant
    [Documentation]    Verify A2aResponse (success) serialises to JSON-RPC 2.0 wire format
    ...                with jsonrpc, id, result fields and no non-standard fields.
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    response-success-wire-format    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-response-success-wire-format-ok

A2A Response Error Wire Frame Is JSON-RPC 2.0 Compliant
    [Documentation]    Verify A2aResponse (error) serialises to JSON-RPC 2.0 wire format
    ...                with jsonrpc, id, error fields and no non-standard fields.
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    response-error-wire-format    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-response-error-wire-format-ok

A2A Facade Dispatch Produces JSON-RPC 2.0 Response
    [Documentation]    Verify end-to-end: facade.dispatch() returns a response
    ...                with jsonrpc="2.0", id matching the request, and result set.
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    facade-dispatch-jsonrpc    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-facade-dispatch-jsonrpc-ok

A2A Request Deserialises From JSON-RPC 2.0 Payload
    [Documentation]    Verify A2aRequest can be constructed from a JSON-RPC 2.0 dict
    ...                (simulating inbound network payload).
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    request-deserialise    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-request-deserialise-ok

A2A Response Deserialises From JSON-RPC 2.0 Payload
    [Documentation]    Verify A2aResponse can be constructed from a JSON-RPC 2.0 dict
    ...                (simulating inbound network payload).
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    response-deserialise    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-response-deserialise-ok

A2A Request Rejects Non-Standard Field Names
    [Documentation]    Verify that A2aRequest no longer accepts old non-standard
    ...                field names (a2a_version, request_id, operation).
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    request-rejects-old-fields    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    a2a-request-rejects-old-fields-ok
