@Test public void reportAppOpen_Twice_shouldCallOnlyOnce() { subject.reportAppOpen(context); verify(mockRequestQueue).add(requestCaptor.capture()); reset(mockRequestQueue); requestCaptor.getValue().deliverResponse(null); subject.reportAppOpen(context); verify(mockRequestQueue, never()).add(any(TrackingRequest.class)); }
public void reportAppOpen(Context context) { if (context == null) { return; } mContext = context; mPackageName = mContext.getPackageName(); mIsTrackedKey = mPackageName + " tracked"; mSharedPreferences = SharedPreferencesHelper.getSharedPreferences(mContext); if (!isAlreadyTracked()) { TrackingRequest.makeTrackingHttpRequest(new ConversionUrlGenerator().generateUrlString(Constants.HOST), mContext, new TrackingRequest.Listener() { @Override public void onResponse(@NonNull String url) { mSharedPreferences .edit() .putBoolean(mIsTrackedKey, true) .commit(); } @Override public void onErrorResponse(final VolleyError volleyError) { } }); } else { MoPubLog.d("Conversion already tracked"); } }
MoPubConversionTracker { public void reportAppOpen(Context context) { if (context == null) { return; } mContext = context; mPackageName = mContext.getPackageName(); mIsTrackedKey = mPackageName + " tracked"; mSharedPreferences = SharedPreferencesHelper.getSharedPreferences(mContext); if (!isAlreadyTracked()) { TrackingRequest.makeTrackingHttpRequest(new ConversionUrlGenerator().generateUrlString(Constants.HOST), mContext, new TrackingRequest.Listener() { @Override public void onResponse(@NonNull String url) { mSharedPreferences .edit() .putBoolean(mIsTrackedKey, true) .commit(); } @Override public void onErrorResponse(final VolleyError volleyError) { } }); } else { MoPubLog.d("Conversion already tracked"); } } }
MoPubConversionTracker { public void reportAppOpen(Context context) { if (context == null) { return; } mContext = context; mPackageName = mContext.getPackageName(); mIsTrackedKey = mPackageName + " tracked"; mSharedPreferences = SharedPreferencesHelper.getSharedPreferences(mContext); if (!isAlreadyTracked()) { TrackingRequest.makeTrackingHttpRequest(new ConversionUrlGenerator().generateUrlString(Constants.HOST), mContext, new TrackingRequest.Listener() { @Override public void onResponse(@NonNull String url) { mSharedPreferences .edit() .putBoolean(mIsTrackedKey, true) .commit(); } @Override public void onErrorResponse(final VolleyError volleyError) { } }); } else { MoPubLog.d("Conversion already tracked"); } }  }
MoPubConversionTracker { public void reportAppOpen(Context context) { if (context == null) { return; } mContext = context; mPackageName = mContext.getPackageName(); mIsTrackedKey = mPackageName + " tracked"; mSharedPreferences = SharedPreferencesHelper.getSharedPreferences(mContext); if (!isAlreadyTracked()) { TrackingRequest.makeTrackingHttpRequest(new ConversionUrlGenerator().generateUrlString(Constants.HOST), mContext, new TrackingRequest.Listener() { @Override public void onResponse(@NonNull String url) { mSharedPreferences .edit() .putBoolean(mIsTrackedKey, true) .commit(); } @Override public void onErrorResponse(final VolleyError volleyError) { } }); } else { MoPubLog.d("Conversion already tracked"); } }  void reportAppOpen(Context context); }
MoPubConversionTracker { public void reportAppOpen(Context context) { if (context == null) { return; } mContext = context; mPackageName = mContext.getPackageName(); mIsTrackedKey = mPackageName + " tracked"; mSharedPreferences = SharedPreferencesHelper.getSharedPreferences(mContext); if (!isAlreadyTracked()) { TrackingRequest.makeTrackingHttpRequest(new ConversionUrlGenerator().generateUrlString(Constants.HOST), mContext, new TrackingRequest.Listener() { @Override public void onResponse(@NonNull String url) { mSharedPreferences .edit() .putBoolean(mIsTrackedKey, true) .commit(); } @Override public void onErrorResponse(final VolleyError volleyError) { } }); } else { MoPubLog.d("Conversion already tracked"); } }  void reportAppOpen(Context context);  }