Search in sources :

Example 6 with ValidationError

use of org.killbill.xmlloader.ValidationError in project killbill by killbill.

the class DefaultUsage method validate.

@Override
public ValidationErrors validate(final StandaloneCatalog catalog, final ValidationErrors errors) {
    if (billingMode == BillingMode.IN_ADVANCE && usageType == UsageType.CAPACITY && limits.length == 0) {
        errors.add(new ValidationError(String.format("Usage [IN_ADVANCE CAPACITY] section of phase %s needs to define some limits", phase.toString()), DefaultUsage.class, ""));
    }
    if (billingMode == BillingMode.IN_ADVANCE && usageType == UsageType.CONSUMABLE && blocks.length == 0) {
        errors.add(new ValidationError(String.format("Usage [IN_ADVANCE CONSUMABLE] section of phase %s needs to define some blocks", phase.toString()), DefaultUsage.class, ""));
    }
    if (billingMode == BillingMode.IN_ARREAR && tiers.length == 0) {
        errors.add(new ValidationError(String.format("Usage [IN_ARREAR] section of phase %s needs to define some tiers", phase.toString()), DefaultUsage.class, ""));
    }
    validateCollection(catalog, errors, limits);
    validateCollection(catalog, errors, tiers);
    return errors;
}
Also used : ValidationError(org.killbill.xmlloader.ValidationError) TierPriceOverride(org.killbill.billing.catalog.api.TierPriceOverride) UsagePriceOverride(org.killbill.billing.catalog.api.UsagePriceOverride) TieredBlockPriceOverride(org.killbill.billing.catalog.api.TieredBlockPriceOverride)

Aggregations

ValidationError (org.killbill.xmlloader.ValidationError)6 UsagePriceOverride (org.killbill.billing.catalog.api.UsagePriceOverride)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 TreeSet (java.util.TreeSet)1 Callable (java.util.concurrent.Callable)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 DefaultVersionedCatalog (org.killbill.billing.catalog.DefaultVersionedCatalog)1 StandaloneCatalog (org.killbill.billing.catalog.StandaloneCatalog)1 StandaloneCatalogWithPriceOverride (org.killbill.billing.catalog.StandaloneCatalogWithPriceOverride)1 CatalogApiException (org.killbill.billing.catalog.api.CatalogApiException)1 PlanPhase (org.killbill.billing.catalog.api.PlanPhase)1 PlanPhasePriceOverride (org.killbill.billing.catalog.api.PlanPhasePriceOverride)1 StaticCatalog (org.killbill.billing.catalog.api.StaticCatalog)1 TierPriceOverride (org.killbill.billing.catalog.api.TierPriceOverride)1 TieredBlockPriceOverride (org.killbill.billing.catalog.api.TieredBlockPriceOverride)1