use of org.killbill.billing.subscription.api.user.DefaultSubscriptionBase in project killbill by killbill.
the class TestPlanAligner method testCreateWithTargetPhaseType3.
//
// Scenario : change Plan with START_OF_SUBSCRIPTION after skipping TRIAL on Create to a new Plan that has {TRIAL, DISCOUNT, EVERGREEN}
//
@Test(groups = "fast")
public void testCreateWithTargetPhaseType3() throws Exception {
final String productName = "pistol-monthly";
final DateTime now = clock.getUTCNow();
final DateTime bundleStartDate = now;
final DateTime alignStartDate = bundleStartDate;
final Plan plan = currentVersion.findPlan(productName);
final TimedPhase[] phases = planAligner.getCurrentAndNextTimedPhaseOnCreate(alignStartDate, bundleStartDate, plan, PhaseType.EVERGREEN, PriceListSet.DEFAULT_PRICELIST_NAME, now, catalog, internalCallContext);
Assert.assertEquals(phases.length, 2);
Assert.assertEquals(phases[0].getPhase().getPhaseType(), PhaseType.EVERGREEN);
Assert.assertEquals(phases[0].getStartPhase(), now);
Assert.assertNull(phases[1]);
final DefaultSubscriptionBase defaultSubscriptionBase = createSubscription(bundleStartDate, alignStartDate, productName, PhaseType.EVERGREEN);
final String newProductName = "assault-rifle-annual-gunclub-discount";
final Plan newPlan = currentVersion.findPlan(newProductName);
final DateTime effectiveChangeDate = defaultSubscriptionBase.getStartDate().plusMonths(15);
// Because new Plan has an EVERGREEN PhaseType we end up directly on that PhaseType
final TimedPhase currentPhase = planAligner.getCurrentTimedPhaseOnChange(defaultSubscriptionBase, newPlan, effectiveChangeDate, null, catalog, internalCallContext);
Assert.assertEquals(currentPhase.getStartPhase(), alignStartDate);
Assert.assertEquals(currentPhase.getPhase().getPhaseType(), PhaseType.EVERGREEN);
}
use of org.killbill.billing.subscription.api.user.DefaultSubscriptionBase in project killbill by killbill.
the class TestDefaultSubscriptionTransferApi method testEventsForCancelledSubscriptionBeforeTransfer.
@Test(groups = "fast")
public void testEventsForCancelledSubscriptionBeforeTransfer() throws Exception {
final DateTime subscriptionStartTime = clock.getUTCNow();
final DateTime subscriptionCancelTime = subscriptionStartTime.plusDays(1);
final ImmutableList<ExistingEvent> existingEvents = ImmutableList.<ExistingEvent>of(createEvent(subscriptionStartTime, SubscriptionBaseTransitionType.CREATE), createEvent(subscriptionCancelTime, SubscriptionBaseTransitionType.CANCEL));
final SubscriptionBuilder subscriptionBuilder = new SubscriptionBuilder();
final DefaultSubscriptionBase subscription = new DefaultSubscriptionBase(subscriptionBuilder);
final DateTime transferDate = subscriptionStartTime.plusDays(10);
final List<SubscriptionBaseEvent> events = transferApi.toEvents(existingEvents, subscription, transferDate, internalCallContext);
Assert.assertEquals(events.size(), 0);
}
use of org.killbill.billing.subscription.api.user.DefaultSubscriptionBase in project killbill by killbill.
the class TestDefaultSubscriptionTransferApi method testEventsForCancelledSubscriptionAfterTransfer.
@Test(groups = "fast")
public void testEventsForCancelledSubscriptionAfterTransfer() throws Exception {
final DateTime subscriptionStartTime = clock.getUTCNow();
final DateTime subscriptionCancelTime = subscriptionStartTime.plusDays(1);
final ImmutableList<ExistingEvent> existingEvents = ImmutableList.<ExistingEvent>of(createEvent(subscriptionStartTime, SubscriptionBaseTransitionType.CREATE), createEvent(subscriptionCancelTime, SubscriptionBaseTransitionType.CANCEL));
final SubscriptionBuilder subscriptionBuilder = new SubscriptionBuilder();
final DefaultSubscriptionBase subscription = new DefaultSubscriptionBase(subscriptionBuilder);
final DateTime transferDate = subscriptionStartTime.plusHours(1);
final List<SubscriptionBaseEvent> events = transferApi.toEvents(existingEvents, subscription, transferDate, internalCallContext);
Assert.assertEquals(events.size(), 1);
Assert.assertEquals(events.get(0).getType(), EventType.API_USER);
Assert.assertEquals(events.get(0).getEffectiveDate(), transferDate);
Assert.assertEquals(((ApiEventTransfer) events.get(0)).getApiEventType(), ApiEventType.TRANSFER);
}
Aggregations