entitlement.changePlanWithDate( new DefaultEntitlementSpecifier(spec), new LocalDate("2017-02-15"), ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus();
bp.changePlanWithDate(new DefaultEntitlementSpecifier(spec), new LocalDate("2016-05-09"), null, callContext); assertListenerStatus();
bp.changePlanWithDate(new DefaultEntitlementSpecifier(spec2), new LocalDate("2016-05-09"), null, callContext); assertListenerStatus();
entitlement.changePlanWithDate(new DefaultEntitlementSpecifier(spec2), startDate.minusDays(1), ImmutableList.<PluginProperty>of(), callContext); fail("Changing plan immediately prior the subscription is active is not allowed"); } catch (EntitlementApiException e) { entitlement.changePlanWithDate(new DefaultEntitlementSpecifier(spec2), startDate, ImmutableList.<PluginProperty>of(), callContext);
@Override public Response doOperation(final CallContext ctx) throws EntitlementApiException, AccountApiException { final Entitlement current = entitlementApi.getEntitlementForId(subscriptionId, callContext); final LocalDate inputLocalDate = toLocalDate(requestedDate); final Entitlement newEntitlement; final Account account = accountUserApi.getAccountById(current.getAccountId(), callContext); final PhaseType phaseType = entitlement.getPhaseType(); final PlanPhaseSpecifier planSpec = entitlement.getPlanName() != null ? new PlanPhaseSpecifier(entitlement.getPlanName(), phaseType) : new PlanPhaseSpecifier(entitlement.getProductName(), entitlement.getBillingPeriod(), entitlement.getPriceList(), phaseType); final List<PlanPhasePriceOverride> overrides = buildPlanPhasePriceOverrides(entitlement.getPriceOverrides(), account.getCurrency(), planSpec); if (requestedDate == null && billingPolicy == null) { newEntitlement = current.changePlan(new DefaultEntitlementSpecifier(planSpec, null, overrides), pluginProperties, ctx); } else if (billingPolicy == null) { newEntitlement = current.changePlanWithDate(new DefaultEntitlementSpecifier(planSpec, null, overrides), inputLocalDate, pluginProperties, ctx); } else { newEntitlement = current.changePlanOverrideBillingPolicy(new DefaultEntitlementSpecifier(planSpec, null, overrides), null, billingPolicy, pluginProperties, ctx); } isImmediateOp = newEntitlement.getLastActiveProduct().getName().equals(entitlement.getProductName()) && newEntitlement.getLastActivePlan().getRecurringBillingPeriod() == entitlement.getBillingPeriod() && newEntitlement.getLastActivePriceList().getName().equals(entitlement.getPriceList()); return Response.status(Status.NO_CONTENT).build(); }
entitlement.changePlanWithDate(new DefaultEntitlementSpecifier(spec2), entitlementDate, ImmutableList.<PluginProperty>of(), callContext); Assert.fail("Change plan prior billingStartDate should fail"); } catch (EntitlementApiException e) { final Entitlement result = entitlement.changePlanWithDate(new DefaultEntitlementSpecifier(spec2), null, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus();
@Test(groups = "slow") public void testInvoiceNotificationWithFutureSubscriptionEvents() throws Exception { clock.setDay(new LocalDate(2018, 1, 31)); final AccountData accountData = getAccountData(28); final Account account = createAccountWithNonOsgiPaymentMethod(accountData); accountChecker.checkAccount(account.getId(), accountData, callContext); final LocalDate billingDate = new LocalDate(2018, 2, 28); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("pistol-monthly-notrial"); busHandler.pushExpectedEvents(NextEvent.BLOCK); final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), "bundleKey", null, billingDate, false, true, ImmutableList.<PluginProperty>of(), callContext); busHandler.assertListenerStatus(); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); // Move to the notification before the start date => 2018, 2, 21 addDaysAndCheckForCompletion(21, NextEvent.INVOICE_NOTIFICATION); // Move to the start date => 2018, 2, 28 addDaysAndCheckForCompletion(7, NextEvent.CREATE, NextEvent.INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT); final LocalDate futureChangeDate = new LocalDate(2018, 3, 28); final PlanPhaseSpecifier spec2 = new PlanPhaseSpecifier("shotgun-monthly"); entitlement.changePlanWithDate(new DefaultEntitlementSpecifier(spec2), futureChangeDate, null, callContext); assertListenerStatus(); // Move to the notification before the start date => 2018, 3, 21 addDaysAndCheckForCompletion(21, NextEvent.INVOICE_NOTIFICATION); // Move to the change date => 2018, 3, 28 addDaysAndCheckForCompletion(7, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.NULL_INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT); }
entitlement.changePlanWithDate(new DefaultEntitlementSpecifier(spec2), clock.getUTCToday(), ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement latestEntitlement = entitlementApi.getEntitlementForId(entitlement.getId(), callContext);
bpEntitlement = bpEntitlement.changePlanWithDate(new DefaultEntitlementSpecifier(spec2), clock.getUTCToday(), ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus();
bpEntitlement = bpEntitlement.changePlanWithDate(new DefaultEntitlementSpecifier(spec2), clock.getUTCToday(), ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus();