StockCardListFragment extends BaseFragment implements StockCardPresenter.StockCardListView, AdapterView.OnItemSelectedListener { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (requestCode == Constants.REQUEST_FROM_STOCK_LIST_PAGE) { long stockCardId = data.getLongExtra(Constants.PARAM_STOCK_CARD_ID, 0); presenter.refreshStockCardsObservable(stockCardId); } else if (requestCode == Constants.REQUEST_UNPACK_KIT) { presenter.loadKits(); } } }  @Override Presenter initPresenter(); @Override void onAttach(Activity activity); @Nullable @Override View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState); @Override void onViewCreated(View view, Bundle savedInstanceState); @Override void onItemSelected(AdapterView<?> parent, View view, int position, long id); @Override void onNothingSelected(AdapterView<?> parent); @Override void onActivityResult(int requestCode, int resultCode, Intent data); void onSearch(String query); @Override void refreshBannerText(); @Override void showWarning(); @Override void refresh(List<InventoryViewModel> data);  }
@Test public void shouldRefreshBannerText() { fragment.productsUpdateBanner = productUpdateBanner; when(sharedPreferenceMgr.isNeedShowProductsUpdateBanner()).thenReturn(true); when(productUpdateBanner.getVisibility()).thenReturn(View.VISIBLE); fragment.onActivityResult(Constants.REQUEST_FROM_STOCK_LIST_PAGE, Activity.RESULT_OK, new Intent()); verify(fragment.presenter).refreshStockCardsObservable(0); }
@Test public void shouldRefreshAndShowBannerWhenNeedShowBanner() { fragment.productsUpdateBanner = productUpdateBanner; fragment.onActivityResult(Constants.REQUEST_FROM_STOCK_LIST_PAGE, Activity.RESULT_OK, new Intent()); verify(fragment.presenter).refreshStockCardsObservable(0); }