MediaFileServiceClient implements BackgroundResource { public final MediaFile getMediaFile(MediaFileName resourceName) { GetMediaFileRequest request = GetMediaFileRequest.newBuilder() .setResourceName(resourceName == null ? null : resourceName.toString()) .build(); return getMediaFile(request); } protected  MediaFileServiceClient(MediaFileServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  MediaFileServiceClient(MediaFileServiceStub stub); static final MediaFileServiceClient create(); static final MediaFileServiceClient create(MediaFileServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final MediaFileServiceClient create(MediaFileServiceStub stub); final MediaFileServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") MediaFileServiceStub getStub(); final MediaFile getMediaFile(MediaFileName resourceName); final MediaFile getMediaFile(String resourceName); final MediaFile getMediaFile(GetMediaFileRequest request); final UnaryCallable<GetMediaFileRequest, MediaFile> getMediaFileCallable(); final MutateMediaFilesResponse mutateMediaFiles(
      String customerId, List<MediaFileOperation> operations); final MutateMediaFilesResponse mutateMediaFiles(MutateMediaFilesRequest request); final UnaryCallable<MutateMediaFilesRequest, MutateMediaFilesResponse> mutateMediaFilesCallable(); @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 getMediaFileTest() { com.google.ads.googleads.v5.services.MediaFileName resourceName2 = com.google.ads.googleads.v5.services.MediaFileName.of("[CUSTOMER]", "[MEDIA_FILE]"); long id = 3355L; String sourceUrl = "sourceUrl-1111107765"; com.google.ads.googleads.v5.services.MediaFileName name = com.google.ads.googleads.v5.services.MediaFileName.of("[CUSTOMER]", "[MEDIA_FILE]"); long fileSize = 1316310812L; MediaFile expectedResponse = MediaFile.newBuilder() .setResourceName(resourceName2.toString()) .setId(id) .setSourceUrl(sourceUrl) .setName(name.toString()) .setFileSize(fileSize) .build(); mockMediaFileService.addResponse(expectedResponse); MediaFileName resourceName = MediaFileName.of("[CUSTOMER]", "[MEDIA_FILE]"); MediaFile actualResponse = client.getMediaFile(resourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockMediaFileService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetMediaFileRequest actualRequest = (GetMediaFileRequest) actualRequests.get(0); Assert.assertEquals(resourceName, MediaFileName.parse(actualRequest.getResourceName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getMediaFileExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockMediaFileService.addException(exception); try { MediaFileName resourceName = MediaFileName.of("[CUSTOMER]", "[MEDIA_FILE]"); client.getMediaFile(resourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }