### Question:
DefaultPurchaseVerifier implements PurchaseVerifier { @Override public void verify(@Nonnull List<Purchase> purchases, @Nonnull RequestListener<List<Purchase>> listener) { final List<Purchase> verifiedPurchases = new ArrayList<Purchase>(purchases.size()); for (Purchase purchase : purchases) { if (TEST_SKUS.contains(purchase.sku)) { Billing.debug("Auto-verifying a test purchase: " + purchase); verifiedPurchases.add(purchase); continue; } if (Security.verifyPurchase(mPublicKey, purchase.data, purchase.signature)) { verifiedPurchases.add(purchase); continue; } if (isEmpty(purchase.signature)) { Billing.error("Cannot verify purchase: " + purchase + ". Signature is empty"); } else { Billing.error("Cannot verify purchase: " + purchase + ". Wrong signature"); } } listener.onSuccess(verifiedPurchases); } DefaultPurchaseVerifier(@Nonnull String publicKey); @Override void verify(@Nonnull List<Purchase> purchases, @Nonnull RequestListener<List<Purchase>> listener);  }### Answer:
@SuppressWarnings("unchecked") @Test public void testShouldAutoVerifyTestPurchases() throws Exception { final List<Purchase> testPurchases = new ArrayList<>(); for (String sku : DefaultPurchaseVerifier.TEST_SKUS) { testPurchases.add(new Purchase(sku, "", "", 0, 0, "", "", false, "", "")); } final RequestListener<List<Purchase>> listener = Mockito.mock(RequestListener.class); mVerifier.verify(testPurchases, listener); Mockito.verify(listener).onSuccess(Mockito.eq(testPurchases)); }
@SuppressWarnings("unchecked") @Test public void testShouldNotAutoVerifyRealPurchases() throws Exception { final List<Purchase> purchases = Collections.singletonList( new Purchase("android.test.boom", "", "", 0, 0, "", "", false, "", "")); final RequestListener<List<Purchase>> listener = Mockito.mock(RequestListener.class); mVerifier.verify(purchases, listener); Mockito.verify(listener).onSuccess(Mockito.eq(Collections.<Purchase>emptyList())); }