|
62 | 62 | import java.io.FileNotFoundException;
|
63 | 63 | import java.io.FileOutputStream;
|
64 | 64 | import java.io.IOException;
|
| 65 | +import java.lang.annotation.Repeatable; |
65 | 66 | import java.util.ArrayList;
|
66 | 67 | import java.util.Arrays;
|
67 | 68 | import java.util.HashMap;
|
@@ -390,6 +391,43 @@ public void writeVariableExprImports_withAnnotations() {
|
390 | 391 | writerVisitor.write());
|
391 | 392 | }
|
392 | 393 |
|
| 394 | + @Test |
| 395 | + public void writeVariableExprImports_annotationsWithDescription() { |
| 396 | + Variable variable = |
| 397 | + Variable.builder() |
| 398 | + .setName("expr") |
| 399 | + .setType(TypeNode.withReference(ConcreteReference.withClazz(Expr.class))) |
| 400 | + .build(); |
| 401 | + |
| 402 | + VariableExpr annotationDescription = |
| 403 | + VariableExpr.builder() |
| 404 | + .setVariable(Variable.builder().setType(TypeNode.CLASS_OBJECT).setName("class").build()) |
| 405 | + .setStaticReferenceType(TypeNode.withReference(ConcreteReference.withClazz(List.class))) |
| 406 | + .build(); |
| 407 | + |
| 408 | + // Constructs with annotation @Repeatable(List.class) |
| 409 | + VariableExpr variableExpr = |
| 410 | + VariableExpr.builder() |
| 411 | + .setVariable(variable) |
| 412 | + .setIsDecl(true) |
| 413 | + .setAnnotations( |
| 414 | + Arrays.asList( |
| 415 | + AnnotationNode.builder() |
| 416 | + .setType( |
| 417 | + TypeNode.withReference(ConcreteReference.withClazz(Repeatable.class))) |
| 418 | + .setDescription(annotationDescription) |
| 419 | + .build())) |
| 420 | + .build(); |
| 421 | + |
| 422 | + variableExpr.accept(writerVisitor); |
| 423 | + assertEquals( |
| 424 | + LineFormatter.lines( |
| 425 | + "import com.google.api.generator.engine.ast.Expr;\n", |
| 426 | + "import java.lang.annotation.Repeatable;\n", |
| 427 | + "import java.util.List;\n\n"), |
| 428 | + writerVisitor.write()); |
| 429 | + } |
| 430 | + |
393 | 431 | @Test
|
394 | 432 | public void writeAnonymousClassExprImports() {
|
395 | 433 | // [Constructing] Function<List<IOException>, MethodDefinition>
|
|
0 commit comments