### Question:
XClassPropertyEventGeneratorListener implements EventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; XWikiDocument originalDoc = doc.getOriginalDocument(); XWikiContext context = (XWikiContext) data; if (event instanceof DocumentUpdatedEvent) { onDocumentUpdatedEvent(originalDoc, doc, context); } else if (event instanceof DocumentDeletedEvent) { onDocumentDeletedEvent(originalDoc, doc, context); } else if (event instanceof DocumentCreatedEvent) { onDocumentCreatedEvent(originalDoc, doc, context); } }  @Override String getName(); @Override List<Event> getEvents(); @Override void onEvent(Event event, Object source, Object data);  }### Answer:
@Test public void testAddDocument() throws ComponentLookupException { this.xclass.addTextField("property", "Property", 30); final Event event = new XClassPropertyAddedEvent(this.xclass.getField("property").getReference()); this.mocker.getComponentUnderTest().onEvent(new DocumentCreatedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext()); verify(this.mockObservation).notify(eq(event), same(this.document), same(this.oldcore.getXWikiContext())); }
@Test public void testDeleteDocument() throws ComponentLookupException { this.xclassOrigin.addTextField("property", "Property", 30); final Event event = new XClassPropertyDeletedEvent(this.xclassOrigin.getField("property").getReference()); this.mocker.getComponentUnderTest().onEvent(new DocumentDeletedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext()); verify(this.mockObservation).notify(eq(event), same(this.document), same(this.oldcore.getXWikiContext())); }
@Test public void testModifiedDocumentXClassPropertyAdded() throws ComponentLookupException { this.xclass.addTextField("property", "Property", 30); final Event event = new XClassPropertyAddedEvent(this.xclass.getField("property").getReference()); this.mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext()); verify(this.mockObservation).notify(eq(event), same(this.document), same(this.oldcore.getXWikiContext())); }
@Test public void testModifiedDocumentXClassPropertyDeleted() throws ComponentLookupException { this.xclassOrigin.addTextField("property", "Property", 30); final Event event = new XClassPropertyDeletedEvent(this.xclassOrigin.getField("property").getReference()); this.mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext()); verify(this.mockObservation).notify(eq(event), same(this.document), same(this.oldcore.getXWikiContext())); }
@Test public void testModifiedDocumentXClassPropertyModified() throws ComponentLookupException { this.xclassOrigin.addTextField("property", "Property", 30); this.xclass.addTextField("property", "New Property", 30); final Event event = new XClassPropertyUpdatedEvent(this.xclassOrigin.getField("property").getReference()); this.mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext()); verify(this.mockObservation).notify(eq(event), same(this.document), same(this.oldcore.getXWikiContext())); }