Class AbstractServiceClientTestClassComposer
java.lang.Object
com.google.api.generator.gapic.composer.common.AbstractServiceClientTestClassComposer
- All Implemented Interfaces:
ClassComposer
- Direct Known Subclasses:
ServiceClientTestClassComposer,ServiceClientTestClassComposer
public abstract class AbstractServiceClientTestClassComposer
extends Object
implements ClassComposer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Statementprotected static final TypeStoreprotected static final AnnotationNode -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractServiceClientTestClassComposer(TransportContext transportContext) -
Method Summary
Modifier and TypeMethodDescriptionconstructRpcTestCheckerLogic(Method method, List<MethodArgument> methodSignature, Service service, boolean isRequestArg, Map<String, VariableExpr> classMemberVarExprs, VariableExpr requestVarExpr, Message requestMessage) createClassMemberFieldDecls(Map<String, VariableExpr> classMemberVarExprs) protected abstract Map<String,VariableExpr> createClassMemberVarExprs(Service service, GapicContext context, TypeStore typeStore) protected abstract MethodDefinitioncreateRpcExceptionTestMethod(Method method, Service service, List<MethodArgument> methodSignature, int variantIndex, Map<String, VariableExpr> classMemberVarExprs, Map<String, ResourceName> resourceNames, Map<String, Message> messageTypes) Creates a test method to exercise exceptions for a given RPC, e.g.createRpcExceptionTestStatements(Method method, List<MethodArgument> methodSignature, Map<String, VariableExpr> classMemberVarExprs, Map<String, ResourceName> resourceNames, Map<String, Message> messageTypes) createRpcLroExceptionTestCatchBody(VariableExpr exceptionExpr, boolean isStreaming) protected abstract MethodDefinitioncreateSetUpMethod(Service service, Map<String, VariableExpr> classMemberVarExprs, TypeStore typeStore) protected abstract MethodDefinitioncreateStartStaticServerMethod(Service service, GapicContext context, Map<String, VariableExpr> classMemberVarExprs, TypeStore typeStore, String newBuilderMethod) protected abstract MethodDefinitioncreateStopServerMethod(Service service, Map<String, VariableExpr> classMemberVarExprs) createStreamingRpcExceptionTestStatements(Method method, Map<String, VariableExpr> classMemberVarExprs, Map<String, ResourceName> resourceNames, Map<String, Message> messageTypes) protected abstract MethodDefinitioncreateStreamingRpcTestMethod(Service service, Method method, Map<String, VariableExpr> classMemberVarExprs, Map<String, ResourceName> resourceNames, Map<String, Message> messageTypes) protected abstract MethodDefinitioncreateTearDownMethod(Service service, Map<String, VariableExpr> classMemberVarExprs) protected MethodDefinitioncreateUnsupportedTestMethod(Method method) generate(GapicContext context, Service service) protected GapicClassgenerate(String className, GapicContext context, Service service) protected static StringgetCallableMethodName(Method protoMethod) protected static TypeNodegetCallableType(Method protoMethod) protected StringgetMockServiceVarName(Service service)
-
Field Details
-
EMPTY_LINE_STATEMENT
-
CLIENT_VAR_NAME
- See Also:
-
FIXED_TYPESTORE
-
TEST_ANNOTATION
-
-
Constructor Details
-
AbstractServiceClientTestClassComposer
-
-
Method Details
-
getTransportContext
-
generate
- Specified by:
generatein interfaceClassComposer
-
generate
-
createClassMemberVarExprs
protected abstract Map<String,VariableExpr> createClassMemberVarExprs(Service service, GapicContext context, TypeStore typeStore) -
createClassMemberFieldDecls
-
createStartStaticServerMethod
protected abstract MethodDefinition createStartStaticServerMethod(Service service, GapicContext context, Map<String, VariableExpr> classMemberVarExprs, TypeStore typeStore, String newBuilderMethod) -
createStopServerMethod
protected abstract MethodDefinition createStopServerMethod(Service service, Map<String, VariableExpr> classMemberVarExprs) -
createSetUpMethod
protected abstract MethodDefinition createSetUpMethod(Service service, Map<String, VariableExpr> classMemberVarExprs, TypeStore typeStore) -
createTearDownMethod
protected abstract MethodDefinition createTearDownMethod(Service service, Map<String, VariableExpr> classMemberVarExprs) -
constructRpcTestCheckerLogic
protected abstract List<Statement> constructRpcTestCheckerLogic(Method method, List<MethodArgument> methodSignature, Service service, boolean isRequestArg, Map<String, VariableExpr> classMemberVarExprs, VariableExpr requestVarExpr, Message requestMessage) -
createStreamingRpcTestMethod
protected abstract MethodDefinition createStreamingRpcTestMethod(Service service, Method method, Map<String, VariableExpr> classMemberVarExprs, Map<String, ResourceName> resourceNames, Map<String, Message> messageTypes) -
createRpcExceptionTestMethod
protected abstract MethodDefinition createRpcExceptionTestMethod(Method method, Service service, List<MethodArgument> methodSignature, int variantIndex, Map<String, VariableExpr> classMemberVarExprs, Map<String, ResourceName> resourceNames, Map<String, Message> messageTypes) Creates a test method to exercise exceptions for a given RPC, e.g. createAssetTest.- Parameters:
method- the RPC for which this test method is created.service- the service thatmethodbelongs to.methodSignature- the method signature of the RPC under test.variantIndex- the nth variant of the RPC under test. This applies when we have polymorphism due to the presence of several method signature annotations in the proto.classMemberVarExprs- the class members in the generated test class.resourceNames- the resource names available for use.messageTypes- the proto message types available for use.
-
createStreamingRpcExceptionTestStatements
-
createUnsupportedTestMethod
-
createRpcExceptionTestStatements
protected List<Statement> createRpcExceptionTestStatements(Method method, List<MethodArgument> methodSignature, Map<String, VariableExpr> classMemberVarExprs, Map<String, ResourceName> resourceNames, Map<String, Message> messageTypes) -
createRpcLroExceptionTestCatchBody
protected abstract List<Statement> createRpcLroExceptionTestCatchBody(VariableExpr exceptionExpr, boolean isStreaming) -
getCallableType
-
getCallableMethodName
-
getMockServiceVarName
-