public MockPlanPhase() { this(new MockInternationalPrice(), null); }
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)); }
public MockInternationalPrice(final DefaultPrice... price) { setPrices(price); }
final Currency currency = Currency.USD; final DefaultPrice zeroPrice = new DefaultPrice(BigDecimal.ZERO, Currency.USD); final MockInternationalPrice fixedPrice = new MockInternationalPrice(zeroPrice); final MockPlanPhase phase1 = new MockPlanPhase(null, fixedPrice); final MockInternationalPrice recurringPrice = new MockInternationalPrice(cheapPrice); final MockPlanPhase phase2 = new MockPlanPhase(recurringPrice, null); fixedPrice.getPrice(currency), null, currency, BillingPeriod.MONTHLY, 1, BillingModeType.IN_ADVANCE, "testEvent1", 1L, SubscriptionBaseTransitionType.CREATE); recurringPrice.getPrice(currency), currency, BillingPeriod.MONTHLY, 31, BillingModeType.IN_ADVANCE, "testEvent2", 2L, SubscriptionBaseTransitionType.CHANGE); events.add(event2);
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() ); }
final MockInternationalPrice fixedPrice = new MockInternationalPrice(zeroPrice); final MockPlanPhase phase1 = new MockPlanPhase(null, fixedPrice); final MockInternationalPrice recurringPrice = new MockInternationalPrice(cheapPrice); final MockPlanPhase phase2 = new MockPlanPhase(recurringPrice, null); final DateTime effectiveDate1 = invoiceUtil.buildDate(2011, 1, 1).toDateTimeAtStartOfDay(); final BillingEvent event1 = invoiceUtil.createMockBillingEvent(null, subscription, effectiveDate1, plan, phase1, fixedPrice.getPrice(currency), null, currency, BillingPeriod.MONTHLY, 1, BillingModeType.IN_ADVANCE, "testEvent1", 1L, SubscriptionBaseTransitionType.CREATE); recurringPrice.getPrice(currency), currency, BillingPeriod.MONTHLY, 31, BillingModeType.IN_ADVANCE, "testEvent2", 2L, SubscriptionBaseTransitionType.PHASE); events.add(event2);
public static MockPlanPhase create1USDMonthlyEvergreen() { return (MockPlanPhase) new MockPlanPhase(BillingPeriod.MONTHLY, PhaseType.EVERGREEN, new DefaultDuration().setUnit(TimeUnit.UNLIMITED), MockInternationalPrice.create1USD(), null).setPlan(MockPlan.createBicycleNoTrialEvergreen1USD()); }
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); }
@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); }
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)); }
private MockPlanPhase createMockMonthlyPlanPhase(@Nullable final BigDecimal recurringRate) { return new MockPlanPhase(new MockInternationalPrice(new DefaultPrice(recurringRate, Currency.USD)), null, BillingPeriod.MONTHLY); }
final MockInternationalPrice recurringPrice = new MockInternationalPrice(price); final MockPlanPhase phase = new MockPlanPhase(recurringPrice, null); final MockPlan plan = new MockPlan(phase); 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();
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); }
final MockInternationalPrice recurringPrice = new MockInternationalPrice(price1); final MockPlanPhase phase1 = new MockPlanPhase(recurringPrice, null, BillingPeriod.MONTHLY, PhaseType.TRIAL); final MockPlan plan1 = new MockPlan(phase1); recurringPrice.getPrice(currency), currency, BillingPeriod.MONTHLY, 1, BillingModeType.IN_ADVANCE, "testEvent1", 1L, SubscriptionBaseTransitionType.CREATE); final MockInternationalPrice recurringPrice2 = new MockInternationalPrice(price2); final MockPlanPhase phase2 = new MockPlanPhase(recurringPrice, null, BillingPeriod.MONTHLY, PhaseType.TRIAL); final MockPlan plan2 = new MockPlan(phase2); recurringPrice2.getPrice(currency), currency, BillingPeriod.MONTHLY, 1, BillingModeType.IN_ADVANCE, "testEvent2", 2L, SubscriptionBaseTransitionType.CREATE); events.add(event2);
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 MockInternationalPrice createUSD(final String value) { return new MockInternationalPrice(new DefaultPrice().setCurrency(Currency.USD).setValue(new BigDecimal(value))); }
public static MockInternationalPrice create0USD() { return new MockInternationalPrice(new DefaultPrice().setCurrency(Currency.USD).setValue(BigDecimal.ZERO)); }
@Test(groups = "fast") public void testZeroValue() throws URISyntaxException, CatalogApiException { final StandaloneCatalog c = new MockCatalog(); c.setSupportedCurrencies(new Currency[]{Currency.GBP, Currency.EUR, Currency.USD, Currency.BRL, Currency.MXN}); final DefaultInternationalPrice p0 = new MockInternationalPrice(); p0.setPrices(null); p0.initialize(c, new URI("foo:bar")); final DefaultInternationalPrice p1 = new MockInternationalPrice(); p1.setPrices(new DefaultPrice[]{ new DefaultPrice().setCurrency(Currency.GBP).setValue(new BigDecimal(1)), new DefaultPrice().setCurrency(Currency.EUR).setValue(new BigDecimal(1)), new DefaultPrice().setCurrency(Currency.USD).setValue(new BigDecimal(1)), new DefaultPrice().setCurrency(Currency.BRL).setValue(new BigDecimal(1)), new DefaultPrice().setCurrency(Currency.MXN).setValue(new BigDecimal(1)), }); p1.initialize(c, new URI("foo:bar")); Assert.assertEquals(p0.getPrice(Currency.GBP), new BigDecimal(0)); Assert.assertEquals(p0.getPrice(Currency.EUR), new BigDecimal(0)); Assert.assertEquals(p0.getPrice(Currency.USD), new BigDecimal(0)); Assert.assertEquals(p0.getPrice(Currency.BRL), new BigDecimal(0)); Assert.assertEquals(p0.getPrice(Currency.MXN), new BigDecimal(0)); Assert.assertEquals(p1.getPrice(Currency.GBP), new BigDecimal(1)); Assert.assertEquals(p1.getPrice(Currency.EUR), new BigDecimal(1)); Assert.assertEquals(p1.getPrice(Currency.USD), new BigDecimal(1)); Assert.assertEquals(p1.getPrice(Currency.BRL), new BigDecimal(1)); Assert.assertEquals(p1.getPrice(Currency.MXN), new BigDecimal(1)); }
public static MockInternationalPrice create1USD() { return new MockInternationalPrice(new DefaultPrice().setCurrency(Currency.USD).setValue(BigDecimal.ONE)); }