From 21ac96900d2a3656a5113f3b85737591ea78867c Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Wed, 30 Dec 2020 16:51:26 -0500 Subject: [PATCH] update fast_forward calls to use new parseDuration with better intervals --- .../bubble/test/BubbleApiRunnerListener.java | 18 +------------- .../models/tests/promo/account_credit.json | 8 +++---- .../models/tests/promo/first_month_free.json | 4 ++-- .../models/tests/promo/multi_promo.json | 24 +++++++++---------- .../tests/promo/referral_month_free.json | 4 ++-- utils/cobbzilla-utils | 2 +- 6 files changed, 22 insertions(+), 38 deletions(-) diff --git a/bubble-server/src/test/java/bubble/test/BubbleApiRunnerListener.java b/bubble-server/src/test/java/bubble/test/BubbleApiRunnerListener.java index 8f98f287..afc14a32 100644 --- a/bubble-server/src/test/java/bubble/test/BubbleApiRunnerListener.java +++ b/bubble-server/src/test/java/bubble/test/BubbleApiRunnerListener.java @@ -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 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); diff --git a/bubble-server/src/test/resources/models/tests/promo/account_credit.json b/bubble-server/src/test/resources/models/tests/promo/account_credit.json index 569881f7..f7b697a2 100644 --- a/bubble-server/src/test/resources/models/tests/promo/account_credit.json +++ b/bubble-server/src/test/resources/models/tests/promo/account_credit.json @@ -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": [ diff --git a/bubble-server/src/test/resources/models/tests/promo/first_month_free.json b/bubble-server/src/test/resources/models/tests/promo/first_month_free.json index d76224d9..56fef15a 100644 --- a/bubble-server/src/test/resources/models/tests/promo/first_month_free.json +++ b/bubble-server/src/test/resources/models/tests/promo/first_month_free.json @@ -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": [ diff --git a/bubble-server/src/test/resources/models/tests/promo/multi_promo.json b/bubble-server/src/test/resources/models/tests/promo/multi_promo.json index b3ca71b8..4d9c93bd 100644 --- a/bubble-server/src/test/resources/models/tests/promo/multi_promo.json +++ b/bubble-server/src/test/resources/models/tests/promo/multi_promo.json @@ -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" diff --git a/bubble-server/src/test/resources/models/tests/promo/referral_month_free.json b/bubble-server/src/test/resources/models/tests/promo/referral_month_free.json index fd418019..673e6e85 100644 --- a/bubble-server/src/test/resources/models/tests/promo/referral_month_free.json +++ b/bubble-server/src/test/resources/models/tests/promo/referral_month_free.json @@ -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": [ diff --git a/utils/cobbzilla-utils b/utils/cobbzilla-utils index f87d3b74..aff12362 160000 --- a/utils/cobbzilla-utils +++ b/utils/cobbzilla-utils @@ -1 +1 @@ -Subproject commit f87d3b74f46775143dfffd2182e43eb91f94a0b7 +Subproject commit aff12362cacc1fa00bab2e5e7dacc1f12ae66340