private void registerForBus() { try { busService.getBus().register(listener); } catch (final EventBusException e) { log.error("Problem encountered registering OverdueListener on the Event Bus", e); } }
@LifecycleHandlerType(LifecycleHandlerType.LifecycleLevel.UNREGISTER_EVENTS) public void unregisterForNotifications() { try { eventBus.unregister(listener); } catch (InternalBus.EventBusException e) { throw new RuntimeException("Unable to unregister to the EventBus!", e); } } }
@LifecycleHandlerType(LifecycleHandlerType.LifecycleLevel.REGISTER_EVENTS) public void registerForNotifications() { try { eventBus.register(listener); } catch (InternalBus.EventBusException e) { log.error("Unable to register to the EventBus!", e); } }
@AfterMethod(groups = "fast") public void afterMethod() throws Exception { bus.stop(); } }
@BeforeMethod(groups = "fast") public void beforeMethod() throws Exception { bus.start(); }
bus.post(accountCreationNotification, internalCallContext); waitALittle(new Callable<Boolean>() { @Override bus.post(transition, internalCallContext); waitALittle(new Callable<Boolean>() { @Override bus.post(invoiceCreationNotification, internalCallContext); waitALittle(new Callable<Boolean>() { @Override bus.post(paymentInfoNotification, internalCallContext);
@AfterMethod(groups = "slow") public void afterMethod() throws Exception { bus.stop(); stopAnalyticsService(); }
@BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { super.beforeMethod(); bus.start(); restartAnalyticsService(); }
@LifecycleHandlerType(LifecycleLevel.STOP_SERVICE) public void stop() { try { busService.getBus().unregister(listener); } catch (final EventBusException e) { log.error("Problem encountered registering OverdueListener on the Event Bus", e); } checkNotifier.stop(); asyncNotifier.stop(); } }
nonEntityDao, invoiceNotifier, locker, busService.getBus(), clock);
nonEntityDao, invoiceNotifier, locker, busService.getBus(), clock);
public UUID generateRegularInvoice(final Account account, final DateTime targetDate, final CallContext callContext) throws Exception { final SubscriptionBase subscription = Mockito.mock(SubscriptionBase.class); Mockito.when(subscription.getId()).thenReturn(UUID.randomUUID()); Mockito.when(subscription.getBundleId()).thenReturn(new UUID(0L, 0L)); final BillingEventSet events = new MockBillingEventSet(); final Plan plan = MockPlan.createBicycleNoTrialEvergreen1USD(); final PlanPhase planPhase = MockPlanPhase.create1USDMonthlyEvergreen(); final DateTime effectiveDate = new DateTime().minusDays(1); final Currency currency = Currency.USD; final BigDecimal fixedPrice = null; events.add(createMockBillingEvent(account, subscription, effectiveDate, plan, planPhase, fixedPrice, BigDecimal.ONE, currency, BillingPeriod.MONTHLY, 1, BillingModeType.IN_ADVANCE, "", 1L, SubscriptionBaseTransitionType.CREATE)); Mockito.when(billingApi.getBillingEventsForAccountAndUpdateAccountBCD(Mockito.<UUID>any(), Mockito.<InternalCallContext>any())).thenReturn(events); final InvoiceNotifier invoiceNotifier = new NullInvoiceNotifier(); final InvoiceDispatcher dispatcher = new InvoiceDispatcher(generator, accountApi, billingApi, subscriptionApi, invoiceDao, nonEntityDao, invoiceNotifier, locker, busService.getBus(), clock); Invoice invoice = dispatcher.processAccount(account.getId(), targetDate, true, internalCallContext); Assert.assertNotNull(invoice); final InternalCallContext context = internalCallContextFactory.createInternalCallContext(account.getId(), callContext); List<InvoiceModelDao> invoices = invoiceDao.getInvoicesByAccount(context); Assert.assertEquals(invoices.size(), 0); invoice = dispatcher.processAccount(account.getId(), targetDate, false, context); Assert.assertNotNull(invoice); invoices = invoiceDao.getInvoicesByAccount(context); Assert.assertEquals(invoices.size(), 1); return invoice.getId(); }
final InvoiceNotifier invoiceNotifier = new NullInvoiceNotifier(); final InvoiceDispatcher dispatcher = new InvoiceDispatcher(generator, accountApi, billingApi, subscriptionApi, invoiceDao, nonEntityDao, invoiceNotifier, locker, busService.getBus(), clock);