public MockPlanPhase() { this(new MockInternationalPrice(), null); }
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)); }
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, BillingMode.IN_ADVANCE, "testEvent1", 1L, SubscriptionBaseTransitionType.CREATE); recurringPrice.getPrice(currency), currency, BillingPeriod.MONTHLY, 31, BillingMode.IN_ADVANCE, "testEvent2", 2L, SubscriptionBaseTransitionType.CHANGE); events.add(event2);
public MockInternationalPrice(final DefaultPrice... price) { setPrices(price); }
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, BillingMode.IN_ADVANCE, "testEvent1", 1L, SubscriptionBaseTransitionType.CREATE); recurringPrice.getPrice(currency), currency, BillingPeriod.MONTHLY, 31, BillingMode.IN_ADVANCE, "testEvent2", 2L, SubscriptionBaseTransitionType.PHASE); events.add(event2);
public MockInternationalPrice(final DefaultPrice... price) { setPrices(price); }
public static MockInternationalPrice createUSD(final String value) { return new MockInternationalPrice(new DefaultPrice().setCurrency(Currency.USD).setValue(new BigDecimal(value))); }
@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 fixedPrice = new MockInternationalPrice(price); final MockPlanPhase phase = new MockPlanPhase(null, fixedPrice); 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, fixedPrice.getPrice(currency), null, currency, BillingPeriod.MONTHLY, 15, BillingMode.IN_ADVANCE, "testEvent", 1L, SubscriptionBaseTransitionType.CREATE); final BillingEventSet events = new MockBillingEventSet(); events.add(event); final LocalDate targetDate = invoiceUtil.buildDate(2011, 1, 15); final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, context); final Invoice invoice = invoiceWithMetadata.getInvoice(); assertNotNull(invoice); }
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 static MockPlanPhase create1USDMonthlyEvergreen() { return (MockPlanPhase) new MockPlanPhase(BillingPeriod.MONTHLY, PhaseType.EVERGREEN, new DefaultDuration().setUnit(TimeUnit.UNLIMITED).setNumber(-1), MockInternationalPrice.create1USD(), null).setPlan(MockPlan.createBicycleNoTrialEvergreen1USD()); }
public static MockInternationalPrice create1USD() { return new MockInternationalPrice(new DefaultPrice().setCurrency(Currency.USD).setValue(BigDecimal.ONE)); }
final Currency currency = Currency.USD; final SubscriptionBase subscription = createSubscription(); final MockInternationalPrice recurringPrice = new MockInternationalPrice(new DefaultPrice(new BigDecimal("2.9500"), Currency.USD)); final MockPlanPhase phase = new MockPlanPhase(recurringPrice, null); final Plan plan = new MockPlan(phase); final InvoiceItem recurringInvoiceItem = new RecurringInvoiceItem(existingInvoice.getId(), accountId, subscription.getBundleId(), subscription.getId(), null, plan.getName(), phase.getName(), startDate, endDate, recurringPrice.getPrice(currency), recurringPrice.getPrice(currency), Currency.USD); existingInvoice.addInvoiceItem(recurringInvoiceItem); final BillingEvent event = invoiceUtil.createMockBillingEvent(null, subscription, new DateTime("2013-06-15", DateTimeZone.UTC), plan, phase, null, recurringPrice.getPrice(currency), currency, BillingPeriod.MONTHLY, 15, BillingMode.IN_ADVANCE, "testEvent", 1L, SubscriptionBaseTransitionType.CREATE);
@Test(groups = "fast") public void testValidation() { final MockCatalog catalog = new MockCatalog(); DefaultPlanPhase pp = MockPlanPhase.createUSDMonthlyEvergreen(null, "1.00").setPlan(MockPlan.createBicycleNoTrialEvergreen1USD()); pp.initialize(catalog); ValidationErrors errors = pp.validate(catalog, new ValidationErrors()); errors.log(log); Assert.assertEquals(errors.size(), 1); pp = MockPlanPhase.createUSDMonthlyEvergreen("1.00", null).setRecurring(new MockRecurring(BillingPeriod.NO_BILLING_PERIOD, MockInternationalPrice.createUSD("1.00")).setPhase(pp)).setPlan(MockPlan.createBicycleNoTrialEvergreen1USD()); pp.initialize(catalog); errors = pp.validate(catalog, new ValidationErrors()); errors.log(log); Assert.assertEquals(errors.size(), 1); }
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() ); }
@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(new DefaultPrice[0]); p0.initialize(c); 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); 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)); }
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, BillingMode.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, BillingMode.IN_ADVANCE, "testEvent2", 2L, SubscriptionBaseTransitionType.CREATE); events.add(event2);
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 static MockPlanPhase create1USDMonthlyEvergreen() { return (MockPlanPhase) new MockPlanPhase(BillingPeriod.MONTHLY, PhaseType.EVERGREEN, new DefaultDuration().setUnit(TimeUnit.UNLIMITED).setNumber(-1), MockInternationalPrice.create1USD(), null).setPlan(MockPlan.createBicycleNoTrialEvergreen1USD()); }
public static MockInternationalPrice create0USD() { return new MockInternationalPrice(new DefaultPrice().setCurrency(Currency.USD).setValue(BigDecimal.ZERO)); }