1313import java .util .concurrent .CompletionStage ;
1414import java .util .concurrent .TimeUnit ;
1515
16+ import org .jboss .jandex .AnnotationInstance ;
17+ import org .jboss .jandex .AnnotationValue ;
1618import org .jboss .jandex .ClassInfo ;
1719import org .jboss .jandex .DotName ;
1820import org .jboss .jandex .Index ;
@@ -39,15 +41,16 @@ public class SimpleGeneratorTest {
3941 public static void init () throws IOException {
4042 TestClassOutput classOutput = new TestClassOutput ();
4143 Index index = index (MyService .class , PublicMyService .class , BaseService .class , MyItem .class , String .class ,
42- CompletionStage .class , List .class , MyEnum .class );
44+ CompletionStage .class , List .class , MyEnum .class , StringBuilder . class );
4345 ClassInfo myServiceClazz = index .getClassByName (DotName .createSimple (MyService .class .getName ()));
4446 ValueResolverGenerator generator = ValueResolverGenerator .builder ().setIndex (index ).setClassOutput (classOutput )
4547 .addClass (myServiceClazz )
46- .addClass (index .getClassByName (DotName .createSimple (PublicMyService .class .getName ())))
47- .addClass (index .getClassByName (DotName .createSimple (MyItem .class .getName ())))
48- .addClass (index .getClassByName (DotName .createSimple (String .class .getName ())))
49- .addClass (index .getClassByName (DotName .createSimple (List .class .getName ())))
50- .addClass (index .getClassByName (DotName .createSimple (MyEnum .class .getName ())))
48+ .addClass (index .getClassByName (PublicMyService .class ))
49+ .addClass (index .getClassByName (MyItem .class ))
50+ .addClass (index .getClassByName (String .class ))
51+ .addClass (index .getClassByName (List .class ))
52+ .addClass (index .getClassByName (MyEnum .class ))
53+ .addClass (index .getClassByName (StringBuilder .class ), stringBuilderTemplateData ())
5154 .build ();
5255
5356 generator .generate ();
@@ -146,6 +149,7 @@ public void testWithEngine() throws Exception {
146149 assertEquals ("OK" , engine .parse ("{#if enum is MyEnum:BAR}OK{/if}" ).data ("enum" , MyEnum .BAR ).render ());
147150 assertEquals ("one" , engine .parse ("{MyEnum:valueOf('ONE').name}" ).render ());
148151 assertEquals ("10" , engine .parse ("{io_quarkus_qute_generator_MyService:getDummy(5)}" ).render ());
152+ assertEquals ("foo" , engine .parse ("{builder.append('foo')}" ).data ("builder" , new StringBuilder ()).render ());
149153 }
150154
151155 @ Test
@@ -192,4 +196,15 @@ public static Index index(Class<?>... classes) throws IOException {
192196 return indexer .complete ();
193197 }
194198
199+ private static AnnotationInstance stringBuilderTemplateData () {
200+ AnnotationValue ignoreValue = AnnotationValue .createArrayValue (ValueResolverGenerator .IGNORE , new AnnotationValue [] {});
201+ AnnotationValue targetValue = AnnotationValue .createClassValue ("target" ,
202+ Type .create (ValueResolverGenerator .TEMPLATE_DATA , Kind .CLASS ));
203+ AnnotationValue propertiesValue = AnnotationValue .createBooleanValue (ValueResolverGenerator .PROPERTIES , false );
204+ AnnotationValue ignoreSuperclassesValue = AnnotationValue .createBooleanValue (ValueResolverGenerator .IGNORE_SUPERCLASSES ,
205+ true );
206+ return AnnotationInstance .create (ValueResolverGenerator .TEMPLATE_DATA , null ,
207+ new AnnotationValue [] { targetValue , ignoreValue , propertiesValue , ignoreSuperclassesValue });
208+ }
209+
195210}
0 commit comments