fun testFullAgentCardSerialization()

in a2a/a2a-core/src/commonTest/kotlin/ai/koog/a2a/model/AgentCardSerializationTest.kt [72:278]


    fun testFullAgentCardSerialization() {
        val agentCard = AgentCard(
            name = "GeoSpatial Route Planner Agent",
            description = "Provides advanced route planning, traffic analysis, and custom map generation services. This agent can calculate optimal routes, estimate travel times considering real-time traffic, and create personalized maps with points of interest.",
            url = "https://georoute-agent.example.com/a2a/v1",
            additionalInterfaces = listOf(
                AgentInterface(
                    url = "https://georoute-agent.example.com/a2a/v1",
                    transport = TransportProtocol.JSONRPC
                ),
                AgentInterface(
                    url = "https://georoute-agent.example.com/a2a/grpc",
                    transport = TransportProtocol.GRPC
                ),
                AgentInterface(
                    url = "https://georoute-agent.example.com/a2a/json",
                    transport = TransportProtocol.HTTP_JSON_REST
                )
            ),
            provider = AgentProvider(
                organization = "Example Geo Services Inc.",
                url = "https://www.examplegeoservices.com"
            ),
            iconUrl = "https://georoute-agent.example.com/icon.png",
            version = "1.2.0",
            documentationUrl = "https://docs.examplegeoservices.com/georoute-agent/api",
            capabilities = AgentCapabilities(
                streaming = true,
                pushNotifications = true,
                stateTransitionHistory = false
            ),
            securitySchemes = mapOf(
                "google" to OpenIdConnectSecurityScheme(
                    openIdConnectUrl = "https://accounts.google.com/.well-known/openid-configuration"
                )
            ),
            security = listOf(
                mapOf("google" to listOf("openid", "profile", "email"))
            ),
            defaultInputModes = listOf("application/json", "text/plain"),
            defaultOutputModes = listOf("application/json", "image/png"),
            skills = listOf(
                AgentSkill(
                    id = "route-optimizer-traffic",
                    name = "Traffic-Aware Route Optimizer",
                    description = "Calculates the optimal driving route between two or more locations, taking into account real-time traffic conditions, road closures, and user preferences (e.g., avoid tolls, prefer highways).",
                    tags = listOf("maps", "routing", "navigation", "directions", "traffic"),
                    examples = listOf(
                        "Plan a route from '1600 Amphitheatre Parkway, Mountain View, CA' to 'San Francisco International Airport' avoiding tolls.",
                        "{\"origin\": {\"lat\": 37.422, \"lng\": -122.084}, \"destination\": {\"lat\": 37.7749, \"lng\": -122.4194}, \"preferences\": [\"avoid_ferries\"]}"
                    ),
                    inputModes = listOf("application/json", "text/plain"),
                    outputModes = listOf(
                        "application/json",
                        "application/vnd.geo+json",
                        "text/html"
                    )
                ),
                AgentSkill(
                    id = "custom-map-generator",
                    name = "Personalized Map Generator",
                    description = "Creates custom map images or interactive map views based on user-defined points of interest, routes, and style preferences. Can overlay data layers.",
                    tags = listOf("maps", "customization", "visualization", "cartography"),
                    examples = listOf(
                        "Generate a map of my upcoming road trip with all planned stops highlighted.",
                        "Show me a map visualizing all coffee shops within a 1-mile radius of my current location."
                    ),
                    inputModes = listOf("application/json"),
                    outputModes = listOf(
                        "image/png",
                        "image/jpeg",
                        "application/json",
                        "text/html"
                    )
                )
            ),
            supportsAuthenticatedExtendedCard = true,
            signatures = listOf(
                AgentCardSignature(
                    `protected` = "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpPU0UiLCJraWQiOiJrZXktMSIsImprdSI6Imh0dHBzOi8vZXhhbXBsZS5jb20vYWdlbnQvandrcy5qc29uIn0",
                    signature = "QFdkNLNszlGj3z3u0YQGt_T9LixY3qtdQpZmsTdDHDe3fXV9y9-B3m2-XgCpzuhiLt8E0tV6HXoZKHv4GtHgKQ"
                )
            )
        )

        //language=JSON
        val expectedJson = """
        {
            "protocolVersion": "0.3.0",
            "name": "GeoSpatial Route Planner Agent",
            "description": "Provides advanced route planning, traffic analysis, and custom map generation services. This agent can calculate optimal routes, estimate travel times considering real-time traffic, and create personalized maps with points of interest.",
            "url": "https://georoute-agent.example.com/a2a/v1",
            "preferredTransport": "JSONRPC",
            "additionalInterfaces": [
                {
                    "url": "https://georoute-agent.example.com/a2a/v1",
                    "transport": "JSONRPC"
                },
                {
                    "url": "https://georoute-agent.example.com/a2a/grpc",
                    "transport": "GRPC"
                },
                {
                    "url": "https://georoute-agent.example.com/a2a/json",
                    "transport": "HTTP+JSON/REST"
                }
            ],
            "iconUrl": "https://georoute-agent.example.com/icon.png",
            "provider": {
                "organization": "Example Geo Services Inc.",
                "url": "https://www.examplegeoservices.com"
            },
            "version": "1.2.0",
            "documentationUrl": "https://docs.examplegeoservices.com/georoute-agent/api",
            "capabilities": {
                "streaming": true,
                "pushNotifications": true,
                "stateTransitionHistory": false
            },
            "securitySchemes": {
                "google": {
                    "openIdConnectUrl": "https://accounts.google.com/.well-known/openid-configuration",
                    "type": "openIdConnect"
                }
            },
            "security": [
                {
                    "google": [
                        "openid",
                        "profile",
                        "email"
                    ]
                }
            ],
            "defaultInputModes": [
                "application/json",
                "text/plain"
            ],
            "defaultOutputModes": [
                "application/json",
                "image/png"
            ],
            "skills": [
                {
                    "id": "route-optimizer-traffic",
                    "name": "Traffic-Aware Route Optimizer",
                    "description": "Calculates the optimal driving route between two or more locations, taking into account real-time traffic conditions, road closures, and user preferences (e.g., avoid tolls, prefer highways).",
                    "tags": [
                        "maps",
                        "routing",
                        "navigation",
                        "directions",
                        "traffic"
                    ],
                    "examples": [
                        "Plan a route from '1600 Amphitheatre Parkway, Mountain View, CA' to 'San Francisco International Airport' avoiding tolls.",
                        "{\"origin\": {\"lat\": 37.422, \"lng\": -122.084}, \"destination\": {\"lat\": 37.7749, \"lng\": -122.4194}, \"preferences\": [\"avoid_ferries\"]}"
                    ],
                    "inputModes": [
                        "application/json",
                        "text/plain"
                    ],
                    "outputModes": [
                        "application/json",
                        "application/vnd.geo+json",
                        "text/html"
                    ]
                },
                {
                    "id": "custom-map-generator",
                    "name": "Personalized Map Generator",
                    "description": "Creates custom map images or interactive map views based on user-defined points of interest, routes, and style preferences. Can overlay data layers.",
                    "tags": [
                        "maps",
                        "customization",
                        "visualization",
                        "cartography"
                    ],
                    "examples": [
                        "Generate a map of my upcoming road trip with all planned stops highlighted.",
                        "Show me a map visualizing all coffee shops within a 1-mile radius of my current location."
                    ],
                    "inputModes": [
                        "application/json"
                    ],
                    "outputModes": [
                        "image/png",
                        "image/jpeg",
                        "application/json",
                        "text/html"
                    ]
                }
            ],
            "supportsAuthenticatedExtendedCard": true,
            "signatures": [
                {
                    "protected": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpPU0UiLCJraWQiOiJrZXktMSIsImprdSI6Imh0dHBzOi8vZXhhbXBsZS5jb20vYWdlbnQvandrcy5qc29uIn0",
                    "signature": "QFdkNLNszlGj3z3u0YQGt_T9LixY3qtdQpZmsTdDHDe3fXV9y9-B3m2-XgCpzuhiLt8E0tV6HXoZKHv4GtHgKQ"
                }
            ]
        }
        """.trimIndent()

        val actualJson = TestJson.encodeToString(agentCard)

        assertEquals(expectedJson, actualJson)
    }