|
16 | 16 |
|
17 | 17 | package com.google.firebase.ai |
18 | 18 |
|
| 19 | +import com.google.firebase.ai.common.TemplateGenerateContentRequest |
| 20 | +import com.google.firebase.ai.common.TemplateGenerateImageRequest |
19 | 21 | import com.google.firebase.ai.common.util.descriptorToJson |
20 | 22 | import com.google.firebase.ai.type.Candidate |
21 | 23 | import com.google.firebase.ai.type.CountTokensResponse |
@@ -512,6 +514,56 @@ internal class SerializationTests { |
512 | 514 | expectedJsonAsString shouldEqualJson actualJson.toString() |
513 | 515 | } |
514 | 516 |
|
| 517 | + @Test |
| 518 | + fun `test template request serialization as Json`() { |
| 519 | + val expectedJsonAsString = |
| 520 | + """ |
| 521 | + { |
| 522 | + "id": "TemplateGenerateContentRequest", |
| 523 | + "type": "object", |
| 524 | + "properties": { |
| 525 | + "inputs": { |
| 526 | + "type": "object", |
| 527 | + "additionalProperties": { |
| 528 | + "${"$"}ref": "JsonElement" |
| 529 | + } |
| 530 | + }, |
| 531 | + "history": { |
| 532 | + "type": "array", |
| 533 | + "items": { |
| 534 | + "${"$"}ref": "Content" |
| 535 | + } |
| 536 | + } |
| 537 | + } |
| 538 | + } |
| 539 | + """ |
| 540 | + .trimIndent() |
| 541 | + val actualJson = descriptorToJson(TemplateGenerateContentRequest.serializer().descriptor) |
| 542 | + expectedJsonAsString shouldEqualJson actualJson.toString() |
| 543 | + } |
| 544 | + |
| 545 | + @Test |
| 546 | + fun `test template imagen request serialization as Json`() { |
| 547 | + val expectedJsonAsString = |
| 548 | + """ |
| 549 | + { |
| 550 | + "id": "TemplateGenerateImageRequest", |
| 551 | + "type": "object", |
| 552 | + "properties": { |
| 553 | + "inputs": { |
| 554 | + "type": "object", |
| 555 | + "additionalProperties": { |
| 556 | + "${"$"}ref": "JsonElement" |
| 557 | + } |
| 558 | + } |
| 559 | + } |
| 560 | + } |
| 561 | + """ |
| 562 | + .trimIndent() |
| 563 | + val actualJson = descriptorToJson(TemplateGenerateImageRequest.serializer().descriptor) |
| 564 | + expectedJsonAsString shouldEqualJson actualJson.toString() |
| 565 | + } |
| 566 | + |
515 | 567 | @Test |
516 | 568 | fun `test GoogleSearch serialization as Json`() { |
517 | 569 | val expectedJsonAsString = |
|
0 commit comments