use of com.amazon.purchase.model.Response in project zype-firebuilder by zype.
the class PurchaseManagerTest method testIsPurchaseValidForExpiredExistentPurchase.
/**
* tests isPurchaseValid for expired existent purchase
*/
@Test
public void testIsPurchaseValidForExpiredExistentPurchase() throws Exception {
mPurchaseManager.init(purchaseSystem, null);
Thread.sleep(1000);
Receipt receipt = TestUtils.createReceipt("subSku", "subSku", new Date(), new Date());
mPurchaseManager.mReceiptMap.put("subSku", receipt);
mPurchaseManager.isPurchaseValid("subSku", 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);
verify(purchaseSystem).notifyFulfillment(any(String.class), any(UserData.class), any(Receipt.class), any(Receipt.FulfillmentStatus.class));
assertFalse(mPurchaseManager.mReceiptMap.containsKey("subSku"));
verifyUtil.verified();
}
});
Thread.sleep(1000);
verify(verifyUtil).verified();
}
use of com.amazon.purchase.model.Response in project zype-firebuilder by zype.
the class PurchaseManagerTest method testIsPurchaseValidForReceiptValidSystemFailure.
/**
* tests isPurchaseValid for receipt validation system failure
*/
@Test
public void testIsPurchaseValidForReceiptValidSystemFailure() throws Exception {
Response response = new Response("isPurchaseValidRequest", Response.Status.FAILED, 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.FAILED, response.getStatus());
assertFalse(validity);
assertTrue(mPurchaseManager.mReceiptMap.containsKey("rentSku"));
verifyUtil.verified();
}
});
Thread.sleep(1000);
verify(verifyUtil).verified();
}
use of com.amazon.purchase.model.Response in project zype-firebuilder by zype.
the class PurchaseManagerTest method testPurchaseFailure.
/**
* Tests purchase failure
*/
@Test
public void testPurchaseFailure() throws Exception {
Response purchaseResponse = new Response("purchaseRequest", Response.Status.FAILED, null);
doReturn(purchaseResponse).when(mockPurchaseSystem).purchaseListenerResponse();
mPurchaseManager.init(purchaseSystem, null);
Thread.sleep(1000);
mPurchaseManager.purchaseSku("subSku", new PurchaseManagerListener() {
@Override
public void onRegisterSkusResponse(Response response) {
}
@Override
public void onValidPurchaseResponse(Response response, boolean validity, String sku) {
assertEquals(Response.Status.FAILED, response.getStatus());
assertFalse(validity);
assertFalse(mPurchaseManager.mReceiptMap.containsKey("subSku"));
verifyUtil.verified();
}
});
Thread.sleep(1000);
verify(verifyUtil).verified();
}
use of com.amazon.purchase.model.Response in project zype-firebuilder by zype.
the class PurchaseManagerTest method testIsPurchaseValidForValidPurchase.
/**
* tests isPurchaseValid for valid purchase
*/
@Test
public void testIsPurchaseValidForValidPurchase() throws Exception {
Response response = new Response("isPurchaseValidRequest", Response.Status.SUCCESSFUL, null);
doReturn(response).when(mockPurchaseSystem).listenerResponse();
doReturn(true).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());
assertTrue(validity);
assertTrue(mPurchaseManager.mReceiptMap.containsKey("rentSku"));
verifyUtil.verified();
}
});
Thread.sleep(1000);
verify(verifyUtil).verified();
}
use of com.amazon.purchase.model.Response 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();
}
Aggregations