Refine search
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); } }
@Override @BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { if (hasFailed()) { return; } super.beforeMethod(); eventsListener.reset(); eventBus.start(); eventBus.register(eventsListener); }
@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(); }
private void stopBusAndUnregisterListener(final BusService busService, final TestApiListener testListener) throws Exception { busService.getBus().unregister(testListener); busService.getBus().stop(); }
@BeforeMethod(groups = "fast") public void beforeMethod() throws Exception { if (hasFailed()) { return; } eventBus.start(); }
@BeforeMethod(groups = "slow") public void setUp() throws Exception { if (hasFailed()) { return; } mockPaymentProviderPlugin = (MockPaymentProviderPlugin) registry.getServiceForName(MockPaymentProviderPlugin.PLUGIN_NAME); account = testHelper.createTestAccount(UUID.randomUUID().toString(), true); paymentBusListener = new PaymentBusListener(); eventBus.register(paymentBusListener); }
@AfterMethod(groups = "slow") public void afterMethod() throws Exception { if (hasFailed()) { return; } retryService.stop(); eventBus.unregister(handler); eventBus.unregister(testListener); super.afterMethod(); }
private void notifyBusOfRequestedChange(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final DefaultSubscriptionBase subscription, final SubscriptionBaseEvent nextEvent, final SubscriptionBaseTransitionType transitionType, final InternalCallContext context) { try { eventBus.postFromTransaction(new DefaultRequestedSubscriptionEvent(subscription, nextEvent, transitionType, context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken()), entitySqlDaoWrapperFactory.getHandle().getConnection()); } catch (final EventBusException e) { log.warn("Failed to post requested change event for subscriptionId='{}'", subscription.getId(), e); } }
public void testSimpleWithExceptionAndFail() { try { final MyEventHandler handler = new MyEventHandler(1, 4); eventBus.register(handler); eventBus.post(new MyEvent("my-event", 1L, "MY_EVENT_TYPE", 1L, 2L, UUID.randomUUID())); final boolean completed = handler.waitForCompletion(5000); Assert.assertEquals(completed, false); } catch (final Exception ignored) { } }
@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()); } }
final OverdueState nextOverdueState, final InternalCallContext context) throws OverdueException, OverdueApiException { if (isAccountTaggedWith_OVERDUE_ENFORCEMENT_OFF(context)) { log.debug("OverdueStateApplicator: apply returns because account (recordId={}) is set with OVERDUE_ENFORCEMENT_OFF", context.getAccountRecordId()); return; bus.post(event); } catch (final Exception e) { log.warn("Failed to post event {}", event, e);
private void notifyBusOfInvoiceAdjustment(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final UUID invoiceId, final UUID accountId, final UUID userToken, final InternalCallContext context) { try { eventBus.postFromTransaction(new DefaultInvoiceAdjustmentEvent(invoiceId, accountId, context.getAccountRecordId(), context.getTenantRecordId(), userToken), entitySqlDaoWrapperFactory.getHandle().getConnection()); } catch (final EventBusException e) { log.warn("Failed to post adjustment event for invoiceId='{}'", invoiceId, e); } }
@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); } } }
private void registerForBus() { try { busService.getBus().register(listener); } catch (final EventBusException e) { log.error("Failed to register OverdueListener", e); } }
@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(); }
@Override public Void inTransaction(final Handle conn, final TransactionStatus status) throws Exception { Assert.assertEquals(conn.select("select now();").size(), 1); final BusEvent event = new LoadBusEvent(); eventBus.postFromTransaction(event, conn.getConnection()); return null; } });
@BeforeMethod(groups = "fast") public void beforeMethod() throws Exception { if (hasFailed()) { return; } bus.start(); }
@BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { if (hasFailed()) { return; } log.debug("RESET TEST FRAMEWORK"); cleanupAllTables(); clock.resetDeltaFromReality(); busHandler.reset(); lifecycle.fireStartupSequencePriorEventRegistration(); busService.getBus().register(busHandler); externalBus.register(new FakeKPMPlugin()); lifecycle.fireStartupSequencePostEventRegistration(); }