@Test(groups = "fast") public void testFindPhase() throws CatalogApiException { final DefaultPlanPhase phaseTrial1 = new MockPlanPhase().setPhaseType(PhaseType.TRIAL); final DefaultPlanPhase phaseTrial2 = new MockPlanPhase().setPhaseType(PhaseType.TRIAL); final DefaultPlanPhase phaseDiscount1 = new MockPlanPhase().setPhaseType(PhaseType.DISCOUNT); final DefaultPlanPhase phaseDiscount2 = new MockPlanPhase().setPhaseType(PhaseType.DISCOUNT); final DefaultPlan plan1 = new MockPlan().setName("TestPlan1").setFinalPhase(phaseDiscount1).setInitialPhases(new DefaultPlanPhase[]{phaseTrial1}); final DefaultPlan plan2 = new MockPlan().setName("TestPlan2").setFinalPhase(phaseDiscount2).setInitialPhases(new DefaultPlanPhase[]{phaseTrial2}); phaseTrial1.setPlan(plan1); phaseTrial2.setPlan(plan2); phaseDiscount1.setPlan(plan1); phaseDiscount2.setPlan(plan2); final StandaloneCatalog cat = new MockCatalog().setPlans(ImmutableList.<Plan>of(plan1, plan2)); Assert.assertEquals(cat.findCurrentPhase("TestPlan1-discount"), phaseDiscount1); Assert.assertEquals(cat.findCurrentPhase("TestPlan2-discount"), phaseDiscount2); Assert.assertEquals(cat.findCurrentPhase("TestPlan1-trial"), phaseTrial1); Assert.assertEquals(cat.findCurrentPhase("TestPlan2-trial"), phaseTrial2); } }
public static MockPlanPhase createTrial(final int days) { return new MockPlanPhase(BillingPeriod.NO_BILLING_PERIOD, PhaseType.TRIAL, new DefaultDuration().setUnit(TimeUnit.DAYS).setNumber(days), null, MockInternationalPrice.create1USD() ); }
public static MockPlanPhase createUSDMonthlyEvergreen(final String reccuringUSDPrice, final String fixedPrice) { return new MockPlanPhase(BillingPeriod.MONTHLY, PhaseType.EVERGREEN, new DefaultDuration().setUnit(TimeUnit.UNLIMITED).setNumber(-1), (reccuringUSDPrice == null) ? null : MockInternationalPrice.createUSD(reccuringUSDPrice), (fixedPrice == null) ? null : MockInternationalPrice.createUSD(fixedPrice)); }
public static MockPlanPhase createUSDMonthlyFixedTerm(final String reccuringUSDPrice, final String fixedPrice, final int durationInMonths) { return new MockPlanPhase(BillingPeriod.MONTHLY, PhaseType.FIXEDTERM, new DefaultDuration().setUnit(TimeUnit.MONTHS).setNumber(durationInMonths), (reccuringUSDPrice == null) ? null : MockInternationalPrice.createUSD(reccuringUSDPrice), (fixedPrice == null) ? null : MockInternationalPrice.createUSD(fixedPrice)); }
public MockPlan(final String planName) { setName(planName); setProduct(new MockProduct()); setFinalPhase(new MockPlanPhase(this)); setInitialPhases(null); setRecurringBillingMode(BillingMode.IN_ADVANCE); setPlansAllowedInBundle(1); }
public static MockPlanPhase create1USDMonthlyEvergreen() { return (MockPlanPhase) new MockPlanPhase(BillingPeriod.MONTHLY, PhaseType.EVERGREEN, new DefaultDuration().setUnit(TimeUnit.UNLIMITED).setNumber(-1), MockInternationalPrice.create1USD(), null).setPlan(MockPlan.createBicycleNoTrialEvergreen1USD()); }
@Test(groups = "fast") public void testOverriding() throws CatalogApiException { final DefaultProduct foo = new DefaultProduct("Foo", ProductCategory.BASE); final DefaultProduct bar = new DefaultProduct("Bar", ProductCategory.BASE); final DefaultPlan[] defaultPlans = new DefaultPlan[]{ new MockPlan().setName("plan-foo-monthly").setProduct(foo).setFinalPhase(new MockPlanPhase().setRecurring(new MockRecurring(MONTHLY, null)).setPhaseType(EVERGREEN)), new MockPlan().setName("plan-bar-monthly").setProduct(bar).setFinalPhase(new MockPlanPhase().setRecurring(new MockRecurring(MONTHLY, null)).setPhaseType(EVERGREEN)), new MockPlan().setName("plan-foo-annual").setProduct(foo).setFinalPhase(new MockPlanPhase().setRecurring(new MockRecurring(ANNUAL, null)).setPhaseType(EVERGREEN)), new MockPlan().setName("plan-bar-annual").setProduct(bar).setFinalPhase(new MockPlanPhase().setRecurring(new MockRecurring(ANNUAL, null)).setPhaseType(EVERGREEN)) }; final DefaultPlan[] childPlans = new DefaultPlan[]{ new MockPlan().setName("plan-foo").setProduct(foo).setFinalPhase(new MockPlanPhase().setRecurring(new MockRecurring(ANNUAL, null)).setPhaseType(DISCOUNT)), new MockPlan().setName("plan-bar").setProduct(bar).setFinalPhase(new MockPlanPhase().setRecurring(new MockRecurring(ANNUAL, null)).setPhaseType(DISCOUNT)) }; final PriceListDefault defaultPriceList = new PriceListDefault(defaultPlans); final DefaultPriceList[] childPriceLists = new DefaultPriceList[]{ new DefaultPriceList(childPlans, "child") }; final DefaultPriceListSet set = new DefaultPriceListSet(defaultPriceList, childPriceLists); Assert.assertEquals(set.getPlanFrom(foo, BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME).getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); Assert.assertEquals(set.getPlanFrom(foo, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME).getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); Assert.assertEquals(set.getPlanFrom(foo, BillingPeriod.ANNUAL, "child").getFinalPhase().getPhaseType(), PhaseType.DISCOUNT); Assert.assertEquals(set.getPlanFrom(foo, BillingPeriod.MONTHLY, "child").getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); }
@Test(groups = "fast") public void testForNullBillingPeriod() throws CatalogApiException { final DefaultProduct foo = new DefaultProduct("Foo", ProductCategory.BASE); final DefaultProduct bar = new DefaultProduct("Bar", ProductCategory.BASE); final DefaultPlan[] defaultPlans = new DefaultPlan[]{ new MockPlan().setName("plan-foo-monthly").setProduct(foo).setFinalPhase(new MockPlanPhase().setRecurring(new MockRecurring(MONTHLY, null)).setPhaseType(EVERGREEN)), new MockPlan().setName("plan-bar-monthly").setProduct(bar).setFinalPhase(new MockPlanPhase().setRecurring(new MockRecurring(MONTHLY, null)).setPhaseType(EVERGREEN)), new MockPlan().setName("plan-foo-annual").setProduct(foo).setFinalPhase(new MockPlanPhase().setRecurring(new MockRecurring(ANNUAL, null)).setPhaseType(EVERGREEN)), new MockPlan().setName("plan-bar-annual").setProduct(bar).setFinalPhase(new MockPlanPhase().setRecurring(new MockRecurring(ANNUAL, null)).setPhaseType(EVERGREEN)) }; final DefaultPlan[] childPlans = new DefaultPlan[]{ new MockPlan().setName("plan-foo").setProduct(foo).setFinalPhase(new MockPlanPhase().setRecurring(new MockRecurring(ANNUAL, null)).setPhaseType(DISCOUNT)), new MockPlan().setName("plan-bar").setProduct(bar).setFinalPhase(new MockPlanPhase().setRecurring(new MockRecurring(ANNUAL, null)).setPhaseType(DISCOUNT)) }; final PriceListDefault defaultPriceList = new PriceListDefault(defaultPlans); final DefaultPriceList[] childPriceLists = new DefaultPriceList[]{ new DefaultPriceList(childPlans, "child") }; final DefaultPriceListSet set = new DefaultPriceListSet(defaultPriceList, childPriceLists); Assert.assertEquals(set.getPlanFrom(foo, BillingPeriod.ANNUAL, "child").getFinalPhase().getPhaseType(), PhaseType.DISCOUNT); Assert.assertEquals(set.getPlanFrom(foo, BillingPeriod.MONTHLY, "child").getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); Assert.assertEquals(set.getPlanFrom(foo, BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME).getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); Assert.assertEquals(set.getPlanFrom(foo, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME).getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); } }
private MockPlanPhase createMockMonthlyPlanPhase() { return new MockPlanPhase(null, null, BillingPeriod.MONTHLY); }
@Test(groups = "fast") public void testIsSameDayAndSameSubscriptionWithNullPrevEvent() { final Plan plan = new MockPlan("my-plan"); final BigDecimal fixedPriceAmount = BigDecimal.TEN; final MockInternationalPrice fixedPrice = new MockInternationalPrice(new DefaultPrice(fixedPriceAmount, Currency.USD)); final PlanPhase phase = new MockPlanPhase(null, fixedPrice, BillingPeriod.NO_BILLING_PERIOD, PhaseType.TRIAL); final InvoiceItem prevInvoiceItem = null; final BillingEvent event = invoiceUtil.createMockBillingEvent(account, subscription, new DateTime("2016-02-01"), plan, phase, fixedPriceAmount, null, Currency.USD, BillingPeriod.NO_BILLING_PERIOD, 1, BillingMode.IN_ADVANCE, "Billing Event Desc", 1L, SubscriptionBaseTransitionType.CREATE); assertFalse(fixedAndRecurringInvoiceItemGenerator.isSameDayAndSameSubscription(prevInvoiceItem, event, internalCallContext)); }
private MockPlanPhase createMockMonthlyPlanPhase(@Nullable final BigDecimal recurringRate, @Nullable final BigDecimal fixedCost, final PhaseType phaseType) { final MockInternationalPrice recurringPrice = (recurringRate == null) ? null : new MockInternationalPrice(new DefaultPrice(recurringRate, Currency.USD)); final MockInternationalPrice fixedPrice = (fixedCost == null) ? null : new MockInternationalPrice(new DefaultPrice(fixedCost, Currency.USD)); return new MockPlanPhase(recurringPrice, fixedPrice, BillingPeriod.MONTHLY, phaseType); }
private MockPlanPhase createMockMonthlyPlanPhase(@Nullable final BigDecimal recurringRate) { return new MockPlanPhase(new MockInternationalPrice(new DefaultPrice(recurringRate, Currency.USD)), null, BillingPeriod.MONTHLY); }
private MockPlanPhase createMockThirtyDaysPlanPhase(@Nullable final BigDecimal recurringRate) { return new MockPlanPhase(new MockInternationalPrice(new DefaultPrice(recurringRate, Currency.USD)), null, BillingPeriod.THIRTY_DAYS); }
public static MockPlanPhase createTrial(final int days) { return new MockPlanPhase(BillingPeriod.NO_BILLING_PERIOD, PhaseType.TRIAL, new DefaultDuration().setUnit(TimeUnit.DAYS).setNumber(days), null, MockInternationalPrice.create1USD() ); }
private MockPlanPhase createMockMonthlyPlanPhase(final BigDecimal recurringRate, final PhaseType phaseType) { return new MockPlanPhase(new MockInternationalPrice(new DefaultPrice(recurringRate, Currency.USD)), null, BillingPeriod.MONTHLY, phaseType); }
private MockPlanPhase createMockAnnualPlanPhase(final BigDecimal recurringRate, final PhaseType phaseType) { return new MockPlanPhase(new MockInternationalPrice(new DefaultPrice(recurringRate, Currency.USD)), null, BillingPeriod.ANNUAL, phaseType); }
public static MockPlanPhase createUSDMonthlyEvergreen(final String reccuringUSDPrice, final String fixedPrice) { return new MockPlanPhase(BillingPeriod.MONTHLY, PhaseType.EVERGREEN, new DefaultDuration().setUnit(TimeUnit.UNLIMITED).setNumber(-1), (reccuringUSDPrice == null) ? null : MockInternationalPrice.createUSD(reccuringUSDPrice), (fixedPrice == null) ? null : MockInternationalPrice.createUSD(fixedPrice)); }
public static MockPlanPhase createUSDMonthlyFixedTerm(final String reccuringUSDPrice, final String fixedPrice, final int durationInMonths) { return new MockPlanPhase(BillingPeriod.MONTHLY, PhaseType.FIXEDTERM, new DefaultDuration().setUnit(TimeUnit.MONTHS).setNumber(durationInMonths), (reccuringUSDPrice == null) ? null : MockInternationalPrice.createUSD(reccuringUSDPrice), (fixedPrice == null) ? null : MockInternationalPrice.createUSD(fixedPrice)); }
public MockPlan(final String planName) { setName(planName); setProduct(new MockProduct()); setFinalPhase(new MockPlanPhase(this)); setInitialPhases(null); setRecurringBillingMode(BillingMode.IN_ADVANCE); setPlansAllowedInBundle(1); }
public static MockPlanPhase create1USDMonthlyEvergreen() { return (MockPlanPhase) new MockPlanPhase(BillingPeriod.MONTHLY, PhaseType.EVERGREEN, new DefaultDuration().setUnit(TimeUnit.UNLIMITED).setNumber(-1), MockInternationalPrice.create1USD(), null).setPlan(MockPlan.createBicycleNoTrialEvergreen1USD()); }