@@ -66,7 +66,7 @@ TEST_F(ServiceSchemaTest, Programs) {
6666 EXPECT_EQ (programs.size (), 3 );
6767
6868 auto & mainProgram = syntaxGraph.findProgramByName (" syntax_graph" );
69- EXPECT_EQ (mainProgram.definitionsByName ().size (), 15 );
69+ EXPECT_EQ (mainProgram.definitionsByName ().size (), 16 );
7070 EXPECT_EQ (mainProgram.namespaces ().size (), 1 );
7171 EXPECT_EQ (
7272 mainProgram.namespaces ().at (" cpp2" ), " apache.thrift.syntax_graph.test" );
@@ -578,7 +578,7 @@ TEST_F(ServiceSchemaTest, Interaction) {
578578
579579void checkAnnotationsOnTestUnion (const UnionNode& node) {
580580 const auto & annotations = node.definition ().annotations ();
581- EXPECT_EQ (annotations.size (), 1 );
581+ EXPECT_EQ (annotations.size (), 2 );
582582 EXPECT_EQ (
583583 &annotations[0 ].type ().asStruct (),
584584 &node.definition ()
@@ -591,6 +591,18 @@ void checkAnnotationsOnTestUnion(const UnionNode& node) {
591591 EXPECT_TRUE (annotations[0 ].value ()[" field2" ].isObject ());
592592 const auto & innerField = annotations[0 ].value ()[" field2" ];
593593 EXPECT_EQ (innerField[" field1" ].asInt (), 4 );
594+
595+ EXPECT_EQ (
596+ &annotations[1 ].type ().asStruct (),
597+ &node.definition ()
598+ .program ()
599+ .definitionsByName ()
600+ .at (" ComplexAnnotation" )
601+ ->asStruct ());
602+ EXPECT_EQ (annotations[1 ].value ().size (), 3 );
603+ EXPECT_EQ (annotations[1 ].value ()[" l" ][0 ][" field1" ].asInt (), 1 );
604+ EXPECT_EQ (annotations[1 ].value ()[" s" ][0 ], " foo" );
605+ EXPECT_EQ (annotations[1 ].value ()[" m" ][" bar" ][" field1" ].asInt (), 2 );
594606}
595607
596608TEST_F (ServiceSchemaTest, StructuredAnnotation) {
@@ -795,12 +807,39 @@ TEST_F(ServiceSchemaTest, asTypeSystem) {
795807 &mainProgram.definitionsByName ().at (" TestUnion" )->asUnion (),
796808 &sgUnionNode);
797809 checkAnnotationsOnTestUnion (sgUnionNode);
798- const auto & annot = *unionNode.getAnnotationOrNull (
799- " meta.com/thrift_test/TestStructuredAnnotation" );
800- EXPECT_EQ (annot.asFieldSet ().at (FieldId{1 }).asInt64 (), 3 );
801- EXPECT_EQ (
802- annot.asFieldSet ().at (FieldId{2 }).asFieldSet ().at (FieldId{1 }).asInt64 (),
803- 4 );
810+ {
811+ const auto & annot = *unionNode.getAnnotationOrNull (
812+ " meta.com/thrift_test/TestStructuredAnnotation" );
813+ EXPECT_EQ (annot.asFieldSet ().at (FieldId{1 }).asInt64 (), 3 );
814+ EXPECT_EQ (
815+ annot.asFieldSet ().at (FieldId{2 }).asFieldSet ().at (FieldId{1 }).asInt64 (),
816+ 4 );
817+ }
818+ {
819+ const auto & annot = *unionNode.getAnnotationOrNull (
820+ " meta.com/thrift_test/ComplexAnnotation" );
821+ EXPECT_EQ (
822+ annot.asFieldSet ()
823+ .at (FieldId{1 })
824+ .asList ()[0 ]
825+ .asFieldSet ()
826+ .at (FieldId{1 })
827+ .asInt64 (),
828+ 1 );
829+ EXPECT_TRUE (annot.asFieldSet ()
830+ .at (FieldId{2 })
831+ .asSet ()
832+ .contains (type_system::SerializableRecord::Text (" foo" )));
833+ EXPECT_EQ (
834+ annot.asFieldSet ()
835+ .at (FieldId{3 })
836+ .asMap ()
837+ .at (type_system::SerializableRecord::Text (" bar" ))
838+ .asFieldSet ()
839+ .at (FieldId{1 })
840+ .asInt64 (),
841+ 2 );
842+ }
804843
805844 uri = " meta.com/thrift_test/TestEnum" ;
806845 const type_system::EnumNode& enumNode =
0 commit comments