analytics: prefer private fields over protected ones

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
entitlement: reformat SubscriptionTransitionData

No functional change.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
entitlement: send future events

Analytics needs to know when future changes are requested.
Hook into the AuditedEntitlementDao and send an event on the bus right
after adding the future change on the notification queue.

Although it seems to work, there are two problems with this patch.
First, it adds some more logic in the (already complicated) dao.
Second, I am jumping through hoops to generate the actual event: since I
am in the middle of the transaction, I need to add some logic to find
the previous state for a given event the subscription is in (some of
that state might be on disk, some might still be in memory, in the transaction).

I am open to suggestions to refactor this.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
analytics: store subscription_id in bst

This will be useful to handle future events.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
analytics: start listening to future events

Due to ordering issues, we may now need to update transitions in bst.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
Revert "analytics: store subscription_id in bst"

This reverts commit 7634ba410e437337d00e38d2e622b4057fdca364.

We actually already store the subscription_id in the prev/next objects.
Although it makes sense in the Java code to have subscription_id in the
BusinessSubscription object, it feels weird to have it duplicated in the
table (prev/next). But let's keep it for now.

Conflicts:

	analytics/src/main/java/com/ning/billing/analytics/BusinessSubscriptionTransitionRecorder.java

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
beatrix: add simple test for future events in TestAnalytics

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
util: fix potential NPE in PersistentBus

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
beatrix: update simple Analytics test to verify system events

Make sure not to duplicate events in Analytics: requested phase events
and effective system phase events go in pair.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
analytics: fix test failure

Implement correctly MockBusinessSubscriptionTransitionSqlDao.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
analytics: fix test failures for re-add events

For re-add transitions, make sure the previous subscription is always
null.

Also, move all the dao logic into the transaction.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
beatrix: add cancellation tests for Analytics

They don't pass yet.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
Revert "entitlement: send future events"

This reverts commit acb999c429d343e863ce401623ec8686641266ac.

We're going to take a trigger approach and change Analytics to handle
it.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
util: extract entitlement mocks from junction

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
api: change Subscription interface

Add List<EffectiveSubscriptionEvent> getAllTransitions() method: this
will be useful for Analytics to rebuild all transactions given a
subscription.

While we're at it, remove the Analytics-specific MockSubscription object
and use the one shared in util.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
entitlement: fix test failure due to the beginning of the month

July has 31 days!

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
junction: fix test failure

Add a new constructor in MockSubscription to support TestBillingApi.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
entitlement: reimplement logic to send requested events

Requested events should now be used only as triggers: they are shallow
objects (only contain top level information, such as bundle and
subscription id, and relevant dates), sent once per api call.
Listeners are expected to call back the entitlement subsystem to get
the full list of rehydrated events.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
analytics: revisit bst listener

On requested or effective events, Analytics will now call back
entitlement and rebuild the whole history for a given bundle.
This greatly simplify the code for requested events and adds
support for repair.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
Merge branch 'integration' into entitlement-future-events