|
58 | 58 | import com.google.api.generator.test.utils.LineFormatter; |
59 | 59 | import com.google.common.base.Function; |
60 | 60 | import com.google.common.base.Strings; |
| 61 | +import com.google.testgapic.v1beta1.Outer; |
61 | 62 | import java.io.File; |
62 | 63 | import java.io.FileNotFoundException; |
63 | 64 | import java.io.FileOutputStream; |
@@ -428,6 +429,32 @@ public void writeVariableExprImports_annotationsWithDescription() { |
428 | 429 | writerVisitor.write()); |
429 | 430 | } |
430 | 431 |
|
| 432 | + @Test |
| 433 | + public void writeImport_nestedClasses() { |
| 434 | + |
| 435 | + VaporReference nestedVaporReference = |
| 436 | + VaporReference.builder() |
| 437 | + .setName("Inner") |
| 438 | + .setEnclosingClassNames(Arrays.asList("Outer", "Middle")) |
| 439 | + .setPakkage("com.google.testgapic.v1beta1") |
| 440 | + .build(); |
| 441 | + |
| 442 | + TypeNode.withReference(nestedVaporReference).accept(writerVisitor); |
| 443 | + // TODO: The import below causes compilation errors, |
| 444 | + // since JavaWriterVisitor writes the corresponding type as Outer.Middle.Inner |
| 445 | + // Need to change either Writer's behavior to align with the other |
| 446 | + assertEquals("import com.google.testgapic.v1beta1.Outer.Middle;\n\n", writerVisitor.write()); |
| 447 | + |
| 448 | + writerVisitor.clear(); |
| 449 | + |
| 450 | + ConcreteReference nestedConcreteReference = |
| 451 | + ConcreteReference.withClazz(Outer.Middle.Inner.class); |
| 452 | + TypeNode.withReference(nestedConcreteReference).accept(writerVisitor); |
| 453 | + // TODO: This is currently writing import com.google.testgapic.v1beta1.Middle.Outer; |
| 454 | + // which is incorrect - uncomment assertion along with fix |
| 455 | + // assertEquals("import com.google.testgapic.v1beta1.Outer.Middle;\n\n", writerVisitor.write()); |
| 456 | + } |
| 457 | + |
431 | 458 | @Test |
432 | 459 | public void writeAnonymousClassExprImports() { |
433 | 460 | // [Constructing] Function<List<IOException>, MethodDefinition> |
|
0 commit comments