@Test public void onCreate_withoutCacheCustomer_callsApiAndDisplaysProgressBarWhileWaiting() { Customer customer = Customer.fromString(CustomerSessionTest.FIRST_TEST_CUSTOMER_OBJECT); assertNotNull(customer); when(mCustomerSessionProxy.getCachedCustomer()).thenReturn(null); ArgumentCaptor<CustomerSession.CustomerRetrievalListener> listenerArgumentCaptor = ArgumentCaptor.forClass(CustomerSession.CustomerRetrievalListener.class); assertNotNull(mProgressBar); assertNotNull(mRecyclerView); assertNotNull(mAddCardView); mActivityController.get().initializeCustomerSourceData(); verify(mCustomerSessionProxy).retrieveCurrentCustomer(listenerArgumentCaptor.capture()); assertEquals(View.VISIBLE, mProgressBar.getVisibility()); assertEquals(View.VISIBLE, mAddCardView.getVisibility()); assertEquals(View.VISIBLE, mRecyclerView.getVisibility()); CustomerSession.CustomerRetrievalListener listener = listenerArgumentCaptor.getValue(); assertNotNull(listener); listener.onCustomerRetrieved(customer); assertEquals(View.GONE, mProgressBar.getVisibility()); }
@VisibleForTesting void initializeCustomerSourceData() { Customer cachedCustomer = mCustomerSessionProxy == null ? CustomerSession.getInstance().getCachedCustomer() : mCustomerSessionProxy.getCachedCustomer(); if (cachedCustomer != null) { mCustomer = cachedCustomer; createListFromCustomerSources(); } else { getCustomerFromSession(); } }
PaymentMethodsActivity extends AppCompatActivity { @VisibleForTesting void initializeCustomerSourceData() { Customer cachedCustomer = mCustomerSessionProxy == null ? CustomerSession.getInstance().getCachedCustomer() : mCustomerSessionProxy.getCachedCustomer(); if (cachedCustomer != null) { mCustomer = cachedCustomer; createListFromCustomerSources(); } else { getCustomerFromSession(); } } }
PaymentMethodsActivity extends AppCompatActivity { @VisibleForTesting void initializeCustomerSourceData() { Customer cachedCustomer = mCustomerSessionProxy == null ? CustomerSession.getInstance().getCachedCustomer() : mCustomerSessionProxy.getCachedCustomer(); if (cachedCustomer != null) { mCustomer = cachedCustomer; createListFromCustomerSources(); } else { getCustomerFromSession(); } }  }
PaymentMethodsActivity extends AppCompatActivity { @VisibleForTesting void initializeCustomerSourceData() { Customer cachedCustomer = mCustomerSessionProxy == null ? CustomerSession.getInstance().getCachedCustomer() : mCustomerSessionProxy.getCachedCustomer(); if (cachedCustomer != null) { mCustomer = cachedCustomer; createListFromCustomerSources(); } else { getCustomerFromSession(); } }  static Intent newIntent(Context context); @Override boolean onPrepareOptionsMenu(Menu menu); @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onOptionsItemSelected(MenuItem item); }
PaymentMethodsActivity extends AppCompatActivity { @VisibleForTesting void initializeCustomerSourceData() { Customer cachedCustomer = mCustomerSessionProxy == null ? CustomerSession.getInstance().getCachedCustomer() : mCustomerSessionProxy.getCachedCustomer(); if (cachedCustomer != null) { mCustomer = cachedCustomer; createListFromCustomerSources(); } else { getCustomerFromSession(); } }  static Intent newIntent(Context context); @Override boolean onPrepareOptionsMenu(Menu menu); @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onOptionsItemSelected(MenuItem item); static final String EXTRA_SELECTED_PAYMENT; }