### Question:
StorageNotLowTracker extends BroadcastReceiverConstraintTracker<Boolean> { @Override public void onBroadcastReceive(Context context, @NonNull Intent intent) { if (intent.getAction() == null) { return; } Log.d(TAG, String.format("Received %s", intent.getAction())); switch (intent.getAction()) { case Intent.ACTION_DEVICE_STORAGE_OK: setState(true); break; case Intent.ACTION_DEVICE_STORAGE_LOW: setState(false); break; } } StorageNotLowTracker(Context context); @Override Boolean getInitialState(); @Override IntentFilter getIntentFilter(); @Override void onBroadcastReceive(Context context, @NonNull Intent intent);  }### Answer:
@Test @SmallTest public void testOnBroadcastReceive_invalidIntentAction_doesNotNotifyListeners() { mockContextReturns(null); mTracker.addListener(mListener); verify(mListener).onConstraintChanged(true); mTracker.onBroadcastReceive(mMockContext, new Intent("INVALID")); verifyNoMoreInteractions(mListener); }
@Test @SmallTest public void testOnBroadcastReceive_notifiesListeners() { mockContextReturns(new Intent("INVALID")); mTracker.addListener(mListener); verify(mListener, never()).onConstraintChanged(anyBoolean()); mTracker.onBroadcastReceive(mMockContext, new Intent(Intent.ACTION_DEVICE_STORAGE_OK)); verify(mListener).onConstraintChanged(true); mTracker.onBroadcastReceive(mMockContext, new Intent(Intent.ACTION_DEVICE_STORAGE_LOW)); verify(mListener).onConstraintChanged(false); }