Search in sources :

Example 1 with UnaryOperationExpr

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

the class ImportWriterVisitorTest method writeUnaryOperationExprImports_LogicalNot.

@Test
public void writeUnaryOperationExprImports_LogicalNot() {
    MethodInvocationExpr expr = MethodInvocationExpr.builder().setStaticReferenceType(TypeNode.withReference(ConcreteReference.withClazz(Expr.class))).setMethodName("isEmpty").setReturnType(TypeNode.BOOLEAN).build();
    UnaryOperationExpr unaryOperationExpr = UnaryOperationExpr.logicalNotWithExpr(expr);
    unaryOperationExpr.accept(writerVisitor);
    assertEquals("import com.google.api.generator.engine.ast.Expr;\n\n", writerVisitor.write());
}
Also used : ReferenceConstructorExpr(com.google.api.generator.engine.ast.ReferenceConstructorExpr) LogicalOperationExpr(com.google.api.generator.engine.ast.LogicalOperationExpr) ValueExpr(com.google.api.generator.engine.ast.ValueExpr) EnumRefExpr(com.google.api.generator.engine.ast.EnumRefExpr) ReturnExpr(com.google.api.generator.engine.ast.ReturnExpr) NewObjectExpr(com.google.api.generator.engine.ast.NewObjectExpr) Expr(com.google.api.generator.engine.ast.Expr) TernaryExpr(com.google.api.generator.engine.ast.TernaryExpr) RelationalOperationExpr(com.google.api.generator.engine.ast.RelationalOperationExpr) UnaryOperationExpr(com.google.api.generator.engine.ast.UnaryOperationExpr) AssignmentExpr(com.google.api.generator.engine.ast.AssignmentExpr) VariableExpr(com.google.api.generator.engine.ast.VariableExpr) InstanceofExpr(com.google.api.generator.engine.ast.InstanceofExpr) ArithmeticOperationExpr(com.google.api.generator.engine.ast.ArithmeticOperationExpr) AnonymousClassExpr(com.google.api.generator.engine.ast.AnonymousClassExpr) LambdaExpr(com.google.api.generator.engine.ast.LambdaExpr) MethodInvocationExpr(com.google.api.generator.engine.ast.MethodInvocationExpr) ThrowExpr(com.google.api.generator.engine.ast.ThrowExpr) MethodInvocationExpr(com.google.api.generator.engine.ast.MethodInvocationExpr) UnaryOperationExpr(com.google.api.generator.engine.ast.UnaryOperationExpr) Test(org.junit.Test)

Example 2 with UnaryOperationExpr

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

the class ImportWriterVisitorTest method writeUnaryOperationExprImports_PostIncrement.

@Test
public void writeUnaryOperationExprImports_PostIncrement() {
    MethodInvocationExpr expr = MethodInvocationExpr.builder().setStaticReferenceType(TypeNode.withReference(ConcreteReference.withClazz(Expr.class))).setMethodName("getNumber").setReturnType(TypeNode.INT).build();
    UnaryOperationExpr unaryOperationExpr = UnaryOperationExpr.postfixIncrementWithExpr(expr);
    unaryOperationExpr.accept(writerVisitor);
    assertEquals("import com.google.api.generator.engine.ast.Expr;\n\n", writerVisitor.write());
}
Also used : ReferenceConstructorExpr(com.google.api.generator.engine.ast.ReferenceConstructorExpr) LogicalOperationExpr(com.google.api.generator.engine.ast.LogicalOperationExpr) ValueExpr(com.google.api.generator.engine.ast.ValueExpr) EnumRefExpr(com.google.api.generator.engine.ast.EnumRefExpr) ReturnExpr(com.google.api.generator.engine.ast.ReturnExpr) NewObjectExpr(com.google.api.generator.engine.ast.NewObjectExpr) Expr(com.google.api.generator.engine.ast.Expr) TernaryExpr(com.google.api.generator.engine.ast.TernaryExpr) RelationalOperationExpr(com.google.api.generator.engine.ast.RelationalOperationExpr) UnaryOperationExpr(com.google.api.generator.engine.ast.UnaryOperationExpr) AssignmentExpr(com.google.api.generator.engine.ast.AssignmentExpr) VariableExpr(com.google.api.generator.engine.ast.VariableExpr) InstanceofExpr(com.google.api.generator.engine.ast.InstanceofExpr) ArithmeticOperationExpr(com.google.api.generator.engine.ast.ArithmeticOperationExpr) AnonymousClassExpr(com.google.api.generator.engine.ast.AnonymousClassExpr) LambdaExpr(com.google.api.generator.engine.ast.LambdaExpr) MethodInvocationExpr(com.google.api.generator.engine.ast.MethodInvocationExpr) ThrowExpr(com.google.api.generator.engine.ast.ThrowExpr) MethodInvocationExpr(com.google.api.generator.engine.ast.MethodInvocationExpr) UnaryOperationExpr(com.google.api.generator.engine.ast.UnaryOperationExpr) Test(org.junit.Test)

