@Test(groups = "fast") public void testAddExistingPlanWithNewCurrency() throws Exception { final StandaloneCatalog originalCatalog = XMLLoader.getObjectFromString(Resources.getResource("SpyCarBasic.xml").toExternalForm(), StandaloneCatalog.class); assertEquals(originalCatalog.getPriceLists().getAllPriceLists().size(), 1); assertEquals(originalCatalog.getPriceLists().getAllPriceLists().get(0).getName(), new PriceListDefault().getName()); assertEquals(originalCatalog.getPriceLists().getAllPriceLists().get(0).getPlans().size(), 3); final CatalogUpdater catalogUpdater = new CatalogUpdater(originalCatalog); final SimplePlanDescriptor desc = new DefaultSimplePlanDescriptor("standard-monthly", "Standard", ProductCategory.BASE, Currency.EUR, BigDecimal.TEN, BillingPeriod.MONTHLY, 30, TimeUnit.DAYS, ImmutableList.<String>of()); catalogUpdater.addSimplePlanDescriptor(desc); final StandaloneCatalog catalog = catalogUpdater.getCatalog(); final Plan plan = catalog.findCurrentPlan("standard-monthly"); assertEquals(plan.getName(), "standard-monthly"); assertEquals(plan.getInitialPhases().length, 1); assertEquals(plan.getInitialPhases()[0].getPhaseType(), PhaseType.TRIAL); assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrices().length, 0); assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrice(Currency.EUR), BigDecimal.ZERO); assertEquals(plan.getInitialPhases()[0].getName(), "standard-monthly-trial"); assertEquals(plan.getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); assertNull(plan.getFinalPhase().getFixed()); assertEquals(plan.getFinalPhase().getName(), "standard-monthly-evergreen"); assertEquals(plan.getFinalPhase().getRecurring().getBillingPeriod(), BillingPeriod.MONTHLY); assertEquals(plan.getFinalPhase().getRecurring().getRecurringPrice().getPrices().length, 3); assertEquals(plan.getFinalPhase().getRecurring().getRecurringPrice().getPrice(Currency.EUR), BigDecimal.TEN); }
assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrices().length, 1); assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrices()[0].getCurrency(), Currency.EUR); assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrices()[0].getValue(), BigDecimal.ZERO); assertEquals(plan.getInitialPhases()[0].getName(), "foo-monthly-trial");
assertEquals(newPhase.getUsages().length, initialPhase.getUsages().length); if (initialPhase.getFixed() != null) { assertEquals(newPhase.getFixed().getType(), initialPhase.getFixed().getType()); assertInternationalPrice(newPhase.getFixed().getPrice(), initialPhase.getFixed().getPrice(), override, true);
assertEquals(plan.getInitialPhases()[0].getName(), "dynamic-monthly-trial"); assertEquals(plan.getInitialPhases()[0].getPhaseType(), PhaseType.TRIAL); assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrices().length, 1); assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrices()[0].getCurrency(), Currency.USD); assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrices()[0].getValue(), BigDecimal.ZERO);
assertEquals(newPhase.getUsages().length, initialPhase.getUsages().length); if (initialPhase.getFixed() != null) { assertEquals(newPhase.getFixed().getType(), initialPhase.getFixed().getType()); assertInternationalPrice(newPhase.getFixed().getPrice(), initialPhase.getFixed().getPrice(), override, true);
(plan.getInitialPhases()[0].getPhaseType() != PhaseType.TRIAL || !plan.getInitialPhases()[0].getFixed().getPrice().isZero()))) { failedValidation = true;
assertEquals(newPhase.getUsages().length, initialPhase.getUsages().length); if (initialPhase.getFixed() != null) { assertEquals(newPhase.getFixed().getType(), initialPhase.getFixed().getType()); assertInternationalPrice(newPhase.getFixed().getPrice(), initialPhase.getFixed().getPrice(), override, true);
((DefaultInternationalPrice) plan.getInitialPhases()[0].getFixed().getPrice()).setPrices(null);
assertEquals(newPhase.getUsages().length, initialPhase.getUsages().length); if (initialPhase.getFixed() != null) { assertEquals(newPhase.getFixed().getType(), initialPhase.getFixed().getType()); assertInternationalPrice(newPhase.getFixed().getPrice(), initialPhase.getFixed().getPrice(), override, true);
public PhaseJson(final PlanPhase phase) throws CurrencyValueNull { final List<PriceJson> prices = new LinkedList<PriceJson>(); if (phase.getRecurring() != null && phase.getRecurring().getRecurringPrice() != null) { for (final Price price : phase.getRecurring().getRecurringPrice().getPrices()) { prices.add(new PriceJson(price)); } } final List<PriceJson> fixedPrices = new LinkedList<PriceJson>(); if (phase.getFixed() != null && phase.getFixed().getPrice() != null) { for (final Price price : phase.getFixed().getPrice().getPrices()) { fixedPrices.add(new PriceJson(price)); } } final DurationJson durationJson = new DurationJson(phase.getDuration().getUnit(), phase.getDuration().getNumber()); final List<UsageJson> usagesJson = buildUsagesJson(phase.getUsages()); this.type = phase.getPhaseType().toString(); this.prices = prices; this.fixedPrices = fixedPrices; this.duration = durationJson; this.usages = usagesJson; }
assertEquals(newPhase.getUsages().length, initialPhase.getUsages().length); if (initialPhase.getFixed() != null) { assertEquals(newPhase.getFixed().getType(), initialPhase.getFixed().getType()); assertInternationalPrice(newPhase.getFixed().getPrice(), initialPhase.getFixed().getPrice(), override, true);
@Test(groups = "fast") public void testAddExistingPlanWithNewCurrency() throws Exception { final StandaloneCatalog originalCatalog = XMLLoader.getObjectFromString(Resources.getResource("SpyCarBasic.xml").toExternalForm(), StandaloneCatalog.class); assertEquals(originalCatalog.getPriceLists().getAllPriceLists().size(), 1); assertEquals(originalCatalog.getPriceLists().getAllPriceLists().get(0).getName(), new PriceListDefault().getName()); assertEquals(originalCatalog.getPriceLists().getAllPriceLists().get(0).getPlans().size(), 3); final CatalogUpdater catalogUpdater = new CatalogUpdater(originalCatalog); final SimplePlanDescriptor desc = new DefaultSimplePlanDescriptor("standard-monthly", "Standard", ProductCategory.BASE, Currency.EUR, BigDecimal.TEN, BillingPeriod.MONTHLY, 30, TimeUnit.DAYS, ImmutableList.<String>of()); catalogUpdater.addSimplePlanDescriptor(desc); final StandaloneCatalog catalog = catalogUpdater.getCatalog(); final Plan plan = catalog.findCurrentPlan("standard-monthly"); assertEquals(plan.getName(), "standard-monthly"); assertEquals(plan.getInitialPhases().length, 1); assertEquals(plan.getInitialPhases()[0].getPhaseType(), PhaseType.TRIAL); assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrices().length, 0); assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrice(Currency.EUR), BigDecimal.ZERO); assertEquals(plan.getInitialPhases()[0].getName(), "standard-monthly-trial"); assertEquals(plan.getFinalPhase().getPhaseType(), PhaseType.EVERGREEN); assertNull(plan.getFinalPhase().getFixed()); assertEquals(plan.getFinalPhase().getName(), "standard-monthly-evergreen"); assertEquals(plan.getFinalPhase().getRecurring().getBillingPeriod(), BillingPeriod.MONTHLY); assertEquals(plan.getFinalPhase().getRecurring().getRecurringPrice().getPrices().length, 3); assertEquals(plan.getFinalPhase().getRecurring().getRecurringPrice().getPrice(Currency.EUR), BigDecimal.TEN); }
assertEquals(newPhase.getUsages().length, initialPhase.getUsages().length); if (initialPhase.getFixed() != null) { assertEquals(newPhase.getFixed().getType(), initialPhase.getFixed().getType()); assertInternationalPrice(newPhase.getFixed().getPrice(), initialPhase.getFixed().getPrice(), override, true);
assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrices().length, 1); assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrices()[0].getCurrency(), Currency.EUR); assertEquals(plan.getInitialPhases()[0].getFixed().getPrice().getPrices()[0].getValue(), BigDecimal.ZERO); assertEquals(plan.getInitialPhases()[0].getName(), "foo-monthly-trial");
final BigDecimal rate = subscription.getCurrentPhase().getFixed().getPrice().getPrice(Currency.USD); verifyTestResult(accountId, subscription.getId(), startDate, null, rate, clock.getUTCNow(), 1);
private BillingEvent createBillingEvent(final UUID subscriptionId, final UUID bundleId, final LocalDate startDate, final Plan plan, final PlanPhase planPhase, final int billCycleDayLocal) throws CatalogApiException { final SubscriptionBase sub = createSubscription(subscriptionId, bundleId); final Currency currency = Currency.USD; return invoiceUtil.createMockBillingEvent(null, sub, startDate.toDateTimeAtStartOfDay(), plan, planPhase, planPhase.getFixed().getPrice() == null ? null : planPhase.getFixed().getPrice().getPrice(currency), planPhase.getRecurring().getRecurringPrice() == null ? null : planPhase.getRecurring().getRecurringPrice().getPrice(currency), currency, planPhase.getRecurring().getBillingPeriod(), billCycleDayLocal, BillingMode.IN_ADVANCE, "Test", totalOrdering++, SubscriptionBaseTransitionType.CREATE); }
final BigDecimal rate = subscription.getCurrentPhase().getFixed().getPrice().getPrice(Currency.USD); verifyTestResult(accountId, subscription.getId(), startDate, null, rate, clock.getUTCNow(), 1);