### Question:
EventReportingTask extends Task<Void> { @Nullable @Override Void execute() throws Exception { String advertisingId = features.getIncludesIfa() ? deviceManager.getAdvertisingId() : null; return buttonApi.postEvents(events, advertisingId); } EventReportingTask(ButtonApi buttonApi, DeviceManager deviceManager, Features features,
            List<Event> events, 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).postEvents(events, advertisingId); }
@Test public void execute_includesIfa_nullAdvertisingId_verifyNullAdvertisingId() throws Exception { when(features.getIncludesIfa()).thenReturn(true); when(deviceManager.getAdvertisingId()).thenReturn(null); task.execute(); verify(buttonApi).postEvents(eq(events), (String) isNull()); }
@Test public void execute_doesNotIncludesIfa_verifyNullAdvertisingId() throws Exception { when(features.getIncludesIfa()).thenReturn(false); when(deviceManager.getAdvertisingId()).thenReturn(""); task.execute(); verify(buttonApi).postEvents(eq(events), (String) isNull()); }