### Question:
Inventory { public Purchase getPurchase(String sku) { return mPurchaseMap.get(sku); }  SkuDetails getSkuDetails(String sku); Collection<SkuDetails> getSkuDetails(); Purchase getPurchase(String sku); boolean hasPurchase(String sku); boolean hasDetails(String sku); void erasePurchase(String sku); List<String> getAllOwnedSkus(); List<String> getAllOwnedSkus(ItemType itemType); List<Purchase> getAllPurchases(); void addSkuDetails(SkuDetails d); void addPurchase(Purchase p); @Override String toString();  }### Answer:
@Test public void testGetPurchase() throws Exception { Inventory inventory = new Inventory(); Purchase p = mock(Purchase.class); when(p.getSku()).thenReturn("sku1"); inventory.addPurchase(p); assertThat(inventory.getPurchase("sku1")).isSameAs(p); }