@Test public void testAliasAdded() { AcmMarshaller acmMarshaller = ObjectConverter.createJSONMarshallerForTests(); PersonAssociation personAssociation = getPersonAssociation(1L, "TestAlias1"); String currentJsonObject = acmMarshaller.marshal(personAssociation); PersonAlias newPersonAlias = getPersonAlias(2L, "TestAlias2"); List<PersonAlias> personAliases = personAssociation.getPerson().getPersonAliases(); personAliases.add(newPersonAlias); personAssociation.getPerson().setPersonAliases(personAliases); Capture<PersonPersistenceEvent> eventCapture = Capture.newInstance(); mockEventPublisher.publishEvent(capture(eventCapture)); expectLastCall().once(); replayAll(); personAssociationEventPublisher.publishPersonAssociationEvent(currentJsonObject, personAssociation, true); verifyAll(); assertEquals(eventCapture.getValue().getEventType(), "com.armedia.acm.person.personAlias.added"); }
@Async public void publishPersonAssociationEvent(PersonAssociation source, String ipAddress, boolean newPersonAssociation, boolean succeeded) { log.debug("Publishing a person event."); PersonAssociationPersistenceEvent personAssociationPersistenceEvent = newPersonAssociation ? new PersonAssociationAddEvent(source, source.getParentType(), source.getParentId(), AuthenticationUtils.getUserIpAddress()) : new PersonAssociationUpdatedEvent(source, source.getParentType(), source.getParentId(), AuthenticationUtils.getUserIpAddress()); personAssociationPersistenceEvent.setSucceeded(succeeded); eventPublisher.publishEvent(personAssociationPersistenceEvent); }
PersonAssociationEventPublisher implements ApplicationEventPublisherAware { @Async public void publishPersonAssociationEvent(PersonAssociation source, String ipAddress, boolean newPersonAssociation, boolean succeeded) { log.debug("Publishing a person event."); PersonAssociationPersistenceEvent personAssociationPersistenceEvent = newPersonAssociation ? new PersonAssociationAddEvent(source, source.getParentType(), source.getParentId(), AuthenticationUtils.getUserIpAddress()) : new PersonAssociationUpdatedEvent(source, source.getParentType(), source.getParentId(), AuthenticationUtils.getUserIpAddress()); personAssociationPersistenceEvent.setSucceeded(succeeded); eventPublisher.publishEvent(personAssociationPersistenceEvent); } }
PersonAssociationEventPublisher implements ApplicationEventPublisherAware { @Async public void publishPersonAssociationEvent(PersonAssociation source, String ipAddress, boolean newPersonAssociation, boolean succeeded) { log.debug("Publishing a person event."); PersonAssociationPersistenceEvent personAssociationPersistenceEvent = newPersonAssociation ? new PersonAssociationAddEvent(source, source.getParentType(), source.getParentId(), AuthenticationUtils.getUserIpAddress()) : new PersonAssociationUpdatedEvent(source, source.getParentType(), source.getParentId(), AuthenticationUtils.getUserIpAddress()); personAssociationPersistenceEvent.setSucceeded(succeeded); eventPublisher.publishEvent(personAssociationPersistenceEvent); }  }
PersonAssociationEventPublisher implements ApplicationEventPublisherAware { @Async public void publishPersonAssociationEvent(PersonAssociation source, String ipAddress, boolean newPersonAssociation, boolean succeeded) { log.debug("Publishing a person event."); PersonAssociationPersistenceEvent personAssociationPersistenceEvent = newPersonAssociation ? new PersonAssociationAddEvent(source, source.getParentType(), source.getParentId(), AuthenticationUtils.getUserIpAddress()) : new PersonAssociationUpdatedEvent(source, source.getParentType(), source.getParentId(), AuthenticationUtils.getUserIpAddress()); personAssociationPersistenceEvent.setSucceeded(succeeded); eventPublisher.publishEvent(personAssociationPersistenceEvent); }  @Override void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher); @Async void publishPersonAssociationEvent(PersonAssociation source, String ipAddress, boolean newPersonAssociation, boolean succeeded); @Async void publishPersonAssociationEvent(String personAssociationHistory, PersonAssociation source, boolean succeeded); @Async void publishPersonEvent(Person person, String eventAction, boolean succeeded, String parentType, Long parentId); @Async void publishPersonAssociationEvent(PersonAssociation source, String eventAction, boolean succeeded); @Async void publishPersonAssociationDeletedEvent(PersonAssociation source); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter objectConverter); }
PersonAssociationEventPublisher implements ApplicationEventPublisherAware { @Async public void publishPersonAssociationEvent(PersonAssociation source, String ipAddress, boolean newPersonAssociation, boolean succeeded) { log.debug("Publishing a person event."); PersonAssociationPersistenceEvent personAssociationPersistenceEvent = newPersonAssociation ? new PersonAssociationAddEvent(source, source.getParentType(), source.getParentId(), AuthenticationUtils.getUserIpAddress()) : new PersonAssociationUpdatedEvent(source, source.getParentType(), source.getParentId(), AuthenticationUtils.getUserIpAddress()); personAssociationPersistenceEvent.setSucceeded(succeeded); eventPublisher.publishEvent(personAssociationPersistenceEvent); }  @Override void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher); @Async void publishPersonAssociationEvent(PersonAssociation source, String ipAddress, boolean newPersonAssociation, boolean succeeded); @Async void publishPersonAssociationEvent(String personAssociationHistory, PersonAssociation source, boolean succeeded); @Async void publishPersonEvent(Person person, String eventAction, boolean succeeded, String parentType, Long parentId); @Async void publishPersonAssociationEvent(PersonAssociation source, String eventAction, boolean succeeded); @Async void publishPersonAssociationDeletedEvent(PersonAssociation source); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter objectConverter);  }