public MockPlanPhase() { this(new MockInternationalPrice(), null); }
public static MockInternationalPrice createUSD(final String value) { return new MockInternationalPrice(new DefaultPrice().setCurrency(Currency.USD).setValue(new BigDecimal(value))); }
public static MockInternationalPrice create1USD() { return new MockInternationalPrice(new DefaultPrice().setCurrency(Currency.USD).setValue(BigDecimal.ONE)); }
@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)); }
public static MockInternationalPrice create0USD() { return new MockInternationalPrice(new DefaultPrice().setCurrency(Currency.USD).setValue(BigDecimal.ZERO)); }
public MockPlanPhase(final MockPlan mockPlan) { setPhaseType(PhaseType.EVERGREEN); setDuration(new DefaultDuration().setNumber(-1).setUnit(TimeUnit.UNLIMITED)); setPlan(mockPlan); setFixed(new MockFixed(null)); setRecurring(new MockRecurring(BillingPeriod.MONTHLY, new MockInternationalPrice())); }
public MockPlanPhase(final Plan plan, final PhaseType phaseType) { setPhaseType(phaseType); setDuration(new DefaultDuration().setNumber(-1).setUnit(TimeUnit.UNLIMITED)); setPlan(plan); setFixed(new MockFixed(null)); setRecurring(new MockRecurring(BillingPeriod.MONTHLY, new MockInternationalPrice())); } }
@Test(groups = "fast") public void testNegativeValuePrices() { final StandaloneCatalog c = new MockCatalog(); c.setSupportedCurrencies(new Currency[]{Currency.GBP, Currency.EUR, Currency.USD, Currency.BRL, Currency.MXN}); 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)), }); final ValidationErrors errors = p1.validate(c, new ValidationErrors()); errors.log(log); Assert.assertEquals(errors.size(), 3); } }
public MockPlanPhase() { this(new MockInternationalPrice(), null); }
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); }
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 createMockAnnualPlanPhase(final BigDecimal recurringRate, final PhaseType phaseType) { return new MockPlanPhase(new MockInternationalPrice(new DefaultPrice(recurringRate, Currency.USD)), null, BillingPeriod.ANNUAL, phaseType); }
private MockPlanPhase createMockMonthlyPlanPhase(final BigDecimal recurringRate, final PhaseType phaseType) { return new MockPlanPhase(new MockInternationalPrice(new DefaultPrice(recurringRate, Currency.USD)), null, BillingPeriod.MONTHLY, phaseType); }
public static MockInternationalPrice createUSD(final String value) { return new MockInternationalPrice(new DefaultPrice().setCurrency(Currency.USD).setValue(new BigDecimal(value))); }
@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)); }
public static MockInternationalPrice create0USD() { return new MockInternationalPrice(new DefaultPrice().setCurrency(Currency.USD).setValue(BigDecimal.ZERO)); }
public static MockInternationalPrice create1USD() { return new MockInternationalPrice(new DefaultPrice().setCurrency(Currency.USD).setValue(BigDecimal.ONE)); }
public MockPlanPhase(final MockPlan mockPlan) { setPhaseType(PhaseType.EVERGREEN); setDuration(new DefaultDuration().setNumber(-1).setUnit(TimeUnit.UNLIMITED)); setPlan(mockPlan); setFixed(new MockFixed(null)); setRecurring(new MockRecurring(BillingPeriod.MONTHLY, new MockInternationalPrice())); }
public MockPlanPhase(final Plan plan, final PhaseType phaseType) { setPhaseType(phaseType); setDuration(new DefaultDuration().setNumber(-1).setUnit(TimeUnit.UNLIMITED)); setPlan(plan); setFixed(new MockFixed(null)); setRecurring(new MockRecurring(BillingPeriod.MONTHLY, new MockInternationalPrice())); } }