### Question:
FirebaseDynamicLinksImpl extends FirebaseDynamicLinks { @Override public Task<PendingDynamicLinkData> getDynamicLink(@NonNull final Intent intent) { Task<PendingDynamicLinkData> result = googleApi.doWrite(new GetDynamicLinkImpl(analytics, intent.getDataString())); PendingDynamicLinkData pendingDynamicLinkData = getPendingDynamicLinkData(intent); if (pendingDynamicLinkData != null) { result = Tasks.forResult(pendingDynamicLinkData); } return result; } FirebaseDynamicLinksImpl(FirebaseApp firebaseApp, @Nullable AnalyticsConnector analytics); @VisibleForTesting  FirebaseDynamicLinksImpl(
      GoogleApi<NoOptions> googleApi, @Nullable AnalyticsConnector analytics); PendingDynamicLinkData getPendingDynamicLinkData(@NonNull Intent intent); @Override Task<PendingDynamicLinkData> getDynamicLink(@NonNull final Intent intent); @Override Task<PendingDynamicLinkData> getDynamicLink(@NonNull final Uri dynamicLinkUri); @Override DynamicLink.Builder createDynamicLink(); static Uri createDynamicLink(Bundle builderParameters); Task<ShortDynamicLink> createShortDynamicLink(final Bundle builderParameters); static void verifyDomainUriPrefix(Bundle builderParameters); static final String KEY_SCION_DATA; static final String EXTRA_DYNAMIC_LINK_DATA; }### Answer:
@Test public void testGetDynamicLink_Intent() { Intent intent = new Intent(); api.getDynamicLink(intent); verify(mockGoogleApi) .doWrite(ArgumentMatchers.<TaskApiCall<DynamicLinksClient, PendingDynamicLinkData>>any()); }
@Test public void testGetDynamicLink_IntentWithDynamicLinkData() { Bundle extensions = new Bundle(); extensions.putString(PARAMETER, VALUE); DynamicLinkData dynamicLinkData = new DynamicLinkData( DYNAMIC_LINK, DEEP_LINK, MINIMUM_VERSION, CLICK_TIMESTAMP, extensions, null ); Intent intent = new Intent(); SafeParcelableSerializer.serializeToIntentExtra( dynamicLinkData, intent, EXTRA_DYNAMIC_LINK_DATA); Task<PendingDynamicLinkData> task = api.getDynamicLink(intent); verify(mockGoogleApi) .doWrite(ArgumentMatchers.<TaskApiCall<DynamicLinksClient, PendingDynamicLinkData>>any()); assertTrue(task.isComplete()); assertTrue(task.isSuccessful()); PendingDynamicLinkData pendingDynamicLinkData = task.getResult(); assertNotNull(pendingDynamicLinkData); assertEquals(Uri.parse(DEEP_LINK), pendingDynamicLinkData.getLink()); assertEquals(MINIMUM_VERSION, pendingDynamicLinkData.getMinimumAppVersion()); assertEquals(CLICK_TIMESTAMP, pendingDynamicLinkData.getClickTimestamp()); Bundle returnExtensions = pendingDynamicLinkData.getExtensions(); assertEquals(extensions.keySet(), returnExtensions.keySet()); for (String key : extensions.keySet()) { assertEquals(extensions.getString(key), returnExtensions.getString(key)); } assertNull(pendingDynamicLinkData.getRedirectUrl()); }
@Test public void testGetDynamicLink_Uri() { Uri dynamicLink = Uri.parse(DYNAMIC_LINK); api.getDynamicLink(dynamicLink); verify(mockGoogleApi) .doWrite(ArgumentMatchers.<TaskApiCall<DynamicLinksClient, PendingDynamicLinkData>>any()); }
@Test public void testGetDynamicLink_doExecute() { final FirebaseDynamicLinksImpl.GetDynamicLinkImpl getDynamicLink = new FirebaseDynamicLinksImpl.GetDynamicLinkImpl(mockAnalytics, DYNAMIC_LINK); try { getDynamicLink.doExecute(mockDynamicLinksClient, mockCompletionSource); ArgumentCaptor<IDynamicLinksCallbacks.Stub> captorCallbacks = ArgumentCaptor.forClass(IDynamicLinksCallbacks.Stub.class); verify(mockDynamicLinksClient).getDynamicLink(captorCallbacks.capture(), eq(DYNAMIC_LINK)); captorCallbacks .getValue() .onGetDynamicLink(Status.RESULT_SUCCESS, genDynamicLinkData(new Bundle())); } catch (RemoteException e) { fail("Unexpected Remote Exception"); } }