@Override public Catalog getCatalog(final String catalogName, final TenantContext context) { // STEPH TODO this is hack until we decides what do do exactly: // Probably we want one catalog for tenant but but TBD return catalogService.getFullCatalog(); } }
@Override protected void configure() { final Catalog catalog = Mockito.mock(Catalog.class); final CatalogService catalogService = Mockito.mock(CatalogService.class); Mockito.when(catalogService.getCurrentCatalog()).thenReturn(new MockCatalog()); Mockito.when(catalogService.getFullCatalog()).thenReturn(catalog); bind(CatalogService.class).toInstance(catalogService); } }
@GET @Produces(APPLICATION_JSON) public Response getCatalogJson(@javax.ws.rs.core.Context final HttpServletRequest request) throws Exception { final StaticCatalog catalog = catalogService.getCurrentCatalog(); return Response.status(Status.OK).entity(catalog).build(); }
@GET @Produces(APPLICATION_XML) public Response getCatalogXml(@javax.ws.rs.core.Context final HttpServletRequest request) throws Exception { return Response.status(Status.OK).entity(XMLWriter.writeXML(catalogService.getCurrentCatalog(), StaticCatalog.class)).build(); }
public Catalog initCatalog(final CatalogService catalogService) throws Exception { ((DefaultCatalogService) catalogService).loadCatalog(); final Catalog catalog = catalogService.getFullCatalog(); assertNotNull(catalog); return catalog; }
@BeforeMethod(groups = "fast") public void beforeMethod() throws Exception { super.beforeMethod(); final SubscriptionBaseBundle bundle = Mockito.mock(SubscriptionBaseBundle.class); Mockito.when(bundle.getId()).thenReturn(bunId); final List<SubscriptionBaseBundle> bundles = ImmutableList.<SubscriptionBaseBundle>of(bundle); effectiveSubscriptionTransitions = new LinkedList<EffectiveSubscriptionInternalEvent>(); final DateTime subscriptionStartDate = clock.getUTCNow().minusDays(3); subscription = new MockSubscription(subId, bunId, null, subscriptionStartDate, effectiveSubscriptionTransitions); final List<SubscriptionBase> subscriptions = ImmutableList.<SubscriptionBase>of(subscription); Mockito.when(subscriptionInternalApi.getBundlesForAccount(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(bundles); Mockito.when(subscriptionInternalApi.getSubscriptionsForBundle(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(subscriptions); Mockito.when(subscriptionInternalApi.getSubscriptionFromId(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(subscription); Mockito.when(subscriptionInternalApi.getBundleFromId(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(bundle); Mockito.when(subscriptionInternalApi.getBaseSubscription(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(subscription); Mockito.when(subscriptionInternalApi.getBillingTransitions(Mockito.<SubscriptionBase>any(), Mockito.<InternalTenantContext>any())).thenReturn(effectiveSubscriptionTransitions); Mockito.when(subscriptionInternalApi.getAllTransitions(Mockito.<SubscriptionBase>any(), Mockito.<InternalTenantContext>any())).thenReturn(effectiveSubscriptionTransitions); catalog = ((MockCatalog) catalogService.getCurrentCatalog()); // TODO The MockCatalog module returns two different things for full vs current catalog Mockito.when(catalogService.getFullCatalog()).thenReturn(catalog); // Set a default alignment catalog.setBillingAlignment(BillingAlignment.ACCOUNT); // Cleanup mock daos ((MockBlockingStateDao) blockingStateDao).clear(); ((MockTagDao) tagDao).clear(); }
@GET @Path("/simpleCatalog") @Produces(APPLICATION_JSON) public Response getSimpleCatalog(@javax.ws.rs.core.Context final HttpServletRequest request) throws CatalogApiException { final StaticCatalog catalog = catalogService.getCurrentCatalog(); final CatalogJsonSimple json = new CatalogJsonSimple(catalog); return Response.status(Status.OK).entity(json).build(); } }
private Catalog initCatalog(final CatalogService catalogService) throws Exception { ((DefaultCatalogService) catalogService).loadCatalog(); final Catalog catalog = catalogService.getFullCatalog(); assertNotNull(catalog); return catalog; }
@GET @Path("/availableBasePlans") @Produces(APPLICATION_JSON) public Response getAvailableBasePlans(@javax.ws.rs.core.Context final HttpServletRequest request) throws CatalogApiException { final StaticCatalog catalog = catalogService.getCurrentCatalog(); final List<Listing> listings = catalog.getAvailableBasePlanListings(); final List<PlanDetailJson> details = new ArrayList<PlanDetailJson>(); for (final Listing listing : listings) { details.add(new PlanDetailJson(listing)); } return Response.status(Status.OK).entity(details).build(); }
private BusinessSubscriptionEvent subscriptionRecreated(final SubscriptionInternalEvent recreated) throws AccountApiException, EntitlementUserApiException { return BusinessSubscriptionEvent.subscriptionRecreated(recreated.getNextPlan(), catalogService.getFullCatalog(), recreated.getEffectiveTransitionTime(), recreated.getSubscriptionStartDate()); }
@GET @Path("/availableAddons") @Produces(APPLICATION_JSON) public Response getAvailableAddons(@QueryParam("baseProductName") final String baseProductName, @javax.ws.rs.core.Context final HttpServletRequest request) throws CatalogApiException { final StaticCatalog catalog = catalogService.getCurrentCatalog(); final List<Listing> listings = catalog.getAvailableAddonListings(baseProductName); final List<PlanDetailJson> details = new ArrayList<PlanDetailJson>(); for (final Listing listing : listings) { details.add(new PlanDetailJson(listing)); } return Response.status(Status.OK).entity(details).build(); }
@BeforeClass(groups = "slow") public void beforeClass() throws Exception { super.beforeClass(); Mockito.when(catalog.findPlan(Mockito.anyString(), Mockito.<DateTime>any())).thenReturn(plan); Mockito.when(catalog.findPlan(Mockito.anyString(), Mockito.<DateTime>any(), Mockito.<DateTime>any())).thenReturn(plan); Mockito.when(catalog.findPhase(Mockito.anyString(), Mockito.<DateTime>any(), Mockito.<DateTime>any())).thenReturn(phase); Mockito.when(catalogService.getFullCatalog()).thenReturn(catalog); setupBusinessSubscriptionTransition(); setupBusinessAccount(); }
private BusinessSubscriptionEvent subscriptionMigrated(final SubscriptionInternalEvent created) throws AccountApiException, EntitlementUserApiException { return BusinessSubscriptionEvent.subscriptionMigrated(created.getNextPlan(), catalogService.getFullCatalog(), created.getEffectiveTransitionTime(), created.getSubscriptionStartDate()); }
private BusinessSubscriptionEvent subscriptionCreated(final SubscriptionInternalEvent created) throws AccountApiException, EntitlementUserApiException { return BusinessSubscriptionEvent.subscriptionCreated(created.getNextPlan(), catalogService.getFullCatalog(), created.getEffectiveTransitionTime(), created.getSubscriptionStartDate()); }
private BusinessSubscriptionEvent subscriptionTransfered(final SubscriptionInternalEvent transfered) throws AccountApiException, EntitlementUserApiException { return BusinessSubscriptionEvent.subscriptionTransfered(transfered.getNextPlan(), catalogService.getFullCatalog(), transfered.getEffectiveTransitionTime(), transfered.getSubscriptionStartDate()); }
private BusinessSubscriptionEvent subscriptionChanged(final SubscriptionInternalEvent changed) throws AccountApiException, EntitlementUserApiException { return BusinessSubscriptionEvent.subscriptionChanged(changed.getNextPlan(), catalogService.getFullCatalog(), changed.getEffectiveTransitionTime(), changed.getSubscriptionStartDate()); }
private BusinessSubscriptionEvent subscriptionCancelled(final SubscriptionInternalEvent cancelled) throws AccountApiException, EntitlementUserApiException { // cancelled.getNextPlan() is null here - need to look at the previous one to create the correct event name return BusinessSubscriptionEvent.subscriptionCancelled(cancelled.getPreviousPlan(), catalogService.getFullCatalog(), cancelled.getEffectiveTransitionTime(), cancelled.getSubscriptionStartDate()); }
@Override @BeforeMethod(groups = "fast") public void beforeMethod() throws Exception { super.beforeMethod(); product = new MockProduct("platinium", "subscription", ProductCategory.BASE); plan = new MockPlan("platinum-monthly", product); phase = new MockPhase(PhaseType.EVERGREEN, plan, MockDuration.UNLIMITED(), 25.95); Mockito.when(catalog.findPlan(Mockito.anyString(), Mockito.<DateTime>any())).thenReturn(plan); Mockito.when(catalog.findPlan(Mockito.anyString(), Mockito.<DateTime>any(), Mockito.<DateTime>any())).thenReturn(plan); Mockito.when(catalog.findPhase(Mockito.anyString(), Mockito.<DateTime>any(), Mockito.<DateTime>any())).thenReturn(phase); Mockito.when(catalogService.getFullCatalog()).thenReturn(catalog); subscription = new MockSubscription(SubscriptionState.ACTIVE, plan, phase); }
@Override @BeforeMethod(groups = "fast") public void beforeMethod() throws Exception { super.beforeMethod(); product = new MockProduct("platinium", "subscription", ProductCategory.BASE); plan = new MockPlan("platinum-monthly", product); phase = new MockPhase(PhaseType.EVERGREEN, plan, MockDuration.UNLIMITED(), 25.95); Mockito.when(catalog.findPlan(Mockito.anyString(), Mockito.<DateTime>any())).thenReturn(plan); Mockito.when(catalog.findPlan(Mockito.anyString(), Mockito.<DateTime>any(), Mockito.<DateTime>any())).thenReturn(plan); Mockito.when(catalog.findPhase(Mockito.anyString(), Mockito.<DateTime>any(), Mockito.<DateTime>any())).thenReturn(phase); Mockito.when(catalogService.getFullCatalog()).thenReturn(catalog); isubscription = new MockSubscription(SubscriptionState.ACTIVE, plan, phase); subscription = new BusinessSubscription(isubscription, USD, catalog); }
private BusinessSubscriptionEvent subscriptionPhaseChanged(final SubscriptionInternalEvent phaseChanged) throws AccountApiException, EntitlementUserApiException { return BusinessSubscriptionEvent.subscriptionPhaseChanged(phaseChanged.getNextPlan(), phaseChanged.getNextState(), catalogService.getFullCatalog(), phaseChanged.getEffectiveTransitionTime(), phaseChanged.getSubscriptionStartDate()); }