private void insertBusEventIntoNotificationQueue(final UUID accountId, final BusEvent event) { final InternalCallContext internalCallContext = createCallContext(event.getUserToken(), event.getSearchKey1(), event.getSearchKey2()); insertBusEventIntoNotificationQueue(accountId, OverdueAsyncBusNotificationAction.REFRESH, internalCallContext); }
private void registerForBus() { try { busService.getBus().register(listener); } catch (final EventBusException e) { log.error("Failed to register OverdueListener", e); } }
@AfterMethod(groups = "fast") public void afterMethod() throws Exception { bus.stop(); } }
@AfterMethod(groups = "slow") public void afterMethod() throws Exception { if (hasFailed()) { return; } eventBus.unregister(eventsListener); eventBus.stop(); }
@BeforeMethod(groups = "fast") public void beforeMethod() throws Exception { if (hasFailed()) { return; } eventBus.start(); }
@Override public void broadcast(final String serviceName, final String type, final String event, final DateTime createdDate, final String createdBy, final boolean localNodeOnly) { // If localNodeOnly, this is not really a broadcast api anymore, but we still rely on that broadcast bus event to notify the local node if (localNodeOnly) { final BroadcastInternalEvent busEvent = new DefaultBroadcastInternalEvent(serviceName, type, event); try { eventBus.post(busEvent); } catch (final EventBusException e) { logger.warn("Failed to post event {}", event, e); } } else { final BroadcastModelDao modelDao = new BroadcastModelDao(serviceName, type, event, createdDate, createdBy); dao.create(modelDao); } } }
@Override public void create(final AccountModelDao account, final InternalCallContext context) throws AccountApiException { super.create(account, context); try { final Long accountRecordId = getRecordId(account.getId(), context); final long tenantRecordId = context == null ? InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID : context.getTenantRecordId(); eventBus.post(new DefaultAccountCreationEvent(new DefaultAccountData(account), account.getId(), accountRecordId, tenantRecordId, UUID.randomUUID())); } catch (final EventBusException ex) { Assert.fail(ex.toString()); } }
@LifecycleHandlerType(LifecycleLevel.STOP_SERVICE) public void stop() { try { busService.getBus().unregister(listener); } catch (final EventBusException e) { log.error("Failed to unregister OverdueListener", e); } checkNotifier.stop(); asyncNotifier.stop(); }
private void stopBusAndUnregisterListener(final BusService busService, final TestApiListener testListener) throws Exception { busService.getBus().unregister(testListener); busService.getBus().stop(); }
@AfterMethod(groups = "slow") public void afterMethod() throws Exception { bus.stop(); }
@BeforeMethod(groups = "fast") public void beforeMethod() throws Exception { if (hasFailed()) { return; } bus.start(); }
private void notifyBusOfEffectiveImmediateChange(final DefaultSubscriptionBase subscription, final SubscriptionBaseEvent immediateEvent, final int seqId, final InternalCallContext context) { try { final SubscriptionBaseTransitionData transition = subscription.getTransitionFromEvent(immediateEvent, seqId); final BusEvent busEvent = new DefaultEffectiveSubscriptionEvent(transition, subscription.getAlignStartDate(), context.getUserToken(), context.getAccountRecordId(), context.getTenantRecordId()); eventBus.post(busEvent); } catch (final EventBusException e) { log.warn("Failed to post effective event for subscription " + subscription.getId(), e); } }
@AfterMethod(groups = "slow") public void afterMethod() throws Exception { if (hasFailed()) { return; } service.stop(); bus.unregister(listener); bus.stop(); } }
@AfterMethod(groups = "fast") public void afterMethod() throws Exception { if (hasFailed()) { return; } eventBus.stop(); // Reset the security manager ThreadContext.unbindSecurityManager(); }
@BeforeMethod(groups = "fast") public void beforeMethod() throws Exception { if (hasFailed()) { return; } bus.start(); service.initialize(); service.start(); }
@AfterMethod(groups = "fast") public void afterMethod() { if (hasFailed()) { return; } service.stop(); bus.stop(); } }
@BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { if (hasFailed()) { return; } super.beforeMethod(); controllerDispatcher.clearAll(); bus.start(); }