@Test(groups = "fast")
 public void testEquals() throws Exception {
   final DateTime now = new DateTime();
   final BusinessSubscriptionEvent event =
       BusinessSubscriptionEvent.subscriptionChanged(
           subscription.getCurrentPlan().getName(), catalog, now, now);
   Assert.assertSame(event, event);
   Assert.assertEquals(event, event);
   Assert.assertTrue(event.equals(event));
 }
  @Test(groups = "fast")
  public void testFromSubscription() throws Exception {
    BusinessSubscriptionEvent event;

    final DateTime now = new DateTime();

    event =
        BusinessSubscriptionEvent.subscriptionCreated(
            subscription.getCurrentPlan().getName(), catalog, now, now);
    Assert.assertEquals(event.getEventType(), BusinessSubscriptionEvent.EventType.ADD);
    Assert.assertEquals(event.getCategory(), product.getCategory());
    Assert.assertEquals(event.toString(), "ADD_BASE");

    event =
        BusinessSubscriptionEvent.subscriptionCancelled(
            subscription.getCurrentPlan().getName(), catalog, now, now);
    Assert.assertEquals(event.getEventType(), BusinessSubscriptionEvent.EventType.CANCEL);
    Assert.assertEquals(event.getCategory(), product.getCategory());
    Assert.assertEquals(event.toString(), "CANCEL_BASE");

    event =
        BusinessSubscriptionEvent.subscriptionChanged(
            subscription.getCurrentPlan().getName(), catalog, now, now);
    Assert.assertEquals(event.getEventType(), BusinessSubscriptionEvent.EventType.CHANGE);
    Assert.assertEquals(event.getCategory(), product.getCategory());
    Assert.assertEquals(event.toString(), "CHANGE_BASE");

    event =
        BusinessSubscriptionEvent.subscriptionPhaseChanged(
            subscription.getCurrentPlan().getName(), subscription.getState(), catalog, now, now);
    // The subscription is still active, it's a system change
    Assert.assertEquals(event.getEventType(), BusinessSubscriptionEvent.EventType.SYSTEM_CHANGE);
    Assert.assertEquals(event.getCategory(), product.getCategory());
    Assert.assertEquals(event.toString(), "SYSTEM_CHANGE_BASE");

    subscription = new MockSubscription(Subscription.SubscriptionState.CANCELLED, plan, phase);
    event =
        BusinessSubscriptionEvent.subscriptionPhaseChanged(
            subscription.getCurrentPlan().getName(), subscription.getState(), catalog, now, now);
    // The subscription is cancelled, it's a system cancellation
    Assert.assertEquals(event.getEventType(), BusinessSubscriptionEvent.EventType.SYSTEM_CANCEL);
    Assert.assertEquals(event.getCategory(), product.getCategory());
    Assert.assertEquals(event.toString(), "SYSTEM_CANCEL_BASE");
  }