### Question:
ActivityReportingTask extends Task<Void> { @Nullable @Override Void execute() throws Exception { String advertisingId = features.getIncludesIfa() ? deviceManager.getAdvertisingId() : null; return buttonApi.postActivity(activityName, products, sourceToken, advertisingId); } ActivityReportingTask(ButtonApi buttonApi, DeviceManager deviceManager,
            Features features, String activityName, List<ButtonProductCompatible> products,
            @Nullable String sourceToken, @Nullable Listener<Void> listener);   }### Answer:
@Test public void execute_includesIfa_hasAdvertisingId_verifyApiCall() throws Exception { when(features.getIncludesIfa()).thenReturn(true); String advertisingId = "valid_advertising_id"; when(deviceManager.getAdvertisingId()).thenReturn(advertisingId); task.execute(); verify(buttonApi).postActivity(activityName, products, sourceToken, "valid_advertising_id"); }
@Test public void execute_includesIfa_nullAdvertisingId_verifyNullAdvertisingId() throws Exception { when(features.getIncludesIfa()).thenReturn(true); when(deviceManager.getAdvertisingId()).thenReturn(null); task.execute(); verify(buttonApi).postActivity(eq(activityName), eq(products), eq(sourceToken), (String) isNull()); }
@Test public void execute_doesNotIncludesIfa_verifyNullAdvertisingId() throws Exception { when(features.getIncludesIfa()).thenReturn(false); when(deviceManager.getAdvertisingId()).thenReturn(""); task.execute(); verify(buttonApi).postActivity(eq(activityName), eq(products), eq(sourceToken), (String) isNull()); }