use of org.killbill.billing.entitlement.AccountEventsStreams in project killbill by killbill.
the class TestEntitlementUtils method computeFutureBlockingStatesForAssociatedAddonsViaAccount.
private Collection<BlockingState> computeFutureBlockingStatesForAssociatedAddonsViaAccount(final DefaultEntitlement baseEntitlement) throws EntitlementApiException {
final AccountEventsStreams accountEventsStreams = eventsStreamBuilder.buildForAccount(internalCallContext);
final EventsStream eventsStream = Iterables.<EventsStream>find(Iterables.<EventsStream>concat(accountEventsStreams.getEventsStreams().values()), new Predicate<EventsStream>() {
@Override
public boolean apply(final EventsStream input) {
return input.getSubscriptionBase().getId().equals(baseEntitlement.getId());
}
});
return eventsStream.computeAddonsBlockingStatesForFutureSubscriptionBaseEvents();
}
use of org.killbill.billing.entitlement.AccountEventsStreams in project killbill by killbill.
the class DefaultEntitlementApiBase method getAllEntitlementsForAccount.
public AccountEntitlements getAllEntitlementsForAccount(final InternalTenantContext tenantContext) throws EntitlementApiException {
final AccountEventsStreams accountEventsStreams = eventsStreamBuilder.buildForAccount(tenantContext);
final Map<UUID, Collection<Entitlement>> entitlementsPerBundle = new HashMap<UUID, Collection<Entitlement>>();
for (final UUID bundleId : accountEventsStreams.getEventsStreams().keySet()) {
if (entitlementsPerBundle.get(bundleId) == null) {
entitlementsPerBundle.put(bundleId, new LinkedList<Entitlement>());
}
for (final EventsStream eventsStream : accountEventsStreams.getEventsStreams().get(bundleId)) {
final Entitlement entitlement = new DefaultEntitlement(eventsStream, eventsStreamBuilder, entitlementApi, pluginExecution, blockingStateDao, subscriptionInternalApi, checker, notificationQueueService, entitlementUtils, dateHelper, clock, securityApi, tenantContext, internalCallContextFactory);
entitlementsPerBundle.get(bundleId).add(entitlement);
}
}
return new DefaultAccountEntitlements(accountEventsStreams, entitlementsPerBundle);
}
use of org.killbill.billing.entitlement.AccountEventsStreams in project killbill by killbill.
the class DefaultEntitlementApi method getAllEntitlementsForAccountId.
@Override
public List<Entitlement> getAllEntitlementsForAccountId(final UUID accountId, final TenantContext tenantContext) throws EntitlementApiException {
final EntitlementApi entitlementApi = this;
final InternalTenantContext context = internalCallContextFactory.createInternalTenantContext(accountId, tenantContext);
final AccountEventsStreams accountEventsStreams = eventsStreamBuilder.buildForAccount(context);
final List<EventsStream> eventsStreams = ImmutableList.<EventsStream>copyOf(Iterables.<EventsStream>concat(accountEventsStreams.getEventsStreams().values()));
return Lists.<EventsStream, Entitlement>transform(eventsStreams, new Function<EventsStream, Entitlement>() {
@Override
public Entitlement apply(final EventsStream eventsStream) {
return new DefaultEntitlement(eventsStream, eventsStreamBuilder, entitlementApi, pluginExecution, blockingStateDao, subscriptionBaseInternalApi, checker, notificationQueueService, entitlementUtils, dateHelper, clock, securityApi, context, internalCallContextFactory);
}
});
}
use of org.killbill.billing.entitlement.AccountEventsStreams in project killbill by killbill.
the class TestEntitlementUtils method computeBlockingStatesForAssociatedAddonsViaAccount.
private Collection<BlockingState> computeBlockingStatesForAssociatedAddonsViaAccount(final DefaultEntitlement baseEntitlement, final DateTime effectiveDate) throws EntitlementApiException {
final AccountEventsStreams accountEventsStreams = eventsStreamBuilder.buildForAccount(internalCallContext);
final EventsStream eventsStream = Iterables.<EventsStream>find(Iterables.<EventsStream>concat(accountEventsStreams.getEventsStreams().values()), new Predicate<EventsStream>() {
@Override
public boolean apply(final EventsStream input) {
return input.getSubscriptionBase().getId().equals(baseEntitlement.getId());
}
});
return eventsStream.computeAddonsBlockingStatesForNextSubscriptionBaseEvent(effectiveDate);
}
Aggregations