Search in sources :

Example 1 with Price

use of org.killbill.billing.catalog.api.Price in project killbill by killbill.

the class TestDefaultPriceOverride method assertInternationalPrice.

private void assertInternationalPrice(final InternationalPrice newInternationalPrice, final InternationalPrice initInternationalPrice, final PlanPhasePriceOverride override, final boolean isFixed) throws CatalogApiException {
    if (initInternationalPrice.getPrices().length == 0) {
        if (override != null) {
            assertEquals(newInternationalPrice.getPrices().length, 1);
            assertEquals(newInternationalPrice.getPrice(override.getCurrency()).compareTo(isFixed ? override.getFixedPrice() : override.getRecurringPrice()), 0);
        }
    } else {
        assertEquals(newInternationalPrice.getPrices().length, initInternationalPrice.getPrices().length);
        for (int i = 0; i < newInternationalPrice.getPrices().length; i++) {
            final Price initPrice = initInternationalPrice.getPrices()[i];
            final Price newPrice = newInternationalPrice.getPrices()[i];
            if (override != null && override.getCurrency() == initPrice.getCurrency() && ((isFixed && override.getFixedPrice() != null) || (!isFixed && override.getRecurringPrice() != null))) {
                assertEquals(newPrice.getValue().compareTo(isFixed ? override.getFixedPrice() : override.getRecurringPrice()), 0);
            } else {
                if (initPrice != null && initPrice.getValue() != null) {
                    assertEquals(newPrice.getValue().compareTo(initPrice.getValue()), 0);
                }
            }
        }
    }
}
Also used : InternationalPrice(org.killbill.billing.catalog.api.InternationalPrice) Price(org.killbill.billing.catalog.api.Price)

Aggregations

InternationalPrice (org.killbill.billing.catalog.api.InternationalPrice)1 Price (org.killbill.billing.catalog.api.Price)1