@Test public void testPublishDocument() throws OperationException { try (OperationContext ctx = new OperationContext(session); CapturingEventListener listener = new CapturingEventListener(DocumentEventTypes.DOCUMENT_PUBLISHED)) { ctx.setInput(fileToPublish); DocumentModel publishedDoc = (DocumentModel) service.run(ctx, PublishDocument.ID, Collections.singletonMap("target", section)); assertEquals(section.getId(), session.getDocument(publishedDoc.getParentRef()).getId()); assertEquals(1, session.getChildren(section.getRef()).size()); List<Event> events = listener.getCapturedEvents(); assertEquals(2, events.size()); assertEquals(fileToPublish, ((DocumentEventContext) events.get(0).getContext()).getSourceDocument()); assertEquals(publishedDoc, ((DocumentEventContext) events.get(1).getContext()).getSourceDocument()); } }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { DocumentModel proxy = session.publishDocument(doc, target, override); notifyPublishedEvent(doc); notifyPublishedEvent(proxy); return proxy; }
PublishDocument { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { DocumentModel proxy = session.publishDocument(doc, target, override); notifyPublishedEvent(doc); notifyPublishedEvent(proxy); return proxy; } }
PublishDocument { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { DocumentModel proxy = session.publishDocument(doc, target, override); notifyPublishedEvent(doc); notifyPublishedEvent(proxy); return proxy; }  }
PublishDocument { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { DocumentModel proxy = session.publishDocument(doc, target, override); notifyPublishedEvent(doc); notifyPublishedEvent(proxy); return proxy; }  @OperationMethod(collector = DocumentModelCollector.class) DocumentModel run(DocumentModel doc); }
PublishDocument { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { DocumentModel proxy = session.publishDocument(doc, target, override); notifyPublishedEvent(doc); notifyPublishedEvent(proxy); return proxy; }  @OperationMethod(collector = DocumentModelCollector.class) DocumentModel run(DocumentModel doc); static final String ID; }