private MockPlanPhase createMockMonthlyPlanPhase() { return new MockPlanPhase(null, null, BillingPeriod.MONTHLY); }
protected BillingEvent createRealEvent(final DateTime effectiveDate, final SubscriptionBase subscription, final SubscriptionBaseTransitionType type) { final Account account = this.account; final Integer billCycleDay = 1; final PlanPhase planPhase = new MockPlanPhase(); final Plan plan = new MockPlan(); final BigDecimal fixedPrice = BigDecimal.TEN; final BigDecimal recurringPrice = BigDecimal.TEN; final Currency currency = Currency.USD; final String description = ""; final BillingModeType billingModeType = BillingModeType.IN_ADVANCE; final BillingPeriod billingPeriod = BillingPeriod.MONTHLY; final Long totalOrdering = 0L; final DateTimeZone tz = DateTimeZone.UTC; return new DefaultBillingEvent(account, subscription, effectiveDate, plan, planPhase, fixedPrice, recurringPrice, currency, billingPeriod, billCycleDay, billingModeType, description, totalOrdering, type, tz); }
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); }
@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(new DefaultPlan[]{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), (reccuringUSDPrice == null) ? null : MockInternationalPrice.createUSD(reccuringUSDPrice), (fixedPrice == null) ? null : MockInternationalPrice.createUSD(fixedPrice)); }
final MockInternationalPrice cheapPrice = new MockInternationalPrice(new DefaultPrice(ONE, Currency.USD)); final PlanPhase phase1 = new MockPlanPhase(null, zeroPrice, BillingPeriod.NO_BILLING_PERIOD, PhaseType.TRIAL); final PlanPhase phase2 = new MockPlanPhase(cheapPrice, null, BillingPeriod.MONTHLY, PhaseType.DISCOUNT);
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); }
final DefaultPrice zeroPrice = new DefaultPrice(BigDecimal.ZERO, Currency.USD); final MockInternationalPrice fixedPrice = new MockInternationalPrice(zeroPrice); final MockPlanPhase phase1 = new MockPlanPhase(null, fixedPrice); final MockPlanPhase phase2 = new MockPlanPhase(recurringPrice, null);
public static MockPlanPhase create1USDMonthlyEvergreen() { return (MockPlanPhase) new MockPlanPhase(BillingPeriod.MONTHLY, PhaseType.EVERGREEN, new DefaultDuration().setUnit(TimeUnit.UNLIMITED), MockInternationalPrice.create1USD(), null).setPlan(MockPlan.createBicycleNoTrialEvergreen1USD()); }
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); setPlansAllowedInBundle(1); }
@Test(groups = "slow") public void testInvoiceForFreeTrial() throws InvoiceApiException, CatalogApiException { final Currency currency = Currency.USD; final DefaultPrice price = new DefaultPrice(BigDecimal.ZERO, Currency.USD); final MockInternationalPrice recurringPrice = new MockInternationalPrice(price); final MockPlanPhase phase = new MockPlanPhase(recurringPrice, null); final MockPlan plan = new MockPlan(phase); final SubscriptionBase subscription = getZombieSubscription(); final DateTime effectiveDate = invoiceUtil.buildDate(2011, 1, 1).toDateTimeAtStartOfDay(); final BillingEvent event = invoiceUtil.createMockBillingEvent(null, subscription, effectiveDate, plan, phase, null, recurringPrice.getPrice(currency), currency, BillingPeriod.MONTHLY, 15, BillingModeType.IN_ADVANCE, "testEvent", 1L, SubscriptionBaseTransitionType.CREATE); final BillingEventSet events = new MockBillingEventSet(); events.add(event); final LocalDate targetDate = invoiceUtil.buildDate(2011, 1, 15); final Invoice invoice = generator.generateInvoice(UUID.randomUUID(), events, null, targetDate, Currency.USD); // expect one pro-ration item and one full-period item assertEquals(invoice.getNumberOfItems(), 2); assertEquals(invoice.getBalance().compareTo(ZERO), 0); }
private MockPlanPhase createMockMonthlyPlanPhase(@Nullable final BigDecimal recurringRate, final BigDecimal fixedRate, final PhaseType phaseType) { return new MockPlanPhase(new MockInternationalPrice(new DefaultPrice(recurringRate, Currency.USD)), new MockInternationalPrice(new DefaultPrice(fixedRate, Currency.USD)), BillingPeriod.MONTHLY, phaseType); }
final PlanPhase originalPlanEvergreen = new MockPlanPhase(price10, null, BillingPeriod.MONTHLY, PhaseType.EVERGREEN); final Plan newPlan = new MockPlan("new plan"); final MockInternationalPrice price5 = new MockInternationalPrice(new DefaultPrice(FIVE, Currency.USD)); final PlanPhase newPlanEvergreen = new MockPlanPhase(price5, null, BillingPeriod.MONTHLY, PhaseType.EVERGREEN); events.add(createBillingEvent(newSubscription.getId(), originalSubscription.getBundleId(), april25, newPlan, newPlanEvergreen, 25));
final MockPlanPhase phase1 = new MockPlanPhase(recurringPrice, null, BillingPeriod.MONTHLY, PhaseType.TRIAL); final MockPlan plan1 = new MockPlan(phase1); final MockPlanPhase phase2 = new MockPlanPhase(recurringPrice, null, BillingPeriod.MONTHLY, PhaseType.TRIAL); final MockPlan plan2 = new MockPlan(phase2);
@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().setBillCycleDuration(MONTHLY).setPhaseType(EVERGREEN)), new MockPlan().setName("plan-bar-monthly").setProduct(bar).setFinalPhase(new MockPlanPhase().setBillCycleDuration(MONTHLY).setPhaseType(EVERGREEN)), new MockPlan().setName("plan-foo-annual").setProduct(foo).setFinalPhase(new MockPlanPhase().setBillCycleDuration(ANNUAL).setPhaseType(EVERGREEN)), new MockPlan().setName("plan-bar-annual").setProduct(bar).setFinalPhase(new MockPlanPhase().setBillCycleDuration(ANNUAL).setPhaseType(EVERGREEN)) }; final DefaultPlan[] childPlans = new DefaultPlan[]{ new MockPlan().setName("plan-foo").setProduct(foo).setFinalPhase(new MockPlanPhase().setBillCycleDuration(ANNUAL).setPhaseType(DISCOUNT)), new MockPlan().setName("plan-bar").setProduct(bar).setFinalPhase(new MockPlanPhase().setBillCycleDuration(ANNUAL).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(PriceListSet.DEFAULT_PRICELIST_NAME, foo, BillingPeriod.ANNUAL).getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); Assert.assertEquals(set.getPlanFrom(PriceListSet.DEFAULT_PRICELIST_NAME, foo, BillingPeriod.MONTHLY).getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); Assert.assertEquals(set.getPlanFrom("child", foo, BillingPeriod.ANNUAL).getFinalPhase().getPhaseType(), PhaseType.DISCOUNT); Assert.assertEquals(set.getPlanFrom("child", foo, BillingPeriod.MONTHLY).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().setBillCycleDuration(MONTHLY).setPhaseType(EVERGREEN)), new MockPlan().setName("plan-bar-monthly").setProduct(bar).setFinalPhase(new MockPlanPhase().setBillCycleDuration(MONTHLY).setPhaseType(EVERGREEN)), new MockPlan().setName("plan-foo-annual").setProduct(foo).setFinalPhase(new MockPlanPhase().setBillCycleDuration(null).setPhaseType(EVERGREEN)), new MockPlan().setName("plan-bar-annual").setProduct(bar).setFinalPhase(new MockPlanPhase().setBillCycleDuration(null).setPhaseType(EVERGREEN)) }; final DefaultPlan[] childPlans = new DefaultPlan[]{ new MockPlan().setName("plan-foo").setProduct(foo).setFinalPhase(new MockPlanPhase().setBillCycleDuration(ANNUAL).setPhaseType(DISCOUNT)), new MockPlan().setName("plan-bar").setProduct(bar).setFinalPhase(new MockPlanPhase().setBillCycleDuration(ANNUAL).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("child", foo, BillingPeriod.ANNUAL).getFinalPhase().getPhaseType(), PhaseType.DISCOUNT); Assert.assertEquals(set.getPlanFrom("child", foo, BillingPeriod.MONTHLY).getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); Assert.assertEquals(set.getPlanFrom(PriceListSet.DEFAULT_PRICELIST_NAME, foo, BillingPeriod.ANNUAL).getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); Assert.assertEquals(set.getPlanFrom(PriceListSet.DEFAULT_PRICELIST_NAME, foo, BillingPeriod.MONTHLY).getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); } }