@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 @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(); } }
@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(); }
@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(); }
@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(); }
@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); } }
@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(); }