Search in sources :

Example 11 with VaporReference

use of com.google.api.generator.engine.ast.VaporReference in project gapic-generator-java by googleapis.

the class JavaWriterVisitorTest method writeThisObjectValue_methodReturn.

@Test
public void writeThisObjectValue_methodReturn() {
    VaporReference ref = VaporReference.builder().setName("Student").setPakkage("com.google.example.v1").build();
    TypeNode classType = TypeNode.withReference(ref);
    MethodDefinition methodDefinition = MethodDefinition.builder().setName("apply").setScope(ScopeNode.PUBLIC).setReturnType(TypeNode.withReference(ref)).setReturnExpr(ValueExpr.builder().setValue(ThisObjectValue.withType(classType)).build()).build();
    methodDefinition.accept(writerVisitor);
    assertEquals(LineFormatter.lines("public Student apply() {\n", "return this;\n", "}\n\n"), writerVisitor.write());
}
Also used : MethodDefinition(com.google.api.generator.engine.ast.MethodDefinition) VaporReference(com.google.api.generator.engine.ast.VaporReference) TypeNode(com.google.api.generator.engine.ast.TypeNode) Test(org.junit.Test)

Aggregations

VaporReference (com.google.api.generator.engine.ast.VaporReference)11 TypeNode (com.google.api.generator.engine.ast.TypeNode)10 Test (org.junit.Test)9 VariableExpr (com.google.api.generator.engine.ast.VariableExpr)7 MethodInvocationExpr (com.google.api.generator.engine.ast.MethodInvocationExpr)5 ReferenceConstructorExpr (com.google.api.generator.engine.ast.ReferenceConstructorExpr)5 AssignmentExpr (com.google.api.generator.engine.ast.AssignmentExpr)4 ValueExpr (com.google.api.generator.engine.ast.ValueExpr)3 Variable (com.google.api.generator.engine.ast.Variable)3 MethodDefinition (com.google.api.generator.engine.ast.MethodDefinition)2 NewObjectExpr (com.google.api.generator.engine.ast.NewObjectExpr)2 SuperObjectValue (com.google.api.generator.engine.ast.SuperObjectValue)2 HttpJsonOperationSnapshotCallable (com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable)1 OperationCallable (com.google.api.gax.rpc.OperationCallable)1 UnaryCallable (com.google.api.gax.rpc.UnaryCallable)1 AnnotationNode (com.google.api.generator.engine.ast.AnnotationNode)1 ExprStatement (com.google.api.generator.engine.ast.ExprStatement)1 LogicalOperationExpr (com.google.api.generator.engine.ast.LogicalOperationExpr)1 Statement (com.google.api.generator.engine.ast.Statement)1 ThisObjectValue (com.google.api.generator.engine.ast.ThisObjectValue)1