@Test(groups = "fast") public void testJson() throws Exception { final String someUUID = UUID.randomUUID().toString(); final UUID bundleId = UUID.randomUUID(); final String externalKey = UUID.randomUUID().toString(); final List<AuditLogJson> auditLogs = createAuditLogsJson(clock.getUTCNow()); EventSubscriptionJson event = new EventSubscriptionJson(someUUID, BillingPeriod.NO_BILLING_PERIOD.toString(), new LocalDate(), new LocalDate(), "product", "priceList", "eventType", "phase", null); final SubscriptionJson subscription = new SubscriptionJson(someUUID, someUUID, someUUID, externalKey, new LocalDate(), someUUID, someUUID, someUUID, someUUID, new LocalDate(), new LocalDate(), new LocalDate(), new LocalDate(), ImmutableList.<EventSubscriptionJson>of(event), null, null, auditLogs); final BundleJson bundleJson = new BundleJson(someUUID, bundleId.toString(), externalKey, ImmutableList.<SubscriptionJson>of(subscription), auditLogs); Assert.assertEquals(bundleJson.getBundleId(), bundleId.toString()); Assert.assertEquals(bundleJson.getExternalKey(), externalKey); Assert.assertEquals(bundleJson.getSubscriptions().size(), 1); Assert.assertEquals(bundleJson.getAuditLogs(), auditLogs); final String asJson = mapper.writeValueAsString(bundleJson); final BundleJson fromJson = mapper.readValue(asJson, BundleJson.class); Assert.assertEquals(fromJson, bundleJson); } }
@Override public DefaultPlan findCurrentPlan(final String productName, final BillingPeriod period, final String priceListName) throws CatalogApiException { if (productName == null) { throw new CatalogApiException(ErrorCode.CAT_NULL_PRODUCT_NAME); } if (priceLists == null) { throw new CatalogApiException(ErrorCode.CAT_PRICE_LIST_NOT_FOUND, priceListName); } final Product product = findCurrentProduct(productName); final DefaultPlan result = priceLists.getPlanFrom(priceListName, product, period); if (result == null) { final String periodString = (period == null) ? "NULL" : period.toString(); throw new CatalogApiException(ErrorCode.CAT_PLAN_NOT_FOUND, productName, periodString, priceListName); } return result; }
final List<AuditLogJson> auditLogs = createAuditLogsJson(clock.getUTCNow()); final EventSubscriptionJson newEvent = new EventSubscriptionJson(eventId.toString(), BillingPeriod.NO_BILLING_PERIOD.toString(), requestedDate.toLocalDate(), effectiveDate.toLocalDate(),
@Test(groups = "fast") public void testJson() throws Exception { final String productName = UUID.randomUUID().toString(); final String planName = UUID.randomUUID().toString(); final BillingPeriod billingPeriod = BillingPeriod.ANNUAL; final String priceListName = UUID.randomUUID().toString(); final PlanDetailJson planDetailJason = new PlanDetailJson(productName, planName, billingPeriod, priceListName, null); Assert.assertEquals(planDetailJason.getProductName(), productName); Assert.assertEquals(planDetailJason.getPlanName(), planName); Assert.assertEquals(planDetailJason.getBillingPeriod(), billingPeriod); Assert.assertEquals(planDetailJason.getPriceListName(), priceListName); Assert.assertEquals(planDetailJason.getFinalPhasePrice(), null); final String asJson = mapper.writeValueAsString(planDetailJason); Assert.assertEquals(asJson, "{\"productName\":\"" + planDetailJason.getProductName() + "\"," + "\"planName\":\"" + planDetailJason.getPlanName() + "\"," + "\"billingPeriod\":\"" + planDetailJason.getBillingPeriod().toString() + "\"," + "\"priceListName\":\"" + planDetailJason.getPriceListName() + "\"," + "\"finalPhasePrice\":null}"); final PlanDetailJson fromJson = mapper.readValue(asJson, PlanDetailJson.class); Assert.assertEquals(fromJson, planDetailJason); }
public BusinessInvoiceItemModelDao(@Nullable final String externalKey, final InvoiceItem invoiceItem, @Nullable final Plan plan, @Nullable final PlanPhase planPhase) { this(invoiceItem.getAmount(), planPhase != null ? planPhase.getBillingPeriod().toString() : null, invoiceItem.getCreatedDate(), invoiceItem.getCurrency(), /* Populate end date for fixed items for convenience (null in invoice_items table) */ (invoiceItem.getEndDate() == null && planPhase != null) ? invoiceItem.getStartDate().plus(planPhase.getDuration().toJodaPeriod()) : invoiceItem.getEndDate(), externalKey, invoiceItem.getInvoiceId(), invoiceItem.getId(), invoiceItem.getLinkedItemId(), invoiceItem.getInvoiceItemType().toString(), planPhase != null ? planPhase.getPhaseType().toString() : null, plan != null ? plan.getProduct().getCategory().toString() : null, plan != null ? plan.getProduct().getName() : null, plan != null ? plan.getProduct().getCatalogName() : null, planPhase != null ? planPhase.getName() : null, invoiceItem.getStartDate(), invoiceItem.getUpdatedDate()); }
billingPeriod = thePhase.getBillingPeriod().toString(); } else { billingPeriod = null;
this.productName = subscription.getLastActiveProduct().getName(); this.productCategory = subscription.getLastActiveProductCategory().name(); this.billingPeriod = subscription.getLastActivePlan().getBillingPeriod().toString(); this.priceList = subscription.getLastActivePriceList().getName(); this.cancelledDate = subscription.getEffectiveEndDate(); final PlanPhase phase = cur.getNextPhase() != null ? cur.getNextPhase() : cur.getPrevPhase(); this.events.add(new EventSubscriptionJson(cur.getId().toString(), billingPeriod != null ? billingPeriod.toString() : null, cur.getRequestedDate(), cur.getEffectiveDate(),
billingPeriod = currentPhase.getBillingPeriod().toString(); } else { billingPeriod = null;