use of com.google.api.generator.engine.ast.SuperObjectValue in project gapic-generator-java by googleapis.
the class JavaWriterVisitorTest method writeSuperObjectValue_accessFieldAndInvokeMethod.
@Test
public void writeSuperObjectValue_accessFieldAndInvokeMethod() {
VaporReference ref = VaporReference.builder().setName("Student").setPakkage("com.google.example.v1").build();
TypeNode classType = TypeNode.withReference(ref);
SuperObjectValue superObjectValue = SuperObjectValue.withType(classType);
ValueExpr superValueExpr = ValueExpr.withValue(superObjectValue);
Variable subVariable = Variable.builder().setName("name").setType(TypeNode.STRING).build();
VariableExpr superVariableExpr = VariableExpr.builder().setVariable(subVariable).setExprReferenceExpr(superValueExpr).build();
MethodInvocationExpr methodExpr = MethodInvocationExpr.builder().setMethodName("getName").setExprReferenceExpr(ValueExpr.withValue(superObjectValue)).setReturnType(TypeNode.STRING).build();
AssignmentExpr assignmentExpr = AssignmentExpr.builder().setVariableExpr(superVariableExpr).setValueExpr(methodExpr).build();
assignmentExpr.accept(writerVisitor);
assertThat(writerVisitor.write()).isEqualTo("super.name = super.getName()");
}
use of com.google.api.generator.engine.ast.SuperObjectValue in project gapic-generator-java by googleapis.
the class ImportWriterVisitorTest method writeSuperObjectValueImports.
@Test
public void writeSuperObjectValueImports() {
VaporReference ref = VaporReference.builder().setName("Student").setPakkage("com.google.example.examples.v1").build();
TypeNode typeNode = TypeNode.withReference(ref);
SuperObjectValue superObjectValue = SuperObjectValue.withType(typeNode);
MethodInvocationExpr methodExpr = MethodInvocationExpr.builder().setMethodName("getName").setExprReferenceExpr(ValueExpr.withValue(superObjectValue)).setReturnType(TypeNode.STRING).build();
methodExpr.accept(writerVisitor);
assertEquals("import com.google.example.examples.v1.Student;\n\n", writerVisitor.write());
}
Aggregations