@Test(groups = "fast", description = "Verify Mockito setup in GuicyKillbillTestSuite") public void testSpy() { clock.setDay(new LocalDate("2012-08-01")); Assert.assertEquals(clock.getUTCToday().toString(), "2012-08-01"); Assert.assertEquals(theRealClock.getUTCToday().toString(), "2012-08-01"); clock.addMonths(1); Assert.assertEquals(clock.getUTCToday().toString(), "2012-09-01"); Assert.assertEquals(theRealClock.getUTCToday().toString(), "2012-09-01"); clock.addDays(30); Assert.assertEquals(clock.getUTCToday().toString(), "2012-10-01"); Assert.assertEquals(theRealClock.getUTCToday().toString(), "2012-10-01"); } }
@Test(groups = "fast") public void testWithAccountInUtc() throws AccountApiException, EntitlementApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate.plusDays(1)); final DateTime referenceDateTime = new DateTime(2013, 1, 1, 15, 43, 25, 0, DateTimeZone.UTC); createAccount(DateTimeZone.UTC, referenceDateTime); final DateTime targetDate = dateHelper.fromLocalDateAndReferenceTime(initialDate, clock.getUTCNow(), internalCallContext); final DateTime expectedDate = new DateTime(2013, 8, 7, 15, 43, 25, 0, DateTimeZone.UTC); Assert.assertEquals(targetDate, expectedDate); }
@Test(groups = "slow", expectedExceptions = EntitlementApiException.class) public void testCreateBaseSubscriptionsWithAddOnsMissingBase() throws AccountApiException, EntitlementApiException, SubscriptionApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final String bundleKey2 = "bundleKey2"; final EntitlementSpecifier spec22 = new DefaultEntitlementSpecifier(new PlanPhaseSpecifier("Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null)); final List<EntitlementSpecifier> specs2 = ImmutableList.of(spec22); final BaseEntitlementWithAddOnsSpecifier baseEntitlementWithAddOnsSpecifier2 = new DefaultBaseEntitlementWithAddOnsSpecifier(null, bundleKey2, specs2, null, null, false); final Iterable<BaseEntitlementWithAddOnsSpecifier> baseEntitlementWithAddOnsSpecifiers = ImmutableList.of(baseEntitlementWithAddOnsSpecifier2); entitlementApi.createBaseEntitlementsWithAddOns(account.getId(), baseEntitlementWithAddOnsSpecifiers, true, ImmutableList.<PluginProperty>of(), callContext); }
@Test(groups = "fast") public void testWithAccountInUtcPlus5() throws AccountApiException, EntitlementApiException { final LocalDate inputDate = new LocalDate(2013, 8, 7); clock.setDay(inputDate.plusDays(1)); final DateTimeZone timeZoneUtcPlus5 = DateTimeZone.forOffsetHours(+5); // We also use a reference time of 20, 28, 10, 0 -> DateTime in accountTimeZone will be (2013, 8, 7, 20, 28, 10) final DateTime referenceDateTime = new DateTime(2013, 1, 1, 20, 28, 10, 0, DateTimeZone.UTC); createAccount(timeZoneUtcPlus5, referenceDateTime); final DateTime targetDate = dateHelper.fromLocalDateAndReferenceTime(inputDate, clock.getUTCNow(), internalCallContext); // Things to verify: // 1. Verify the resulting DateTime brings us back into the correct LocalDate (in the account timezone) Assert.assertEquals(new LocalDate(targetDate, timeZoneUtcPlus5), inputDate); // 2. Verify the resulting DateTime has the same reference time as we indicated (in UTC) Assert.assertEquals(targetDate.toLocalTime(), referenceDateTime.toLocalTime()); // // To be more specific, we should find a UTC Date, with the exact specified reference time, and with a LocalDate one day // ahead because of the 8 hours difference. // Assert.assertEquals(targetDate, new DateTime(2013, 8, 6, 20, 28, 10, 0, DateTimeZone.UTC)); }
@BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { if (hasFailed()) { return; } super.beforeMethod(); // Set original time clock.setDay(new LocalDate(2016, 6, 1)); init = clock.getUTCNow(); // Setup tenant setupTenant(); // Setup account in right tenant setupAccount(); }
@Test(groups = "fast", description = "Verify Mockito setup in GuicyKillbillTestSuite") public void testSpy() { clock.setDay(new LocalDate("2012-08-01")); Assert.assertEquals(clock.getUTCToday().toString(), "2012-08-01"); Assert.assertEquals(theRealClock.getUTCToday().toString(), "2012-08-01"); clock.addMonths(1); Assert.assertEquals(clock.getUTCToday().toString(), "2012-09-01"); Assert.assertEquals(theRealClock.getUTCToday().toString(), "2012-09-01"); clock.addDays(30); Assert.assertEquals(clock.getUTCToday().toString(), "2012-10-01"); Assert.assertEquals(theRealClock.getUTCToday().toString(), "2012-10-01"); } }
@Test(groups = "slow") public void testSubscriptionCreationWithExternalKeyOverLimit() throws AccountApiException, SubscriptionApiException, EntitlementApiException { final String externalKey = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,."; final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); //2013-08-07 final LocalDate effectiveDate = initialDate.plusMonths(1); try { entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), externalKey, effectiveDate, effectiveDate, false, true, ImmutableList.<PluginProperty>of(), callContext); Assert.fail(); } catch (final EntitlementApiException e) { assertEquals(e.getCode(), ErrorCode.EXTERNAL_KEY_LIMIT_EXCEEDED.getCode()); } }
@Test(groups = "slow") public void testCreateSubscriptionWithCatalogPlugin() throws Exception { testCatalogPluginApi.addCatalogVersion("WeaponsHire.xml"); // We take april as it has 30 days (easier to play with BCD) // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC clock.setDay(new LocalDate(2012, 4, 1)); final AccountData accountData = getAccountData(1); final Account account = createAccountWithNonOsgiPaymentMethod(accountData); accountChecker.checkAccount(account.getId(), accountData, callContext); // Create original subscription (Trial PHASE) -> $0 invoice. final DefaultEntitlement bpSubscription = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Pistol", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.BLOCK, NextEvent.INVOICE); invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 4, 1), null, InvoiceItemType.FIXED, new BigDecimal("0"))); subscriptionChecker.checkSubscriptionCreated(bpSubscription.getId(), internalCallContext); // Code went to retrieve catalog more than one time Assert.assertTrue(testCatalogPluginApi.getNbLatestCatalogVersionApiCalls() > 1); // Code only retrieved catalog from plugin once (caching works!) Assert.assertEquals(testCatalogPluginApi.getNbVersionedPluginCatalogApiCalls(), 1); }
@Test(groups = "slow") public void testCreateBaseSubscriptionsWithAddOnsBadOrdering() throws AccountApiException, EntitlementApiException, SubscriptionApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final String bundleKey1 = "bundleKey1"; final EntitlementSpecifier spec11 = new DefaultEntitlementSpecifier(new PlanPhaseSpecifier("Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null)); final EntitlementSpecifier spec12 = new DefaultEntitlementSpecifier(new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null)); final List<EntitlementSpecifier> specs1 = ImmutableList.of(spec11, spec12); final BaseEntitlementWithAddOnsSpecifier baseEntitlementWithAddOnsSpecifier1 = new DefaultBaseEntitlementWithAddOnsSpecifier(null, bundleKey1, specs1, null, null, false); final Iterable<BaseEntitlementWithAddOnsSpecifier> baseEntitlementWithAddOnsSpecifiers = ImmutableList.of(baseEntitlementWithAddOnsSpecifier1); testListener.pushExpectedEvents(NextEvent.BLOCK, NextEvent.CREATE, NextEvent.BLOCK, NextEvent.CREATE); entitlementApi.createBaseEntitlementsWithAddOns(account.getId(), baseEntitlementWithAddOnsSpecifiers, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); }
@Test(groups = "slow") public void testCreatWithFixedPriceOverride() throws Exception { // We take april as it has 30 days (easier to play with BCD) // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC clock.setDay(new LocalDate(2012, 4, 1)); final AccountData accountData = getAccountData(1); final Account account = createAccountWithNonOsgiPaymentMethod(accountData); accountChecker.checkAccount(account.getId(), accountData, callContext); final List<PlanPhasePriceOverride> overrides = new ArrayList<PlanPhasePriceOverride>(); overrides.add(new DefaultPlanPhasePriceOverride("shotgun-monthly-trial", account.getCurrency(), BigDecimal.ONE, null, null)); final DefaultEntitlement bpSubscription = createBaseEntitlementWithPriceOverrideAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, overrides, NextEvent.CREATE, NextEvent.BLOCK, NextEvent.INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT); // Check bundle after BP got created otherwise we get an error from auditApi. subscriptionChecker.checkSubscriptionCreated(bpSubscription.getId(), internalCallContext); invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(clock.getUTCToday(), null, InvoiceItemType.FIXED, new BigDecimal("1"))); }
@Test(groups = "slow") public void testCreateBaseWithBillingInThePast() throws AccountApiException, EntitlementApiException, SubscriptionApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final LocalDate entitlementDate = null; final LocalDate billingDate = initialDate.minusDays(5); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); testListener.pushExpectedEvents(NextEvent.BLOCK, NextEvent.CREATE); final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), entitlementDate, billingDate, false, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); assertEquals(entitlement.getState(), EntitlementState.ACTIVE); assertEquals(entitlement.getEffectiveStartDate(), initialDate); }
@Test(groups = "slow") public void testCreateBaseWithEntitlementInThePast() throws AccountApiException, EntitlementApiException, SubscriptionApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final LocalDate entitlementDate = initialDate.minusDays(3); final LocalDate billingDate = null; final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); testListener.pushExpectedEvents(NextEvent.BLOCK, NextEvent.CREATE); final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), entitlementDate, billingDate, false, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); assertEquals(entitlement.getState(), EntitlementState.ACTIVE); assertEquals(entitlement.getEffectiveStartDate(), entitlementDate); }
@Test(groups = "slow") public void testCreateBaseWithDifferentInThePast() throws AccountApiException, EntitlementApiException, SubscriptionApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final LocalDate entitlementDate = initialDate.minusDays(3); final LocalDate billingDate = initialDate.minusDays(5); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); testListener.pushExpectedEvents(NextEvent.BLOCK, NextEvent.CREATE); final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), entitlementDate, billingDate, false, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); assertEquals(entitlement.getState(), EntitlementState.ACTIVE); assertEquals(entitlement.getEffectiveStartDate(), entitlementDate); }
@Test(groups = "slow") public void testCancelWithEntitlementPolicyEOTAndNOCTD() throws AccountApiException, EntitlementApiException, SubscriptionApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); // Create entitlement and check each field testListener.pushExpectedEvents(NextEvent.CREATE, NextEvent.BLOCK); final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), null, null, false, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); testListener.pushExpectedEvents(NextEvent.CANCEL, NextEvent.BLOCK); final Entitlement cancelledEntitlement = entitlement.cancelEntitlementWithPolicy(EntitlementActionPolicy.END_OF_TERM, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); assertEquals(cancelledEntitlement.getState(), EntitlementState.CANCELLED); assertEquals(cancelledEntitlement.getEffectiveEndDate(), initialDate); // Entitlement started in trial on 2013-08-07, which is when we want the billing cancellation to occur final Subscription subscription = subscriptionApi.getSubscriptionForEntitlementId(entitlement.getBaseEntitlementId(), callContext); assertEquals(subscription.getBillingEndDate(), new LocalDate(2013, 8, 7)); }
@Test(groups = "slow") public void testCancelWithEntitlementDate() throws AccountApiException, EntitlementApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final PlanPhaseSpecifier planPhaseSpecifier = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); // Create entitlement and check each field testListener.pushExpectedEvents(NextEvent.CREATE, NextEvent.BLOCK); final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(planPhaseSpecifier), account.getExternalKey(), null, null, false, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); assertEquals(entitlement.getState(), EntitlementState.ACTIVE); assertEquals(entitlement.getSourceType(), EntitlementSourceType.NATIVE); clock.addDays(5); testListener.pushExpectedEvents(NextEvent.CANCEL, NextEvent.BLOCK); entitlement.cancelEntitlementWithDate(null, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement entitlement2 = entitlementApi.getEntitlementForId(entitlement.getId(), callContext); assertEquals(entitlement2.getState(), EntitlementState.CANCELLED); assertEquals(entitlement2.getEffectiveEndDate(), clock.getUTCToday()); assertEquals(entitlement2.getSourceType(), EntitlementSourceType.NATIVE); }
@Test(groups = "slow") public void testCancelFutureSubscription() throws AccountApiException, EntitlementApiException, SubscriptionApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, null); final LocalDate futureDate = new LocalDate(2013, 9, 1); // No CREATE event as this is set in the future final UUID createdEntitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), futureDate, futureDate, false, true, ImmutableList.<PluginProperty>of(), callContext); final Entitlement createdEntitlement = entitlementApi.getEntitlementForId(createdEntitlementId, callContext); assertEquals(createdEntitlement.getEffectiveStartDate().compareTo(futureDate), 0); assertEquals(createdEntitlement.getEffectiveEndDate(), null); final Entitlement baseEntitlement = entitlementApi.getEntitlementForId(createdEntitlement.getId(), callContext); assertEquals(baseEntitlement.getEffectiveStartDate().compareTo(futureDate), 0); assertEquals(baseEntitlement.getEffectiveEndDate(), null); final Entitlement cancelledEntitlement = baseEntitlement.cancelEntitlementWithPolicyOverrideBillingPolicy(EntitlementActionPolicy.IMMEDIATE, BillingActionPolicy.IMMEDIATE, null, callContext); assertEquals(cancelledEntitlement.getEffectiveEndDate().compareTo(futureDate), 0); final Subscription subscription = subscriptionApi.getSubscriptionForEntitlementId(cancelledEntitlement.getId(), callContext); assertEquals(subscription.getEffectiveEndDate().compareTo(futureDate), 0); assertListenerStatus(); }
@Test(groups = "slow") public void testCreateBaseWithBillingInTheFuture() throws AccountApiException, EntitlementApiException, SubscriptionApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final LocalDate entitlementDate = null; final LocalDate billingDate = initialDate.plusDays(5); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); testListener.pushExpectedEvents(NextEvent.BLOCK); final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), entitlementDate, billingDate, false, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); assertEquals(entitlement.getState(), EntitlementState.ACTIVE); assertEquals(entitlement.getEffectiveStartDate(), initialDate); testListener.pushExpectedEvents(NextEvent.CREATE); clock.addDays(5); assertListenerStatus(); }
@Test(groups = "slow") public void testInvoiceNotificationBasic() throws Exception { // We take april as it has 30 days (easier to play with BCD) // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC clock.setDay(new LocalDate(2012, 4, 1)); final AccountData accountData = getAccountData(1); final Account account = createAccountWithNonOsgiPaymentMethod(accountData); accountChecker.checkAccount(account.getId(), accountData, callContext); final DefaultEntitlement bpSubscription = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.BLOCK, NextEvent.INVOICE); // Move to end of trial => 2012, 4, 24 addDaysAndCheckForCompletion(23, NextEvent.INVOICE_NOTIFICATION); // Move to end of trial => 2012, 5, 1 addDaysAndCheckForCompletion(7, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT); // Next invoice is scheduled for 2012, 6, 1 so we should have a NOTIFICATION event 7 days before, on 2012, 5, 25 addDaysAndCheckForCompletion(24, NextEvent.INVOICE_NOTIFICATION); // And then verify the invoice is correctly generated addDaysAndCheckForCompletion(7, NextEvent.INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT); }
@Test(groups = "slow") public void testCancelSubscriptionInTrialWith_START_OF_TERM() throws Exception { final LocalDate initialDate = new LocalDate(2015, 9, 1); clock.setDay(initialDate); final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1)); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, null); busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.BLOCK, NextEvent.INVOICE); final UUID createdEntitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), initialDate, initialDate, false, true, ImmutableList.<PluginProperty>of(), callContext); final Entitlement createdEntitlement = entitlementApi.getEntitlementForId(createdEntitlementId, callContext); assertEquals(createdEntitlement.getEffectiveStartDate().compareTo(initialDate), 0); assertEquals(createdEntitlement.getEffectiveEndDate(), null); assertListenerStatus(); // Move clock a bit to make sure START_OF_TERM brings us back to initialDate clock.addDays(5); busHandler.pushExpectedEvents(NextEvent.CANCEL, NextEvent.BLOCK, NextEvent.NULL_INVOICE); final Entitlement cancelledEntitlement = createdEntitlement.cancelEntitlementWithPolicyOverrideBillingPolicy(EntitlementActionPolicy.IMMEDIATE, BillingActionPolicy.START_OF_TERM, null, callContext); assertListenerStatus(); final Subscription subscription = subscriptionApi.getSubscriptionForEntitlementId(cancelledEntitlement.getId(), callContext); assertEquals(subscription.getEffectiveEndDate().compareTo(new LocalDate(2015, 9, 6)), 0); assertEquals(subscription.getBillingEndDate().compareTo(initialDate), 0); }
@Test(groups = "slow") public void testCreateBaseWithEntitlementInTheFuture() throws AccountApiException, EntitlementApiException, SubscriptionApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final LocalDate entitlementDate = initialDate.plusDays(3); final LocalDate billingDate = null; final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); testListener.pushExpectedEvents(NextEvent.CREATE); final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), entitlementDate, billingDate, false, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); assertEquals(entitlement.getState(), EntitlementState.PENDING); assertEquals(entitlement.getEffectiveStartDate(), entitlementDate); testListener.pushExpectedEvents(NextEvent.BLOCK); clock.addDays(3); assertListenerStatus(); final Entitlement entitlementActive = entitlementApi.getEntitlementForId(entitlement.getId(), callContext); assertEquals(entitlementActive.getState(), EntitlementState.ACTIVE); }