UserDataServiceClient implements BackgroundResource { public final UploadUserDataResponse uploadUserData(UploadUserDataRequest request) { return uploadUserDataCallable().call(request); } protected  UserDataServiceClient(UserDataServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  UserDataServiceClient(UserDataServiceStub stub); static final UserDataServiceClient create(); static final UserDataServiceClient create(UserDataServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final UserDataServiceClient create(UserDataServiceStub stub); final UserDataServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") UserDataServiceStub getStub(); final UploadUserDataResponse uploadUserData(UploadUserDataRequest request); final UnaryCallable<UploadUserDataRequest, UploadUserDataResponse> uploadUserDataCallable(); @Override final void close(); @Override void shutdown(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override void shutdownNow(); @Override boolean awaitTermination(long duration, TimeUnit unit);  }
@Test @SuppressWarnings("all") public void uploadUserDataTest() { UploadUserDataResponse expectedResponse = UploadUserDataResponse.newBuilder().build(); mockUserDataService.addResponse(expectedResponse); String customerId = "customerId-1772061412"; List<UserDataOperation> operations = new ArrayList<>(); UploadUserDataRequest request = UploadUserDataRequest.newBuilder() .setCustomerId(customerId) .addAllOperations(operations) .build(); UploadUserDataResponse actualResponse = client.uploadUserData(request); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockUserDataService.getRequests(); Assert.assertEquals(1, actualRequests.size()); UploadUserDataRequest actualRequest = (UploadUserDataRequest) actualRequests.get(0); Assert.assertEquals(customerId, actualRequest.getCustomerId()); Assert.assertEquals(operations, actualRequest.getOperationsList()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void uploadUserDataExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockUserDataService.addException(exception); try { String customerId = "customerId-1772061412"; List<UserDataOperation> operations = new ArrayList<>(); UploadUserDataRequest request = UploadUserDataRequest.newBuilder() .setCustomerId(customerId) .addAllOperations(operations) .build(); client.uploadUserData(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }