@@ -202,6 +202,10 @@ public void testDelCall_delVariant() throws IOException {
202202 factory .create (TemplateTester .asRecord (ImmutableMap .of ("variant" , "unknown" )), EMPTY_DICT )
203203 .render (builder , context ));
204204 assertThat (builder .toString ()).isEmpty ();
205+
206+ TemplateMetadata templateMetadata = getTemplateMetadata (templates , "ns1.callerTemplate" );
207+ assertThat (templateMetadata .callees ()).isEmpty ();
208+ assertThat (templateMetadata .delCallees ()).asList ().containsExactly ("ns1.del" );
205209 }
206210
207211 public void testCallBasicNode () throws IOException {
@@ -251,21 +255,30 @@ public void testCallBasicNode() throws IOException {
251255 params .setField ("boo" , StringData .forValue ("boo" ));
252256 assertThat (render (templates , params , "ns.callerDataAll" )).isEqualTo ("Foo: foo\n Boo: boo\n " );
253257
258+ assertThat (getTemplateMetadata (templates , "ns.callerDataAll" ).callees ()).asList ().containsExactly ("ns.callee" );
259+
254260 params = new BasicParamStore (2 );
255261 params .setField ("rec" , new BasicParamStore (2 ).setField ("foo" , StringData .forValue ("foo" )));
256262 assertThat (render (templates , params , "ns.callerDataExpr" )).isEqualTo ("Foo: foo\n Boo: null\n " );
257263 ((ParamStore ) params .getField ("rec" )).setField ("boo" , StringData .forValue ("boo" ));
258264 assertThat (render (templates , params , "ns.callerDataExpr" )).isEqualTo ("Foo: foo\n Boo: boo\n " );
265+ assertThat (getTemplateMetadata (templates , "ns.callerDataExpr" ).callees ()).asList ().containsExactly ("ns.callee" );
259266
260267 params = new BasicParamStore (2 );
261268 params .setField ("p1" , StringData .forValue ("foo" ));
262269 assertThat (render (templates , params , "ns.callerParams" )).isEqualTo ("Foo: foo\n Boo: a1b\n " );
270+ assertThat (getTemplateMetadata (templates , "ns.callerParams" ).callees ()).asList ().containsExactly ("ns.callee" );
263271
264272 params = new BasicParamStore (2 );
265273 params .setField ("p1" , StringData .forValue ("foo" ));
266274 params .setField ("boo" , StringData .forValue ("boo" ));
267275 assertThat (render (templates , params , "ns.callerParamsAndData" ))
268276 .isEqualTo ("Foo: foo\n Boo: boo\n " );
277+ assertThat (getTemplateMetadata (templates , "ns.callerParamsAndData" ).callees ()).asList ().containsExactly ("ns.callee" );
278+ }
279+
280+ private static TemplateMetadata getTemplateMetadata (CompiledTemplates templates , String name ) {
281+ return templates .getTemplateFactory (name ).getClass ().getDeclaringClass ().getAnnotation (TemplateMetadata .class );
269282 }
270283
271284 private String render (CompiledTemplates templates , SoyRecord params , String name )
@@ -655,6 +668,11 @@ public void testParamFields() throws Exception {
655668 assertEquals (StringData .forValue ("foo" ), getField ("foo" , template ));
656669 assertEquals (StringData .forValue ("bar" ), getField ("bar" , template ));
657670 assertEquals (StringData .forValue ("baz" ), getField ("baz" , template ));
671+
672+ TemplateMetadata templateMetadata = template .getClass ().getAnnotation (TemplateMetadata .class );
673+ assertThat (templateMetadata .injectedParams ()).asList ().containsExactly ("bar" );
674+ assertThat (templateMetadata .callees ()).isEmpty ();
675+ assertThat (templateMetadata .delCallees ()).isEmpty ();
658676 }
659677
660678 private Object getField (String name , CompiledTemplate template ) throws Exception {
@@ -674,7 +692,12 @@ public void testBasicFunctionality() {
674692 factory .create (EMPTY_DICT , EMPTY_DICT ).getClass ();
675693 assertEquals ("com.google.template.soy.jbcsrc.gen.ns.foo" , templateClass .getName ());
676694 assertEquals ("foo" , templateClass .getSimpleName ());
677- assertEquals ("HTML" , templateClass .getAnnotation (TemplateMetadata .class ).contentKind ());
695+
696+ TemplateMetadata templateMetadata = templateClass .getAnnotation (TemplateMetadata .class );
697+ assertEquals ("HTML" , templateMetadata .contentKind ());
698+ assertThat (templateMetadata .injectedParams ()).isEmpty ();
699+ assertThat (templateMetadata .callees ()).isEmpty ();
700+ assertThat (templateMetadata .delCallees ()).isEmpty ();
678701
679702 // ensure that the factory is an inner class of the template.
680703 assertEquals (templateClass , factory .getClass ().getEnclosingClass ());
0 commit comments