use of org.killbill.billing.catalog.DefaultInternationalPrice in project killbill by killbill.
the class StandaloneCatalogMapper method toDefaultInternationalPrice.
private DefaultInternationalPrice toDefaultInternationalPrice(final InternationalPrice input) {
final DefaultInternationalPrice result = new DefaultInternationalPrice();
result.setPrices(toDefaultPrices(ImmutableList.copyOf(input.getPrices())));
return result;
}
use of org.killbill.billing.catalog.DefaultInternationalPrice in project killbill by killbill.
the class TestXMLWriter method testAddPlan.
@Test(groups = "fast")
public void testAddPlan() throws Exception {
final StandaloneCatalog catalog = XMLLoader.getObjectFromString(Resources.getResource("SpyCarBasic.xml").toExternalForm(), StandaloneCatalog.class);
final MutableStaticCatalog mutableCatalog = new DefaultMutableStaticCatalog(catalog);
final DefaultProduct newProduct = new DefaultProduct();
newProduct.setName("Dynamic");
newProduct.setCatagory(ProductCategory.BASE);
newProduct.initialize((StandaloneCatalog) mutableCatalog, new URI("dummy"));
mutableCatalog.addProduct(newProduct);
final DefaultPlanPhase trialPhase = new DefaultPlanPhase();
trialPhase.setPhaseType(PhaseType.TRIAL);
trialPhase.setDuration(new DefaultDuration().setUnit(TimeUnit.DAYS).setNumber(14));
trialPhase.setFixed(new DefaultFixed().setFixedPrice(new DefaultInternationalPrice().setPrices(new DefaultPrice[] { new DefaultPrice().setCurrency(Currency.USD).setValue(BigDecimal.ZERO) })));
final DefaultPlanPhase evergreenPhase = new DefaultPlanPhase();
evergreenPhase.setPhaseType(PhaseType.EVERGREEN);
evergreenPhase.setDuration(new DefaultDuration().setUnit(TimeUnit.MONTHS).setNumber(1));
evergreenPhase.setRecurring(new DefaultRecurring().setBillingPeriod(BillingPeriod.MONTHLY).setRecurringPrice(new DefaultInternationalPrice().setPrices(new DefaultPrice[] { new DefaultPrice().setCurrency(Currency.USD).setValue(BigDecimal.TEN) })));
final DefaultPlan newPlan = new DefaultPlan();
newPlan.setName("dynamic-monthly");
newPlan.setPriceListName(DefaultPriceListSet.DEFAULT_PRICELIST_NAME);
newPlan.setProduct(newProduct);
newPlan.setInitialPhases(new DefaultPlanPhase[] { trialPhase });
newPlan.setFinalPhase(evergreenPhase);
// TODO Ordering breaks
mutableCatalog.addPlan(newPlan);
newPlan.initialize((StandaloneCatalog) mutableCatalog, new URI("dummy"));
final String newCatalogStr = XMLWriter.writeXML((StandaloneCatalog) mutableCatalog, StandaloneCatalog.class);
final StandaloneCatalog newCatalog = XMLLoader.getObjectFromStream(new URI("dummy"), new ByteArrayInputStream(newCatalogStr.getBytes(Charset.forName("UTF-8"))), StandaloneCatalog.class);
assertEquals(newCatalog.getCurrentPlans().size(), catalog.getCurrentPlans().size() + 1);
final Plan plan = newCatalog.findCurrentPlan("dynamic-monthly");
assertEquals(plan.getName(), "dynamic-monthly");
assertEquals(plan.getPriceListName(), DefaultPriceListSet.DEFAULT_PRICELIST_NAME);
assertEquals(plan.getProduct().getName(), "Dynamic");
assertEquals(plan.getProduct().getCategory(), ProductCategory.BASE);
assertEquals(plan.getInitialPhases().length, 1);
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(plan.getFinalPhase().getName(), "dynamic-monthly-evergreen");
assertEquals(plan.getFinalPhase().getPhaseType(), PhaseType.EVERGREEN);
assertEquals(plan.getFinalPhase().getRecurring().getBillingPeriod(), BillingPeriod.MONTHLY);
assertEquals(plan.getFinalPhase().getRecurring().getRecurringPrice().getPrices().length, 1);
assertEquals(plan.getFinalPhase().getRecurring().getRecurringPrice().getPrices()[0].getCurrency(), Currency.USD);
assertEquals(plan.getFinalPhase().getRecurring().getRecurringPrice().getPrices()[0].getValue(), BigDecimal.TEN);
}
use of org.killbill.billing.catalog.DefaultInternationalPrice in project killbill by killbill.
the class TestUsageInArrearBase method createDefaultTieredBlock.
protected DefaultTieredBlock createDefaultTieredBlock(final String unit, final int size, final int max, final BigDecimal btcPrice) {
final DefaultTieredBlock block = new DefaultTieredBlock();
block.setUnit(new DefaultUnit().setName(unit));
block.setSize(new Double(size));
final DefaultPrice[] prices = new DefaultPrice[1];
prices[0] = new DefaultPrice();
prices[0].setCurrency(Currency.BTC).setValue(btcPrice);
block.setPrice(new DefaultInternationalPrice().setPrices(prices));
block.setMax(new Double(max));
return block;
}
use of org.killbill.billing.catalog.DefaultInternationalPrice in project killbill by killbill.
the class TestUsageInArrearBase method createDefaultTierWithLimits.
protected DefaultTier createDefaultTierWithLimits(final BigDecimal recurringAmountInCurrency, final DefaultLimit... limits) {
final DefaultTier tier = new DefaultTier();
tier.setLimits(limits);
final DefaultPrice[] prices = new DefaultPrice[1];
prices[0] = new DefaultPrice().setCurrency(currency).setValue(recurringAmountInCurrency);
final DefaultInternationalPrice price = new DefaultInternationalPrice().setPrices(prices);
tier.setRecurringPrice(price);
return tier;
}
Aggregations