@Override public PlanPhaseSpecifier getPlanPhaseSpecifier() { return new PlanPhaseSpecifier("BicycleTrialEvergreen1USD", ProductCategory.BASE, BillingPeriod.NO_BILLING_PERIOD, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.FIXEDTERM); }
public PlanSpecifier(final PlanPhaseSpecifier planPhase) { super(); this.productName = planPhase.getProductName(); this.productCategory = planPhase.getProductCategory(); this.billingPeriod = planPhase.getBillingPeriod(); this.priceListName = planPhase.getPriceListName(); }
public T getResult(final PlanPhaseSpecifier specifier, final StandaloneCatalog c) throws CatalogApiException { if ((phaseType == null || specifier.getPhaseType() == phaseType) && satisfiesCase(new PlanSpecifier(specifier), c) ) { return getResult(); } return null; }
public IllegalPlanChange(final Throwable cause, final PlanPhaseSpecifier from, final PlanSpecifier to) { super(cause, ErrorCode.CAT_ILLEGAL_CHANGE_REQUEST, from.getProductName(), from.getBillingPeriod(), from.getPriceListName(), to.getProductName(), to.getBillingPeriod(), to.getPriceListName()); }
final PlanPhaseSpecifier spec = new PlanPhaseSpecifier(newBaseProduct, ProductCategory.BASE, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.TRIAL); log.info(String.format("%s, %s, %s, %s", e.getSubscriptionTransitionType(), e.getEffectiveDate(), e.getPlanPhaseSpecifier().getProductName(), e.getPlanPhaseSpecifier().getPhaseType()));
public IllegalPlanChange(final PlanPhaseSpecifier from, final PlanSpecifier to) { super(ErrorCode.CAT_ILLEGAL_CHANGE_REQUEST, from.getProductName(), from.getBillingPeriod(), from.getPriceListName(), to.getProductName(), to.getBillingPeriod(), to.getPriceListName()); }
public PlanPhaseSpecifier getProductSpecifier(final String productName, final String priceList, final BillingPeriod term, @Nullable final PhaseType phaseType) { return new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, priceList, phaseType); }
public void validateExistingEventForAssertion(final ExistingEvent expected, final ExistingEvent input) { log.debug(String.format("Got %s -> Expected %s", input.getPlanPhaseSpecifier().getProductName(), expected.getPlanPhaseSpecifier().getProductName())); assertEquals(input.getPlanPhaseSpecifier().getProductName(), expected.getPlanPhaseSpecifier().getProductName()); log.debug(String.format("Got %s -> Expected %s", input.getPlanPhaseSpecifier().getPhaseType(), expected.getPlanPhaseSpecifier().getPhaseType())); assertEquals(input.getPlanPhaseSpecifier().getPhaseType(), expected.getPlanPhaseSpecifier().getPhaseType()); log.debug(String.format("Got %s -> Expected %s", input.getPlanPhaseSpecifier().getProductCategory(), expected.getPlanPhaseSpecifier().getProductCategory())); assertEquals(input.getPlanPhaseSpecifier().getProductCategory(), expected.getPlanPhaseSpecifier().getProductCategory()); log.debug(String.format("Got %s -> Expected %s", input.getPlanPhaseSpecifier().getPriceListName(), expected.getPlanPhaseSpecifier().getPriceListName())); assertEquals(input.getPlanPhaseSpecifier().getPriceListName(), expected.getPlanPhaseSpecifier().getPriceListName()); log.debug(String.format("Got %s -> Expected %s", input.getPlanPhaseSpecifier().getBillingPeriod(), expected.getPlanPhaseSpecifier().getBillingPeriod())); assertEquals(input.getPlanPhaseSpecifier().getBillingPeriod(), expected.getPlanPhaseSpecifier().getBillingPeriod()); log.debug(String.format("Got %s -> Expected %s", input.getEffectiveDate(), expected.getEffectiveDate())); assertEquals(input.getEffectiveDate(), expected.getEffectiveDate()); }
public BillingActionPolicy getPlanChangePolicy(final PlanPhaseSpecifier from, final PlanSpecifier to, final StandaloneCatalog catalog) throws CatalogApiException { if (from.getProductName().equals(to.getProductName()) && from.getBillingPeriod() == to.getBillingPeriod() && from.getPriceListName().equals(to.getPriceListName())) { return BillingActionPolicy.ILLEGAL; } //Plan toPlan = catalog.findPlan() return CaseChange.getResult(changeCase, from, to, catalog); }
public ExistingEvent createExistingEventForAssertion(final SubscriptionBaseTransitionType type, final String productName, final PhaseType phaseType, final ProductCategory category, final String priceListName, final BillingPeriod billingPeriod, final DateTime effectiveDateTime) { final PlanPhaseSpecifier spec = new PlanPhaseSpecifier(productName, category, billingPeriod, priceListName, phaseType); return new ExistingEvent() { @Override
public T getResult(final PlanPhaseSpecifier from, final PlanSpecifier to, final StandaloneCatalog catalog) throws CatalogApiException { if ( (phaseType == null || from.getPhaseType() == phaseType) && (fromProduct == null || fromProduct.equals(catalog.findCurrentProduct(from.getProductName()))) && (fromProductCategory == null || fromProductCategory.equals(from.getProductCategory())) && (fromBillingPeriod == null || fromBillingPeriod.equals(from.getBillingPeriod())) && (toProduct == null || toProduct.equals(catalog.findCurrentProduct(to.getProductName()))) && (toProductCategory == null || toProductCategory.equals(to.getProductCategory())) && (toBillingPeriod == null || toBillingPeriod.equals(to.getBillingPeriod())) && (fromPriceList == null || fromPriceList.equals(catalog.findCurrentPriceList(from.getPriceListName()))) && (toPriceList == null || toPriceList.equals(catalog.findCurrentPriceList(to.getPriceListName()))) ) { return getResult(); } return null; }
protected void assertionNull(final CaseResult cr, final String productName, final ProductCategory productCategory, final BillingPeriod bp, final String priceListName, final PhaseType phaseType, final StandaloneCatalog cat) { try { Assert.assertNull(cr.getResult(new PlanPhaseSpecifier(productName, productCategory, bp, priceListName, phaseType), cat)); } catch (CatalogApiException e) { Assert.fail("", e); } }
assertEquals(cur.getId(), baseSubscription.getId()); assertEquals(events.get(0).getPlanPhaseSpecifier().getProductName(), baseProduct); assertEquals(events.get(0).getPlanPhaseSpecifier().getPhaseType(), PhaseType.TRIAL); assertEquals(events.get(0).getPlanPhaseSpecifier().getProductCategory(), ProductCategory.BASE); assertEquals(events.get(0).getPlanPhaseSpecifier().getPriceListName(), basePriceList); assertEquals(events.get(0).getPlanPhaseSpecifier().getBillingPeriod(), BillingPeriod.NO_BILLING_PERIOD); assertEquals(events.get(1).getPlanPhaseSpecifier().getProductName(), baseProduct); assertEquals(events.get(1).getPlanPhaseSpecifier().getPhaseType(), PhaseType.EVERGREEN); assertEquals(events.get(1).getPlanPhaseSpecifier().getProductCategory(), ProductCategory.BASE); assertEquals(events.get(1).getPlanPhaseSpecifier().getPriceListName(), basePriceList); assertEquals(events.get(1).getPlanPhaseSpecifier().getBillingPeriod(), baseTerm); } else { assertEquals(cur.getId(), aoSubscription.getId()); assertEquals(events.get(0).getPlanPhaseSpecifier().getProductName(), aoProduct); assertEquals(events.get(0).getPlanPhaseSpecifier().getPhaseType(), PhaseType.DISCOUNT); assertEquals(events.get(0).getPlanPhaseSpecifier().getProductCategory(), ProductCategory.ADD_ON); assertEquals(events.get(0).getPlanPhaseSpecifier().getPriceListName(), aoPriceList); assertEquals(events.get(1).getPlanPhaseSpecifier().getBillingPeriod(), aoTerm); assertEquals(events.get(1).getPlanPhaseSpecifier().getProductName(), aoProduct); assertEquals(events.get(1).getPlanPhaseSpecifier().getPhaseType(), PhaseType.EVERGREEN); assertEquals(events.get(1).getPlanPhaseSpecifier().getProductCategory(), ProductCategory.ADD_ON); assertEquals(events.get(1).getPlanPhaseSpecifier().getPriceListName(), aoPriceList); assertEquals(events.get(1).getPlanPhaseSpecifier().getBillingPeriod(), aoTerm);
protected void assertion(final Result result, final CaseResult cr, final String productName, final ProductCategory productCategory, final BillingPeriod bp, final String priceListName, final PhaseType phaseType, final StandaloneCatalog cat) { try { Assert.assertEquals(result, cr.getResult(new PlanPhaseSpecifier(productName, productCategory, bp, priceListName, phaseType), cat)); } catch (CatalogApiException e) { Assert.fail("", e); } } }
@Override public PlanPhaseSpecifier getPlanPhaseSpecifier() { return SubscriptionBaseTransitionType.CANCEL.equals(subscriptionTransitionType) ? null : new PlanPhaseSpecifier("BicycleTrialEvergreen1USD", ProductCategory.BASE, BillingPeriod.NO_BILLING_PERIOD, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.FIXEDTERM); }
public AccountMigration createAccountForMigrationFuturePendingPhase(final DateTime trialDate) { final List<SubscriptionMigrationCaseWithCTD> cases = new LinkedList<SubscriptionMigrationCaseWithCTD>(); cases.add(new SubscriptionMigrationCaseWithCTD( new PlanPhaseSpecifier("Assault-Rifle", ProductCategory.BASE, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.TRIAL), trialDate, trialDate.plusDays(30), trialDate.plusDays(30))); cases.add(new SubscriptionMigrationCaseWithCTD( new PlanPhaseSpecifier("Assault-Rifle", ProductCategory.BASE, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.EVERGREEN), trialDate.plusDays(30), null, null)); final List<List<SubscriptionMigrationCaseWithCTD>> input = new ArrayList<List<SubscriptionMigrationCaseWithCTD>>(); input.add(cases); return createAccountForMigrationTest(input); }
public AccountMigration createAccountForMigrationWithRegularBasePlan(final DateTime startDate) { final List<SubscriptionMigrationCaseWithCTD> cases = new LinkedList<SubscriptionMigrationCaseWithCTD>(); cases.add(new SubscriptionMigrationCaseWithCTD( new PlanPhaseSpecifier("Shotgun", ProductCategory.BASE, BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.EVERGREEN), startDate, null, startDate.plusYears(1))); final List<List<SubscriptionMigrationCaseWithCTD>> input = new ArrayList<List<SubscriptionMigrationCaseWithCTD>>(); input.add(cases); return createAccountForMigrationTest(input); }
public AccountMigration createAccountForMigrationWithRegularBasePlanFutreCancelled(final DateTime startDate) { final List<SubscriptionMigrationCaseWithCTD> cases = new LinkedList<SubscriptionMigrationCaseWithCTD>(); cases.add(new SubscriptionMigrationCaseWithCTD( new PlanPhaseSpecifier("Assault-Rifle", ProductCategory.BASE, BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.EVERGREEN), startDate, startDate.plusYears(1), startDate.plusYears(1))); final List<List<SubscriptionMigrationCaseWithCTD>> input = new ArrayList<List<SubscriptionMigrationCaseWithCTD>>(); input.add(cases); return createAccountForMigrationTest(input); }
protected void assertionNull(final CaseChangeResult cr, final String fromProductName, final String toProductName, final ProductCategory fromProductCategory, final ProductCategory toProductCategory, final BillingPeriod fromBp, final BillingPeriod toBp, final String fromPriceListName, final String toPriceListName, final PhaseType phaseType, final StandaloneCatalog cat) { try { Assert.assertNull(cr.getResult(new PlanPhaseSpecifier(fromProductName, fromProductCategory, fromBp, fromPriceListName, phaseType), new PlanSpecifier(toProductName, toProductCategory, toBp, toPriceListName), cat)); } catch (CatalogApiException e) { Assert.fail("", e); } }
public AccountMigration createAccountForMigrationWithRegularBasePlanAndAddons(final DateTime initialBPstart, final DateTime initalAddonStart) { final List<SubscriptionMigrationCaseWithCTD> cases = new LinkedList<SubscriptionMigrationCaseWithCTD>(); cases.add(new SubscriptionMigrationCaseWithCTD( new PlanPhaseSpecifier("Shotgun", ProductCategory.BASE, BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.EVERGREEN), initialBPstart, null, initialBPstart.plusYears(1))); final List<SubscriptionMigrationCaseWithCTD> firstAddOnCases = new LinkedList<SubscriptionMigrationCaseWithCTD>(); firstAddOnCases.add(new SubscriptionMigrationCaseWithCTD( new PlanPhaseSpecifier("Telescopic-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.DISCOUNT), initalAddonStart, initalAddonStart.plusMonths(1), initalAddonStart.plusMonths(1))); firstAddOnCases.add(new SubscriptionMigrationCaseWithCTD( new PlanPhaseSpecifier("Telescopic-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.EVERGREEN), initalAddonStart.plusMonths(1), null, null)); final List<List<SubscriptionMigrationCaseWithCTD>> input = new ArrayList<List<SubscriptionMigrationCaseWithCTD>>(); input.add(cases); input.add(firstAddOnCases); return createAccountForMigrationTest(input); }