Class MockAppHubConnection (2.32.0)
Note: Some or all of the information on this page might not apply
to Trusted Cloud. For a list of services that are available in
Trusted Cloud, see Services available for
Trusted Cloud .
Version 2.32.0keyboard_arrow_down
A class to mock AppHubConnection
.
Application developers may want to test their code with simulated responses, including errors, from an object of type AppHubClient
. To do so, construct an object of type AppHubClient
with an instance of this class. Then use the Google Test framework functions to program the behavior of this mock.
See Also
This example for how to test your application with GoogleTest. While the example showcases types from the BigQuery library, the underlying principles apply for any pair of *Client
and *Connection
.
Functions
virtual options()
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Returns
Type
Description
Options
virtual LookupServiceProjectAttachment(google::cloud::apphub::v1::LookupServiceProjectAttachmentRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::LookupServiceProjectAttachmentRequest const &
Returns
Type
Description
StatusOr< google::cloud::apphub::v1::LookupServiceProjectAttachmentResponse >
virtual ListServiceProjectAttachments(google::cloud::apphub::v1::ListServiceProjectAttachmentsRequest)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::ListServiceProjectAttachmentsRequest
Returns
Type
Description
StreamRange< google::cloud::apphub::v1::ServiceProjectAttachment >
virtual CreateServiceProjectAttachment(google::longrunning::Operation const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
operation
google::longrunning::Operation const &
Returns
Type
Description
future< StatusOr< google::cloud::apphub::v1::ServiceProjectAttachment > >
virtual GetServiceProjectAttachment(google::cloud::apphub::v1::GetServiceProjectAttachmentRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::GetServiceProjectAttachmentRequest const &
Returns
Type
Description
StatusOr< google::cloud::apphub::v1::ServiceProjectAttachment >
virtual DeleteServiceProjectAttachment(google::longrunning::Operation const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
operation
google::longrunning::Operation const &
Returns
Type
Description
future< StatusOr< google::cloud::apphub::v1::OperationMetadata > >
virtual DetachServiceProjectAttachment(google::cloud::apphub::v1::DetachServiceProjectAttachmentRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::DetachServiceProjectAttachmentRequest const &
Returns
Type
Description
StatusOr< google::cloud::apphub::v1::DetachServiceProjectAttachmentResponse >
virtual ListDiscoveredServices(google::cloud::apphub::v1::ListDiscoveredServicesRequest)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::ListDiscoveredServicesRequest
Returns
Type
Description
StreamRange< google::cloud::apphub::v1::DiscoveredService >
virtual GetDiscoveredService(google::cloud::apphub::v1::GetDiscoveredServiceRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::GetDiscoveredServiceRequest const &
Returns
Type
Description
StatusOr< google::cloud::apphub::v1::DiscoveredService >
virtual LookupDiscoveredService(google::cloud::apphub::v1::LookupDiscoveredServiceRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::LookupDiscoveredServiceRequest const &
Returns
Type
Description
StatusOr< google::cloud::apphub::v1::LookupDiscoveredServiceResponse >
virtual ListServices(google::cloud::apphub::v1::ListServicesRequest)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::ListServicesRequest
Returns
Type
Description
StreamRange< google::cloud::apphub::v1::Service >
virtual CreateService(google::longrunning::Operation const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
operation
google::longrunning::Operation const &
Returns
Type
Description
future< StatusOr< google::cloud::apphub::v1::Service > >
virtual GetService(google::cloud::apphub::v1::GetServiceRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::GetServiceRequest const &
Returns
Type
Description
StatusOr< google::cloud::apphub::v1::Service >
virtual UpdateService(google::longrunning::Operation const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
operation
google::longrunning::Operation const &
Returns
Type
Description
future< StatusOr< google::cloud::apphub::v1::Service > >
virtual DeleteService(google::longrunning::Operation const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
operation
google::longrunning::Operation const &
Returns
Type
Description
future< StatusOr< google::cloud::apphub::v1::OperationMetadata > >
virtual ListDiscoveredWorkloads(google::cloud::apphub::v1::ListDiscoveredWorkloadsRequest)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::ListDiscoveredWorkloadsRequest
Returns
Type
Description
StreamRange< google::cloud::apphub::v1::DiscoveredWorkload >
virtual GetDiscoveredWorkload(google::cloud::apphub::v1::GetDiscoveredWorkloadRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::GetDiscoveredWorkloadRequest const &
Returns
Type
Description
StatusOr< google::cloud::apphub::v1::DiscoveredWorkload >
virtual LookupDiscoveredWorkload(google::cloud::apphub::v1::LookupDiscoveredWorkloadRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::LookupDiscoveredWorkloadRequest const &
Returns
Type
Description
StatusOr< google::cloud::apphub::v1::LookupDiscoveredWorkloadResponse >
virtual ListWorkloads(google::cloud::apphub::v1::ListWorkloadsRequest)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::ListWorkloadsRequest
Returns
Type
Description
StreamRange< google::cloud::apphub::v1::Workload >
virtual CreateWorkload(google::longrunning::Operation const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
operation
google::longrunning::Operation const &
Returns
Type
Description
future< StatusOr< google::cloud::apphub::v1::Workload > >
virtual GetWorkload(google::cloud::apphub::v1::GetWorkloadRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::GetWorkloadRequest const &
Returns
Type
Description
StatusOr< google::cloud::apphub::v1::Workload >
virtual UpdateWorkload(google::longrunning::Operation const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
operation
google::longrunning::Operation const &
Returns
Type
Description
future< StatusOr< google::cloud::apphub::v1::Workload > >
virtual DeleteWorkload(google::longrunning::Operation const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
operation
google::longrunning::Operation const &
Returns
Type
Description
future< StatusOr< google::cloud::apphub::v1::OperationMetadata > >
virtual ListApplications(google::cloud::apphub::v1::ListApplicationsRequest)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::ListApplicationsRequest
Returns
Type
Description
StreamRange< google::cloud::apphub::v1::Application >
virtual CreateApplication(google::longrunning::Operation const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
operation
google::longrunning::Operation const &
Returns
Type
Description
future< StatusOr< google::cloud::apphub::v1::Application > >
virtual GetApplication(google::cloud::apphub::v1::GetApplicationRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::apphub::v1::GetApplicationRequest const &
Returns
Type
Description
StatusOr< google::cloud::apphub::v1::Application >
virtual UpdateApplication(google::longrunning::Operation const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
operation
google::longrunning::Operation const &
Returns
Type
Description
future< StatusOr< google::cloud::apphub::v1::Application > >
virtual DeleteApplication(google::longrunning::Operation const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
operation
google::longrunning::Operation const &
Returns
Type
Description
future< StatusOr< google::cloud::apphub::v1::OperationMetadata > >
virtual ListLocations(google::cloud::location::ListLocationsRequest)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::location::ListLocationsRequest
Returns
Type
Description
StreamRange< google::cloud::location::Location >
virtual GetLocation(google::cloud::location::GetLocationRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::cloud::location::GetLocationRequest const &
Returns
Type
Description
StatusOr< google::cloud::location::Location >
virtual SetIamPolicy(google::iam::v1::SetIamPolicyRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::v1::SetIamPolicyRequest const &
Returns
Type
Description
StatusOr< google::iam::v1::Policy >
virtual GetIamPolicy(google::iam::v1::GetIamPolicyRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::v1::GetIamPolicyRequest const &
Returns
Type
Description
StatusOr< google::iam::v1::Policy >
virtual TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::v1::TestIamPermissionsRequest const &
Returns
Type
Description
StatusOr< google::iam::v1::TestIamPermissionsResponse >
virtual ListOperations(google::longrunning::ListOperationsRequest)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::longrunning::ListOperationsRequest
Returns
Type
Description
StreamRange< google::longrunning::Operation >
virtual GetOperation(google::longrunning::GetOperationRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::longrunning::GetOperationRequest const &
Returns
Type
Description
StatusOr< google::longrunning::Operation >
virtual DeleteOperation(google::longrunning::DeleteOperationRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::longrunning::DeleteOperationRequest const &
Returns
Type
Description
Status
virtual CancelOperation(google::longrunning::CancelOperationRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::longrunning::CancelOperationRequest const &
Returns
Type
Description
Status
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["This page documents the `MockAppHubConnection` class, which is designed to facilitate testing of code that interacts with `AppHubClient` by simulating responses, including errors."],["The `MockAppHubConnection` class allows developers to program the behavior of the mock using the Google Test framework, making it possible to test how applications respond to various simulated scenarios."],["The class uses `gMock`'s `MOCK_METHOD()` to implement its virtual functions, which users can manipulate for testing purposes, and all of these functions are based on various calls to `AppHub`'s methods such as `LookupServiceProjectAttachment`, `ListServiceProjectAttachments`, `ListDiscoveredServices`, `CreateWorkload` and more."],["There are several versions of the class available for download, with `2.37.0-rc` being the latest version and the one that is recommended for download."],["The page has a `See Also` link with a detailed example, which references the `BigQuery` library for its example, but the principles of how to test your code with `*Client` and `*Connection` apply to any library, including `AppHub`."]]],[]]