entitlement: refresh object state before r/w calls

Make sure to get the latest state from disk before attempting
a cancellation, change plan or uncancellation.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: trivial cleanups in TestDefaultEntitlementApi

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: first pass at blocking add-ons for base plan changes/cancellations

Implement the same logic as in subscription base, i.e. determine if add-ons need
to be blocked in case of base plan cancellations and plan changes.

The bulk of the logic is in EntitlementUtils, called from DefaultEntitlement and
DefaultBlockingStateDao.

This is a first pass, in order to get early feedback on the implementation. We still
need to think through (and probably write tests) for uncancel and transfer scenarii (i.e.
do we do the right thing in these cases?).

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: integrate code review comments

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
Merge remote-tracking branch 'origin/master' into entitlement-bug-fixes

Conflicts:
	pom.xml

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
beatrix: junction: fix tests after recent entitlement changes

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: integrate code review comments

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: refactor DefaultEntitlementApi

Introduce EventsStream, an object that contains all of the states
required to answer entitlement queries.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: refactor DefaultEntitlement

Make it use the new EventsStream object.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: move the add-ons cancellation computation to EventsStream

This gets rid of the BlockingStateDao cycle in EntitlementUtils.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
pom.xml: update killbill-oss-parent to 0.5.6

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
Merge remote-tracking branch 'origin/master' into entitlement-bug-fixes
Merge remote-tracking branch 'origin/master' into entitlement-bug-fixes
Yet another pass at reordering the timeline events for when effectiveDate match.
This issue was when we introduce multiple subscriptions in the stream, and where we first need to add an ordering at the subscription level

Added test case to verify this works.
entitlement: add missing events assertions in tests

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: make tests more robust

Add assertion checks on EntitlementTestListenerStatus. This uncovered
the fact that we were sending bus events via the notification queue
for deleted entitlement events. This has been fixed.

Tests seem less flacky now too.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: lower log level in tests

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: implement toString/equals/hashCode in DefaultEffectiveEntitlementEvent

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
util: fix handleEntitlementEvents implementation in TestApiListener

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
beatrix: add missing listener status checks

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>