use of org.killbill.billing.catalog.api.Usage in project killbill by killbill.
the class TestInvoiceHelper method createMockBillingEvent.
public BillingEvent createMockBillingEvent(@Nullable final Account account, final SubscriptionBase subscription, final DateTime effectiveDate, final Plan plan, final PlanPhase planPhase, @Nullable final BigDecimal fixedPrice, @Nullable final BigDecimal recurringPrice, final Currency currency, final BillingPeriod billingPeriod, final int billCycleDayLocal, final BillingMode billingMode, final String description, final long totalOrdering, final SubscriptionBaseTransitionType type) {
final Account mockAccount = Mockito.mock(Account.class);
Mockito.when(mockAccount.getTimeZone()).thenReturn(DateTimeZone.UTC);
return new BillingEvent() {
@Override
public int getBillCycleDayLocal() {
return billCycleDayLocal;
}
@Override
public SubscriptionBase getSubscription() {
return subscription;
}
@Override
public DateTime getEffectiveDate() {
return effectiveDate;
}
@Override
public PlanPhase getPlanPhase() {
return planPhase;
}
@Override
public Plan getPlan() {
return plan;
}
@Override
public BillingPeriod getBillingPeriod() {
return billingPeriod;
}
@Override
public String getDescription() {
return description;
}
@Override
public BigDecimal getFixedPrice() {
return fixedPrice;
}
@Override
public BigDecimal getRecurringPrice(DateTime effectiveDate) {
return recurringPrice;
}
@Override
public Currency getCurrency() {
return currency;
}
@Override
public SubscriptionBaseTransitionType getTransitionType() {
return type;
}
@Override
public Long getTotalOrdering() {
return totalOrdering;
}
@Override
public DateTimeZone getTimeZone() {
return DateTimeZone.UTC;
}
@Override
public List<Usage> getUsages() {
return Collections.emptyList();
}
@Override
public int compareTo(final BillingEvent e1) {
if (!getSubscription().getId().equals(e1.getSubscription().getId())) {
// First order by subscription
return getSubscription().getId().compareTo(e1.getSubscription().getId());
} else {
// subscriptions are the same
if (!getEffectiveDate().equals(e1.getEffectiveDate())) {
// Secondly order by date
return getEffectiveDate().compareTo(e1.getEffectiveDate());
} else {
// dates and subscriptions are the same
return getTotalOrdering().compareTo(e1.getTotalOrdering());
}
}
}
};
}
Aggregations