use of com.amazon.purchase.model.Receipt in project zype-firebuilder by zype.
the class PurchaseManagerTest method testIsPurchaseValidForNonValidPurchase.
/**
* tests isPurchaseValid for non valid purchase
*/
@Test
public void testIsPurchaseValidForNonValidPurchase() throws Exception {
Response response = new Response("isPurchaseValidRequest", Response.Status.SUCCESSFUL, null);
doReturn(response).when(mockPurchaseSystem).listenerResponse();
doReturn(false).when(mockPurchaseSystem).receiptValidResponse();
mPurchaseManager.init(purchaseSystem, null);
Thread.sleep(1000);
Receipt receipt = TestUtils.createReceipt("rentSku", "rentSku", DateAndTimeHelper.addSeconds(new Date(), 25), null);
mPurchaseManager.mReceiptMap.put("rentSku", receipt);
mPurchaseManager.isPurchaseValid("rentSku", new PurchaseManagerListener() {
@Override
public void onRegisterSkusResponse(Response response) {
}
@Override
public void onValidPurchaseResponse(Response response, boolean validity, String sku) {
assertEquals(Response.Status.SUCCESSFUL, response.getStatus());
assertFalse(validity);
assertFalse(mPurchaseManager.mReceiptMap.containsKey("rentSku"));
verifyUtil.verified();
}
});
Thread.sleep(1000);
verify(verifyUtil).verified();
}
use of com.amazon.purchase.model.Receipt in project zype-firebuilder by zype.
the class TestUtils method createReceipt.
public static Receipt createReceipt(String sku, String receiptTitle, Date purchaseDate, Date expiryDate) {
Receipt receipt = new Receipt();
receipt.setPurchasedDate(purchaseDate);
receipt.setSku(sku);
receipt.setReceiptId(receiptTitle);
receipt.setExpiryDate(expiryDate);
return receipt;
}
Aggregations