### Question:
RobotmediaDatabase { @Nonnull Inventory.Products load(@Nonnull Inventory.Request request) { SQLiteDatabase db = null; try { final String databasePath = RobotmediaDatabase.getDatabasePath(mContext); db = openDatabase(databasePath, null, OPEN_READONLY); return loadProducts(request, db); } catch (RuntimeException e) { Billing.error(e); } finally { if (db != null) { db.close(); } } return toInventoryProducts(ProductTypes.ALL); } RobotmediaDatabase(@Nonnull Context context); static boolean exists(@Nonnull Context context);  }### Answer:
@Test public void testShouldCreateEmptyProductsIfError() throws Exception { mDb.close(); RuntimeEnvironment.application.deleteDatabase(RobotmediaDatabase.NAME); final RobotmediaInventory inventory = new RobotmediaInventory(mCheckout, sameThreadExecutor(), sameThreadExecutor()); final CountDownCallback l = new CountDownCallback(); inventory.load(mRequest, l); final Inventory.Products products = l.waitProducts(); final Inventory.Product product = products.get(IN_APP); assertNotNull(product); assertTrue(product.getPurchases().isEmpty()); }
@Test public void testShouldReadTransactions() throws Exception { mDb.insert(newTransaction(0)); mDb.insert(newTransaction(1)); mDb.insert(newTransaction(2)); mDb.insert(newTransaction(3)); mDb.insert(newTransaction(4)); mDb.insert(newTransaction(5)); final RobotmediaInventory inventory = new RobotmediaInventory(mCheckout, sameThreadExecutor(), sameThreadExecutor()); final CountDownCallback l = new CountDownCallback(); inventory.load(mRequest, l); final Inventory.Products products = l.waitProducts(); final Inventory.Product product = products.get(IN_APP); assertTrue(product.supported); final List<Purchase> purchases = product.getPurchases(); assertEquals(5, purchases.size()); verifyPurchase(purchases, 0); verifyPurchase(purchases, 1); verifyPurchase(purchases, 2); verifyPurchase(purchases, 3); verifyPurchase(purchases, 4); }
@Test public void testShouldReadEmptyList() throws Exception { final RobotmediaInventory inventory = new RobotmediaInventory(mCheckout, sameThreadExecutor(), sameThreadExecutor()); final CountDownCallback l = new CountDownCallback(); inventory.load(mRequest, l); final Inventory.Products products = l.waitProducts(); final Inventory.Product product = products.get(IN_APP); assertTrue(product.supported); final List<Purchase> purchases = product.getPurchases(); assertEquals(0, purchases.size()); }