@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (id != null ? id.hashCode() : 0); result = 31 * result + (key != null ? key.hashCode() : 0); return result; } }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } final DefaultTenantConfigChangeInternalEvent that = (DefaultTenantConfigChangeInternalEvent) o; if (id != null ? !id.equals(that.id) : that.id != null) { return false; } return key != null ? key.equals(that.key) : that.key == null; }
@AllowConcurrentEvents @Subscribe public void handlePaymentInfoEvent(final InvoicePaymentInfoInternalEvent event) { log.debug("Received InvoicePaymentInfo event {}", event); insertBusEventIntoNotificationQueue(event.getAccountId(), event); }
@AllowConcurrentEvents @Subscribe public void handleTagRemoval(final ControlTagDeletionInternalEvent event) { if (event.getTagDefinition().getName().equals(ControlTagType.OVERDUE_ENFORCEMENT_OFF.toString()) && event.getObjectType() == ObjectType.ACCOUNT) { insertBusEventIntoNotificationQueue(event.getObjectId(), event); } else if (event.getTagDefinition().getName().equals(ControlTagType.WRITTEN_OFF.toString()) && event.getObjectType() == ObjectType.INVOICE) { final UUID accountId = nonEntityDao.retrieveIdFromObject(event.getSearchKey1(), ObjectType.ACCOUNT, objectIdCacheController); insertBusEventIntoNotificationQueue(accountId, event); } }
@Override public void onSubscriptionBaseTransition(final EffectiveSubscriptionInternalEvent event) { log.info("Got event SubscriptionBaseTransition token='{}', type='{}', remaining='{}'", event.getUserToken(), event.getTransitionType(), event.getRemainingEventsForUserOperation()); }
@AllowConcurrentEvents @Subscribe public void handleTagInsert(final ControlTagCreationInternalEvent event) { if (event.getTagDefinition().getName().equals(ControlTagType.OVERDUE_ENFORCEMENT_OFF.toString()) && event.getObjectType() == ObjectType.ACCOUNT) { final InternalCallContext internalCallContext = createCallContext(event.getUserToken(), event.getSearchKey1(), event.getSearchKey2()); insertBusEventIntoNotificationQueue(event.getObjectId(), OverdueAsyncBusNotificationAction.CLEAR, internalCallContext); } else if (event.getTagDefinition().getName().equals(ControlTagType.WRITTEN_OFF.toString()) && event.getObjectType() == ObjectType.INVOICE) { final UUID accountId = nonEntityDao.retrieveIdFromObject(event.getSearchKey1(), ObjectType.ACCOUNT, objectIdCacheController); insertBusEventIntoNotificationQueue(accountId, event); } }
@Test(groups = "fast") public void testBasic() throws Exception { final ObjectMapper objectMapper = new ObjectMapper(); objectMapper.registerModule(new JodaModule()); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); final String eventJson = "\"{\"pluginName\":\"foo\",\"pluginVersion\":\"1.2.3\",\"properties\":[{\"key\":\"something\",\"value\":\"nothing\"}]}\""; final BroadcastInternalEvent broadcastEvent = new DefaultBroadcastInternalEvent("service", "PLUGIN_INSTALL", eventJson); final String broadcastEventStr = objectMapper.writeValueAsString(broadcastEvent); final BroadcastInternalEvent res = objectMapper.readValue(broadcastEventStr, DefaultBroadcastInternalEvent.class); Assert.assertEquals(res.getServiceName(), "service"); Assert.assertEquals(res.getType(), "PLUGIN_INSTALL"); Assert.assertEquals(res.getJsonEvent(), eventJson); } }
log.info(String.format("Got subscription event %s", eventEffective.toString())); Assert.assertNotNull(eventEffective.getBundleExternalKey()); switch (eventEffective.getTransitionType()) { case TRANSFER: assertEqualsNicely(NextEvent.TRANSFER); break; default: throw new RuntimeException("Unexpected event type " + eventEffective.getRequestedTransitionTime());
private void verifyTagEvent(final UUID tagId, final UUID objectId, final ObjectType objectType, final UUID tagDefinitionId, final String tagDefinitionName, final String tagDefinitionDescription, final TagDefinition tagDefinition, final UUID userToken, final TagInternalEvent event) { Assert.assertEquals(event.getTagId(), tagId); Assert.assertEquals(event.getObjectId(), objectId); Assert.assertEquals(event.getObjectType(), objectType); Assert.assertEquals(event.getTagDefinition(), tagDefinition); Assert.assertEquals(event.getTagDefinition().getId(), tagDefinitionId); Assert.assertEquals(event.getTagDefinition().getName(), tagDefinitionName); Assert.assertEquals(event.getTagDefinition().getDescription(), tagDefinitionDescription); Assert.assertEquals(event, event); Assert.assertTrue(event.equals(event)); } }
if (curEvent.getUserToken() == null || !curEvent.getUserToken().equals(userToken)) { return; switch (curEvent.getBusEventType()) { case ACCOUNT_CREATE: onAccountCreation((AccountCreationInternalEvent) curEvent); break; default: throw new RuntimeException("Unexpected event type " + curEvent.getBusEventType());
assertTrue(subscriptionInternalApi.getAllTransitions(newBaseSubscription, internalCallContext).get(1).getEffectiveTransitionTime().compareTo(evergreenPhaseDate) == 0);
@Test(groups = "slow", description = "Test Account creation generates an event") public void testBusEvents() throws Exception { final AccountEventHandler eventHandler = new AccountEventHandler(); bus.register(eventHandler); final AccountModelDao accountModelDao = createTestAccount(); final AccountData defaultAccount = new DefaultAccount(accountModelDao); final Account account = createAccount(defaultAccount); await().atMost(10, SECONDS).until(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return eventHandler.getAccountCreationInternalEvents().size() == 1; } }); final AccountCreationInternalEvent accountCreationInternalEvent = eventHandler.getAccountCreationInternalEvents().get(0); Assert.assertEquals(accountCreationInternalEvent.getId(), account.getId()); // account_record_id is most likely 1, although, depending on the DB, we cannot be sure Assert.assertNotNull(accountCreationInternalEvent.getSearchKey1()); Assert.assertEquals(accountCreationInternalEvent.getSearchKey2(), internalCallContext.getTenantRecordId()); }
@AllowConcurrentEvents @Subscribe public void handleInvoiceCreation(final InvoiceCreationInternalEvent event) { log.debug("Received InvoiceCreation event {}", event); insertBusEventIntoNotificationQueue(event.getAccountId(), event); }
private void verifyTagDefinitionEvent(final UUID tagDefinitionId, final String tagDefinitionName, final String tagDefinitionDescription, final TagDefinition tagDefinition, final UUID userToken, final TagDefinitionInternalEvent event) { Assert.assertEquals(event.getTagDefinitionId(), tagDefinitionId); Assert.assertEquals(event.getTagDefinition(), tagDefinition); Assert.assertEquals(event.getTagDefinition().getId(), tagDefinitionId); Assert.assertEquals(event.getTagDefinition().getName(), tagDefinitionName); Assert.assertEquals(event.getTagDefinition().getDescription(), tagDefinitionDescription); Assert.assertEquals(event, event); Assert.assertTrue(event.equals(event)); }
@AllowConcurrentEvents @Subscribe public void handleInvoiceAdjustmentEvent(final InvoiceAdjustmentInternalEvent event) { log.debug("Received InvoiceAdjustment event {}", event); insertBusEventIntoNotificationQueue(event.getAccountId(), event); }
@AllowConcurrentEvents @Subscribe public void handlePaymentErrorEvent(final InvoicePaymentErrorInternalEvent event) { log.debug("Received InvoicePaymentError event {}", event); insertBusEventIntoNotificationQueue(event.getAccountId(), event); }
private void checkBussEvent(final String state) throws Exception { await().atMost(10, SECONDS).until(new Callable<Boolean>() { @Override public Boolean call() throws Exception { final List<OverdueChangeInternalEvent> events = listener.getEventsReceived(); return events.size() == 1; } }); final List<OverdueChangeInternalEvent> events = listener.getEventsReceived(); Assert.assertEquals(1, events.size()); Assert.assertEquals(state, events.get(0).getNextOverdueStateName()); listener.clearEventsReceived(); } }
@Override public void update(final AccountModelDao account, final boolean treatNullValueAsReset, final InternalCallContext context) { super.update(account, context); final AccountModelDao currentAccount = getById(account.getId(), context); final Long accountRecordId = getRecordId(account.getId(), context); final long tenantRecordId = context == null ? InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID : context.getTenantRecordId(); final AccountChangeInternalEvent changeEvent = new DefaultAccountChangeEvent(account.getId(), currentAccount, account, accountRecordId, tenantRecordId, UUID.randomUUID(), clock.getUTCNow()); if (changeEvent.hasChanges()) { try { eventBus.post(changeEvent); } catch (final EventBusException ex) { Assert.fail(ex.toString()); } } }
@Override public void onInvoicePaymentError(final InvoicePaymentErrorInternalEvent event) { log.info("Got event InvoicePaymentError token='{}'", event.getUserToken()); notifyForCompletion(); } }
assertTrue(subscriptionInternalApi.getAllTransitions(newBaseSubscription, internalCallContext).get(1).getEffectiveTransitionTime().compareTo(evergreenPhaseDate) == 0);