@Override public BundleJson apply(final SubscriptionBundle input) { return new BundleJson(input, null); } });
@GET @Path("/{bundleId:" + UUID_PATTERN + "}") @Produces(APPLICATION_JSON) public Response getBundle(@PathParam("bundleId") final String bundleId, @javax.ws.rs.core.Context final HttpServletRequest request) throws SubscriptionApiException { final UUID id = UUID.fromString(bundleId); final SubscriptionBundle bundle = subscriptionApi.getSubscriptionBundle(id, context.createContext(request)); final BundleJson json = new BundleJson(bundle, null); return Response.status(Status.OK).entity(json).build(); }
@GET @Produces(APPLICATION_JSON) public Response getBundleByKey(@QueryParam(QUERY_EXTERNAL_KEY) final String externalKey, @javax.ws.rs.core.Context final HttpServletRequest request) throws SubscriptionApiException { final SubscriptionBundle bundle = subscriptionApi.getActiveSubscriptionBundleForExternalKey(externalKey, context.createContext(request)); final BundleJson json = new BundleJson(bundle, null); return Response.status(Status.OK).entity(json).build(); }
@Override public BundleJson apply(final SubscriptionBundle bundle) { // Cache audit logs per account if (accountsAuditLogs.get().get(bundle.getAccountId()) == null) { accountsAuditLogs.get().put(bundle.getAccountId(), auditUserApi.getAccountAuditLogs(bundle.getAccountId(), auditMode.getLevel(), tenantContext)); } return new BundleJson(bundle, accountsAuditLogs.get().get(bundle.getAccountId())); } },
@Override public BundleJson apply(final SubscriptionBundle bundle) { // Cache audit logs per account if (accountsAuditLogs.get().get(bundle.getAccountId()) == null) { accountsAuditLogs.get().put(bundle.getAccountId(), auditUserApi.getAccountAuditLogs(bundle.getAccountId(), auditMode.getLevel(), tenantContext)); } return new BundleJson(bundle, accountsAuditLogs.get().get(bundle.getAccountId())); } },
private BundleJson createBundleWithSubscriptions() { final String someUUID = UUID.randomUUID().toString(); final UUID accountId = UUID.randomUUID(); final UUID bundleId = UUID.randomUUID(); final UUID subscriptionId = UUID.randomUUID(); final String externalKey = UUID.randomUUID().toString(); final SubscriptionJson entitlementJsonWithEvents = new SubscriptionJson(accountId.toString(), bundleId.toString(), subscriptionId.toString(), externalKey, new LocalDate(), someUUID, someUUID, someUUID, someUUID, new LocalDate(), new LocalDate(), new LocalDate(), new LocalDate(), null, null, null, null); return new BundleJson(accountId.toString(), bundleId.toString(), externalKey, ImmutableList.<SubscriptionJson>of(entitlementJsonWithEvents), null); }
@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); } }
for (final SubscriptionBundle bundle : bundles) { final List<AuditLog> bundleAuditLogs = accountAuditLogs.getAuditLogsForBundle(bundle.getId()); final BundleJson jsonWithSubscriptions = new BundleJson(bundle, accountAuditLogs); this.bundles.add(jsonWithSubscriptions);