### Question:
GetPendingLinkTask extends Task<PostInstallLink> { @Nullable @Override PostInstallLink execute() throws Exception { String advertisingId = features.getIncludesIfa() ? deviceManager.getAdvertisingId() : null; return buttonApi.getPendingLink(applicationId, advertisingId, deviceManager.getSignals()); } GetPendingLinkTask(ButtonApi buttonApi, DeviceManager deviceManager, Features features,
            String applicationId, Listener<PostInstallLink> listener);   }### Answer:
@Test public void execute_includesIfa_hasAdvertisingId_verifyApiCall() throws Exception { PostInstallLink postInstallLink = new PostInstallLink(true, "id", null, null); Map<String, String> signalsMap = Collections.emptyMap(); when(features.getIncludesIfa()).thenReturn(true); String advertisingId = "valid_advertising_id"; when(deviceManager.getAdvertisingId()).thenReturn(advertisingId); when(deviceManager.getSignals()).thenReturn(signalsMap); when(buttonApi.getPendingLink(applicationId, advertisingId, signalsMap)) .thenReturn(postInstallLink); assertEquals(postInstallLink, task.execute()); verify(buttonApi).getPendingLink(applicationId, advertisingId, signalsMap); }
@Test public void execute_includesIfa_nullAdvertisingId_verifyNullAdvertisingId() throws Exception { Map<String, String> signalsMap = Collections.emptyMap(); when(features.getIncludesIfa()).thenReturn(true); when(deviceManager.getAdvertisingId()).thenReturn(null); when(deviceManager.getSignals()).thenReturn(signalsMap); task.execute(); verify(buttonApi).getPendingLink(anyString(),(String) isNull(), eq(signalsMap)); }
@Test public void execute_doesNotIncludesIfa_verifyNullAdvertisingId() throws Exception { Map<String, String> signalsMap = Collections.emptyMap(); when(features.getIncludesIfa()).thenReturn(false); when(deviceManager.getAdvertisingId()).thenReturn(""); when(deviceManager.getSignals()).thenReturn(signalsMap); task.execute(); verify(buttonApi).getPendingLink(anyString(),(String) isNull(), eq(signalsMap)); }