@Test
public void initializeWithCancelledConsumablePurchase() throws Exception {

    // Configure
    final Bundle getSubscriptionsResponse = new Bundle();
    getSubscriptionsResponse.putInt("RESPONSE_CODE", RESULT_OK);
    getSubscriptionsResponse.putStringArrayList("INAPP_PURCHASE_ITEM_LIST", new ArrayList<>());
    getSubscriptionsResponse.putStringArrayList("INAPP_PURCHASE_DATA_LIST", new ArrayList<>());
    getSubscriptionsResponse.putStringArrayList("INAPP_DATA_SIGNATURE_LIST", new ArrayList<>());
    when(inAppBillingService.getPurchases(3, packageName, "subs", null)).thenReturn(getSubscriptionsResponse);
    final Bundle getConsumablePurchasesResponse = new Bundle();
    getConsumablePurchasesResponse.putInt("RESPONSE_CODE", RESULT_OK);
    getConsumablePurchasesResponse.putStringArrayList("INAPP_PURCHASE_ITEM_LIST", new ArrayList<>(Collections.singletonList(getInAppPurchaseItem(InAppPurchase.OcrScans50))));
    getConsumablePurchasesResponse.putStringArrayList("INAPP_PURCHASE_DATA_LIST", new ArrayList<>(Collections.singletonList(getInAppPurchaseData(InAppPurchase.OcrScans50, PURCHASE_STATE_CANCELLED))));
    getConsumablePurchasesResponse.putStringArrayList("INAPP_DATA_SIGNATURE_LIST", new ArrayList<>(Collections.singletonList(getInAppDataSignature())));
    when(inAppBillingService.getPurchases(3, packageName, "inapp", null)).thenReturn(getConsumablePurchasesResponse);
    // Test
    purchaseManager.initialize(application);
    verifyInAppBillingServiceConnected();
    verify(purchaseWallet).updateLocalInAppPurchasesInWallet(updateManagedProductsCaptor.capture());
    when(purchaseWallet.getActiveLocalInAppPurchases()).thenReturn(updateManagedProductsCaptor.getValue());
    assertEquals(Collections.<ManagedProduct>emptySet(), updateManagedProductsCaptor.getValue());
    verify(purchaseWallet, times(2)).getActiveLocalInAppPurchases();
    verifyNoMoreInteractions(purchaseWallet);
}