use of com.google.api.generator.engine.ast.ArithmeticOperationExpr in project gapic-generator-java by googleapis.
the class JavaWriterVisitorTest method writeArithmeticOperationExpr_concatStringWithMethod.
@Test
public void writeArithmeticOperationExpr_concatStringWithMethod() {
ValueExpr lhsExpr = ValueExpr.withValue(StringObjectValue.withValue("someWord"));
MethodInvocationExpr methodInvocationExpr = MethodInvocationExpr.builder().setMethodName("getMethod").build();
MethodInvocationExpr rhsExpr = MethodInvocationExpr.builder().setExprReferenceExpr(methodInvocationExpr).setMethodName("getString").setReturnType(TypeNode.STRING).build();
ArithmeticOperationExpr arithmeticOperationExpr = ArithmeticOperationExpr.concatWithExprs(lhsExpr, rhsExpr);
arithmeticOperationExpr.accept(writerVisitor);
assertThat(writerVisitor.write()).isEqualTo("\"someWord\" + getMethod().getString()");
}
use of com.google.api.generator.engine.ast.ArithmeticOperationExpr in project gapic-generator-java by googleapis.
the class ImportWriterVisitorTest method writeArithmeticOperationExprImports.
@Test
public void writeArithmeticOperationExprImports() {
MethodInvocationExpr lhsExpr = MethodInvocationExpr.builder().setStaticReferenceType(TypeNode.withReference(ConcreteReference.withClazz(Expr.class))).setMethodName("getSomething").setReturnType(TypeNode.STRING).build();
ValueExpr rhsExpr = ValueExpr.createNullExpr();
ArithmeticOperationExpr arithmeticOperationExpr = ArithmeticOperationExpr.concatWithExprs(lhsExpr, rhsExpr);
arithmeticOperationExpr.accept(writerVisitor);
assertEquals("import com.google.api.generator.engine.ast.Expr;\n\n", writerVisitor.write());
}
use of com.google.api.generator.engine.ast.ArithmeticOperationExpr in project gapic-generator-java by googleapis.
the class JavaWriterVisitorTest method writeArithmeticOperationExpr_concatStringWithNumber.
@Test
public void writeArithmeticOperationExpr_concatStringWithNumber() {
ValueExpr rhsExpr = ValueExpr.withValue(PrimitiveValue.builder().setType(TypeNode.INT).setValue("5").build());
ValueExpr lhsExpr = ValueExpr.withValue(StringObjectValue.withValue("someWord"));
ArithmeticOperationExpr arithmeticOperationExpr = ArithmeticOperationExpr.concatWithExprs(lhsExpr, rhsExpr);
arithmeticOperationExpr.accept(writerVisitor);
assertThat(writerVisitor.write()).isEqualTo("\"someWord\" + 5");
}
Aggregations