@@ -20,7 +20,6 @@ import com.stripe.model.Token; | |||
import lombok.Getter; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.cobbzilla.wizard.client.script.SimpleApiRunnerListener; | |||
import org.joda.time.DateTime; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
@@ -31,7 +30,6 @@ import static org.cobbzilla.util.daemon.ZillaRuntime.*; | |||
import static org.cobbzilla.util.string.StringUtil.splitAndTrim; | |||
import static org.cobbzilla.util.system.Sleep.sleep; | |||
import static org.cobbzilla.util.time.TimeUtil.parseDuration; | |||
import static org.joda.time.DurationFieldType.months; | |||
@Slf4j | |||
public class BubbleApiRunnerListener extends SimpleApiRunnerListener { | |||
@@ -59,21 +57,7 @@ public class BubbleApiRunnerListener extends SimpleApiRunnerListener { | |||
if (before == null) return; | |||
if (before.startsWith(FAST_FORWARD_AND_BILL)) { | |||
final List<String> parts = splitAndTrim(before.substring(FAST_FORWARD_AND_BILL.length()), " "); | |||
final long delta; | |||
if (parts.get(0).endsWith("M")) { | |||
// we're fast-forwarding in months | |||
final String part = parts.get(0); | |||
final int direction = part.startsWith("-") ? -1 : 1; | |||
final int count = Integer.parseInt(part.startsWith("-") || part.startsWith("+") | |||
? part.substring(1, part.length()-1) | |||
: part.substring(0, part.length()-1)); | |||
final long now = now(); | |||
final DateTime start = new DateTime(now); | |||
final DateTime later = new DateTime(now).withFieldAdded(months(), direction * count); | |||
delta = later.getMillis() - start.getMillis(); | |||
} else { | |||
delta = parseDuration(parts.get(0)); | |||
} | |||
final long delta = parseDuration(parts.get(0)); | |||
final long sleepTime = parts.size() > 1 ? parseDuration(parts.get(1)) : DEFAULT_BILLING_SLEEP; | |||
getStripePaymentDriver().flushCaches(); | |||
incrementSystemTimeOffset(delta); | |||
@@ -416,8 +416,8 @@ | |||
}, | |||
{ | |||
"before": "fast_forward_and_bill 31d 30s", | |||
"comment": "fast-forward +31 days, verify a new bill exists for first accountPlan", | |||
"before": "fast_forward_and_bill 1M+1d 30s", | |||
"comment": "fast-forward 1 month + 1 day, verify a new bill exists for first accountPlan", | |||
"request": { "uri": "me/plans/{{accountPlan.uuid}}/bills" }, | |||
"response": { | |||
"check": [ | |||
@@ -499,8 +499,8 @@ | |||
}, | |||
{ | |||
"before": "fast_forward_and_bill 31d 30s", | |||
"comment": "fast-forward +31 days, verify a new bill exists for first accountPlan", | |||
"before": "fast_forward_and_bill 1M+1d 30s", | |||
"comment": "fast-forward 1 month + 1 day, verify a new bill exists for first accountPlan", | |||
"request": { "uri": "me/plans/{{accountPlan.uuid}}/bills" }, | |||
"response": { | |||
"check": [ | |||
@@ -353,8 +353,8 @@ | |||
}, | |||
{ | |||
"before": "fast_forward_and_bill 31d 30s", | |||
"comment": "fast-forward +31 days, verify a new bill exists for first accountPlan", | |||
"before": "fast_forward_and_bill 1M+1d 30s", | |||
"comment": "fast-forward 1 month + 1 day, verify a new bill exists for first accountPlan", | |||
"request": { "uri": "me/plans/{{accountPlan.uuid}}/bills" }, | |||
"response": { | |||
"check": [ | |||
@@ -308,8 +308,8 @@ | |||
// Second Month -- referred users use their referral credit. referring user pays with card | |||
{ | |||
"before": "fast_forward_and_bill 29d 40s", | |||
"comment": "root: fast-forward +29 days, verify referring user received notice about first real payment", | |||
"before": "fast_forward_and_bill 1M-2d 40s", | |||
"comment": "root: fast-forward 1 month less 2 days, verify referring user received notice about first real payment", | |||
"request": { | |||
"session": "rootSession", | |||
"uri": "debug/inbox/email/test_user_referring_multi@example.com?type=notice&action=first_payment&target=network" | |||
@@ -438,8 +438,8 @@ | |||
// Third Month -- referred users pay with card. referring user pays with 1st referral credit | |||
{ | |||
"before": "fast_forward_and_bill 29d 40s", | |||
"comment": "root: second fast-forward +29 days, verify referred user 1 received notice about first real payment", | |||
"before": "fast_forward_and_bill 1M-2d 40s", | |||
"comment": "root: second fast-forward 1 month less 2 days, verify referred user 1 received notice about first real payment", | |||
"request": { | |||
"session": "rootSession", | |||
"uri": "debug/inbox/email/referred_multi_1@example.com?type=notice&action=first_payment&target=network" | |||
@@ -567,8 +567,8 @@ | |||
// Fourth Month -- referreds pay with card, referring pays with 2nd referral credit | |||
{ | |||
"before": "fast_forward_and_bill 31d 40s", | |||
"comment": "referring: third fast-forward +31 days, verify a new bill exists for referring", | |||
"before": "fast_forward_and_bill 1M+1d 40s", | |||
"comment": "referring: third fast-forward one month + 1 day, verify a new bill exists for referring", | |||
"request": { | |||
"session": "referringUserSession", | |||
"uri": "me/plans/{{referringAccountPlan.uuid}}/bills" | |||
@@ -655,8 +655,8 @@ | |||
// Fifth Month -- referreds pay with card, referring pays with 3rd referral credit | |||
{ | |||
"before": "fast_forward_and_bill 31d 60s", | |||
"comment": "referring: fourth fast-forward +31 days, verify a new bill exists for referring", | |||
"before": "fast_forward_and_bill 1M+1d 40s", | |||
"comment": "referring: fourth fast-forward 1 month + 1 day, verify a new bill exists for referring", | |||
"request": { | |||
"session": "referringUserSession", | |||
"uri": "me/plans/{{referringAccountPlan.uuid}}/bills" | |||
@@ -743,8 +743,8 @@ | |||
// 6th Month -- referreds pay with card, referring uses regular account credit + card | |||
{ | |||
"before": "fast_forward_and_bill 31d 40s", | |||
"comment": "referring: fifth fast-forward +31 days, verify a new bill exists for referring", | |||
"before": "fast_forward_and_bill 1M+1d 40s", | |||
"comment": "referring: fifth fast-forward 1 month + 1 day, verify a new bill exists for referring", | |||
"request": { | |||
"session": "referringUserSession", | |||
"uri": "me/plans/{{referringAccountPlan.uuid}}/bills" | |||
@@ -835,8 +835,8 @@ | |||
// 7th Month -- everyone pays with credit card | |||
{ | |||
"before": "fast_forward_and_bill 31d 40s", | |||
"comment": "referring: sixth fast-forward +31 days, verify a new bill exists for referring", | |||
"before": "fast_forward_and_bill 1M+1d 40s", | |||
"comment": "referring: sixth fast-forward 1 month + day, verify a new bill exists for referring", | |||
"request": { | |||
"session": "referringUserSession", | |||
"uri": "me/plans/{{referringAccountPlan.uuid}}/bills" | |||
@@ -513,8 +513,8 @@ | |||
}, | |||
{ | |||
"before": "fast_forward_and_bill 31d 30s", | |||
"comment": "referred: fast-forward +31 days, verify a new bill exists for referred accountPlan", | |||
"before": "fast_forward_and_bill 1M+1d 30s", | |||
"comment": "referred: fast-forward 1 montb + 1 day, verify a new bill exists for referred accountPlan", | |||
"request": { "uri": "me/plans/{{referredAccountPlan.uuid}}/bills" }, | |||
"response": { | |||
"check": [ | |||
@@ -1 +1 @@ | |||
Subproject commit f87d3b74f46775143dfffd2182e43eb91f94a0b7 | |||
Subproject commit aff12362cacc1fa00bab2e5e7dacc1f12ae66340 |