Example 3 with UnaryOperationExpr

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

the class JavaWriterVisitorTest method writeUnaryOperationExpr_postfixIncrement.

@Test
public void writeUnaryOperationExpr_postfixIncrement() {
    VariableExpr variableExpr = VariableExpr.withVariable(Variable.builder().setType(TypeNode.INT).setName("i").build());
    UnaryOperationExpr postIncrementOperationExpr = UnaryOperationExpr.postfixIncrementWithExpr(variableExpr);
    postIncrementOperationExpr.accept(writerVisitor);
    assertThat(writerVisitor.write()).isEqualTo("i++");
}
Also used : VariableExpr(com.google.api.generator.engine.ast.VariableExpr) UnaryOperationExpr(com.google.api.generator.engine.ast.UnaryOperationExpr) Test(org.junit.Test)

Example 4 with UnaryOperationExpr

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

the class JavaWriterVisitorTest method writeUnaryOperationExpr_logicalNot.

@Test
public void writeUnaryOperationExpr_logicalNot() {
    MethodInvocationExpr methodInvocationExpr = MethodInvocationExpr.builder().setMethodName("isEmpty").setReturnType(TypeNode.BOOLEAN).build();
    UnaryOperationExpr logicalNotOperationExpr = UnaryOperationExpr.logicalNotWithExpr(methodInvocationExpr);
    logicalNotOperationExpr.accept(writerVisitor);
    assertThat(writerVisitor.write()).isEqualTo("!isEmpty()");
}
Also used : MethodInvocationExpr(com.google.api.generator.engine.ast.MethodInvocationExpr) UnaryOperationExpr(com.google.api.generator.engine.ast.UnaryOperationExpr) Test(org.junit.Test)

Aggregations

UnaryOperationExpr (com.google.api.generator.engine.ast.UnaryOperationExpr)4 Test (org.junit.Test)4 MethodInvocationExpr (com.google.api.generator.engine.ast.MethodInvocationExpr)3 VariableExpr (com.google.api.generator.engine.ast.VariableExpr)3 AnonymousClassExpr (com.google.api.generator.engine.ast.AnonymousClassExpr)2 ArithmeticOperationExpr (com.google.api.generator.engine.ast.ArithmeticOperationExpr)2 AssignmentExpr (com.google.api.generator.engine.ast.AssignmentExpr)2 EnumRefExpr (com.google.api.generator.engine.ast.EnumRefExpr)2 Expr (com.google.api.generator.engine.ast.Expr)2 InstanceofExpr (com.google.api.generator.engine.ast.InstanceofExpr)2 LambdaExpr (com.google.api.generator.engine.ast.LambdaExpr)2 LogicalOperationExpr (com.google.api.generator.engine.ast.LogicalOperationExpr)2 NewObjectExpr (com.google.api.generator.engine.ast.NewObjectExpr)2 ReferenceConstructorExpr (com.google.api.generator.engine.ast.ReferenceConstructorExpr)2 RelationalOperationExpr (com.google.api.generator.engine.ast.RelationalOperationExpr)2 ReturnExpr (com.google.api.generator.engine.ast.ReturnExpr)2 TernaryExpr (com.google.api.generator.engine.ast.TernaryExpr)2 ThrowExpr (com.google.api.generator.engine.ast.ThrowExpr)2 ValueExpr (com.google.api.generator.engine.ast.ValueExpr)2