### Question:
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);  }### Answer:
@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"); }
@Test public void testAliasEdited() { AcmMarshaller acmMarshaller = ObjectConverter.createJSONMarshallerForTests(); PersonAssociation personAssociation = getPersonAssociation(1L, "TestAlias"); String currentJsonObject = acmMarshaller.marshal(personAssociation); List<PersonAlias> personAliases = personAssociation.getPerson().getPersonAliases(); PersonAlias personAlias = personAliases.get(0); personAlias.setAliasValue("TestAliasEdited"); 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.updated"); }
@Test public void testAliasRemoved() { AcmMarshaller acmMarshaller = ObjectConverter.createJSONMarshallerForTests(); PersonAssociation personAssociation = getPersonAssociation(1L, "TestAlias1"); String currentJsonObject = acmMarshaller.marshal(personAssociation); List<PersonAlias> personAliases = personAssociation.getPerson().getPersonAliases(); personAliases.remove(0); 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.deleted"); }