@Test public void testAddProduct() throws Exception { when(sessionId.get()).thenReturn("sessionId"); when(viewBinder.getDeviceYear()).thenReturn(2017); presenter.onBarcode("barcode", true); verify(productList).createProductPlaceholder(); verify(api).getByCode("barcode", "sessionId"); }
@Override public void onBarcode(String barcode, boolean fromCamera) { logger.logSearch(barcode, sessionId.get(), fromCamera ? "camera" : "keyboard"); if (productList.itemExists(barcode)) { handlerScanner.removeCallbacks(runnableResumeScan); handlerScanner.postDelayed(runnableResumeScan, millisecondsBetweenExisting); } else { productList.createProductPlaceholder(); reportResultCall = viewBinder.getDeviceYear() < 2010 ? api.getByCode(barcode, sessionId.get(),true) : api.getByCode(barcode, sessionId.get()); reportResultCall.enqueue(this); } }
MainPresenter implements Callback<SearchResult>, BarcodeListener { @Override public void onBarcode(String barcode, boolean fromCamera) { logger.logSearch(barcode, sessionId.get(), fromCamera ? "camera" : "keyboard"); if (productList.itemExists(barcode)) { handlerScanner.removeCallbacks(runnableResumeScan); handlerScanner.postDelayed(runnableResumeScan, millisecondsBetweenExisting); } else { productList.createProductPlaceholder(); reportResultCall = viewBinder.getDeviceYear() < 2010 ? api.getByCode(barcode, sessionId.get(),true) : api.getByCode(barcode, sessionId.get()); reportResultCall.enqueue(this); } } }
MainPresenter implements Callback<SearchResult>, BarcodeListener { @Override public void onBarcode(String barcode, boolean fromCamera) { logger.logSearch(barcode, sessionId.get(), fromCamera ? "camera" : "keyboard"); if (productList.itemExists(barcode)) { handlerScanner.removeCallbacks(runnableResumeScan); handlerScanner.postDelayed(runnableResumeScan, millisecondsBetweenExisting); } else { productList.createProductPlaceholder(); reportResultCall = viewBinder.getDeviceYear() < 2010 ? api.getByCode(barcode, sessionId.get(),true) : api.getByCode(barcode, sessionId.get()); reportResultCall.enqueue(this); } } MainPresenter(@NonNull MainViewBinder viewBinder,
                  @NonNull ProductList productList,
                  @NonNull Api api,
                  @NonNull EventLogger logger,
                  @NonNull SessionId sessionId,
                  @NonNull Bus eventBus); }
MainPresenter implements Callback<SearchResult>, BarcodeListener { @Override public void onBarcode(String barcode, boolean fromCamera) { logger.logSearch(barcode, sessionId.get(), fromCamera ? "camera" : "keyboard"); if (productList.itemExists(barcode)) { handlerScanner.removeCallbacks(runnableResumeScan); handlerScanner.postDelayed(runnableResumeScan, millisecondsBetweenExisting); } else { productList.createProductPlaceholder(); reportResultCall = viewBinder.getDeviceYear() < 2010 ? api.getByCode(barcode, sessionId.get(),true) : api.getByCode(barcode, sessionId.get()); reportResultCall.enqueue(this); } } MainPresenter(@NonNull MainViewBinder viewBinder,
                  @NonNull ProductList productList,
                  @NonNull Api api,
                  @NonNull EventLogger logger,
                  @NonNull SessionId sessionId,
                  @NonNull Bus eventBus); static MainPresenter create(Context applicationContext, @NonNull final MainViewBinder viewBinder,
                                       @NonNull final ProductList productList,
                                       @NonNull final ProductsAdapter productsAdapter,
                                       @NonNull SessionId sessionId,
                                       @NonNull final Bus eventBus); @Override void onBarcode(String barcode, boolean fromCamera); @Override void onResponse(Call<SearchResult> call, Response<SearchResult> response); @Override void onFailure(Call<SearchResult> call, Throwable t); @Subscribe @SuppressWarnings("WeakerAccess") void productDetailsFragmentDismissed(@SuppressWarnings("UnusedParameters") ProductDetailsFragmentDismissedEvent event); @Subscribe @SuppressWarnings("WeakerAccess") void reportButtonClicked(ReportButtonClickedEvent event); void setCurrentSearchResult(SearchResult currentSearchResult); void onBackStackChange(boolean isNotBackStackEmpty); void onSupportPolaButtonClick(); void onSupportPolaFinished(); }
MainPresenter implements Callback<SearchResult>, BarcodeListener { @Override public void onBarcode(String barcode, boolean fromCamera) { logger.logSearch(barcode, sessionId.get(), fromCamera ? "camera" : "keyboard"); if (productList.itemExists(barcode)) { handlerScanner.removeCallbacks(runnableResumeScan); handlerScanner.postDelayed(runnableResumeScan, millisecondsBetweenExisting); } else { productList.createProductPlaceholder(); reportResultCall = viewBinder.getDeviceYear() < 2010 ? api.getByCode(barcode, sessionId.get(),true) : api.getByCode(barcode, sessionId.get()); reportResultCall.enqueue(this); } } MainPresenter(@NonNull MainViewBinder viewBinder,
                  @NonNull ProductList productList,
                  @NonNull Api api,
                  @NonNull EventLogger logger,
                  @NonNull SessionId sessionId,
                  @NonNull Bus eventBus); static MainPresenter create(Context applicationContext, @NonNull final MainViewBinder viewBinder,
                                       @NonNull final ProductList productList,
                                       @NonNull final ProductsAdapter productsAdapter,
                                       @NonNull SessionId sessionId,
                                       @NonNull final Bus eventBus); @Override void onBarcode(String barcode, boolean fromCamera); @Override void onResponse(Call<SearchResult> call, Response<SearchResult> response); @Override void onFailure(Call<SearchResult> call, Throwable t); @Subscribe @SuppressWarnings("WeakerAccess") void productDetailsFragmentDismissed(@SuppressWarnings("UnusedParameters") ProductDetailsFragmentDismissedEvent event); @Subscribe @SuppressWarnings("WeakerAccess") void reportButtonClicked(ReportButtonClickedEvent event); void setCurrentSearchResult(SearchResult currentSearchResult); void onBackStackChange(boolean isNotBackStackEmpty); void onSupportPolaButtonClick(); void onSupportPolaFinished();  }