private void loadPurchases(@Nonnull final BillingRequests requests, @Nonnull final Product product) { requests.getAllPurchases(product.id, synchronizedListener(new RequestListener<Purchases>() { @Override public void onSuccess(@Nonnull Purchases purchases) { product.setPurchases(purchases.list); countDown(); } @Override public void onError(int response, @Nonnull Exception e) { countDown(); } })); }
@Test public void testShouldLoadAllPurchases() throws Exception { final Billing billing = prepareMultiPurchasesBilling(); final CountDownLatch latch = new CountDownLatch(1); final CountDownListener l = new CountDownListener(latch); billing.getRequests().getAllPurchases(ProductTypes.IN_APP, l); assertTrue(latch.await(1, SECONDS)); verify(l.listener).onSuccess(argThat(new PurchasesMatcher())); }