### Question:
KieMultipleDocumentEditor implements KieMultipleDocumentEditorPresenter<D> { @Override public void registerDocument(final D document) { PortablePreconditions.checkNotNull("document", document); if (documents.contains(document)) { return; } documents.add(document); registeredDocumentsMenuBuilder.registerDocument(document); final ObservablePath path = document.getLatestPath(); path.onRename(() -> refresh(document)); path.onConcurrentRename((info) -> doConcurrentRename(document, info)); path.onDelete(() -> { enableMenus(false); removeDocument(document); deregisterDocument(document); }); path.onConcurrentDelete((info) -> { doConcurrentDelete(document, info); }); path.onConcurrentUpdate((eventInfo) -> document.setConcurrentUpdateSessionInfo(eventInfo)); } KieMultipleDocumentEditor();  KieMultipleDocumentEditor(final KieEditorView editorView); @Override void registerDocument(final D document); @Override void deregisterDocument(final D document); @Override void activateDocument(final D document,
                                 final Overview overview,
                                 final AsyncPackageDataModelOracle dmo,
                                 final Imports imports,
                                 final boolean isReadOnly); @Override D getActiveDocument(); @Override IsWidget getWidget(); @Override IsWidget getTitleWidget(final D document); @Override void getMenus(final Consumer<Menus> menusConsumer); @Override void onClose(); @Override void onSourceTabSelected(); @Override void updateSource(final String source); @Override void onEditTabSelected(); @Override void onEditTabUnselected(); @Override void onOverviewSelected(); @Override boolean mayClose(final Integer originalHashCode,
                            final Integer currentHashCode); @Override Promise<Void> makeMenuBar();  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testRegisterNullDocument() { registerDocument(null); }
@Test @SuppressWarnings("unchecked") public void testRegisterDocument() { final TestDocument document = createTestDocument(); final ObservablePath path = document.getLatestPath(); registerDocument(document); verify(path, times(1)).onRename(any(Command.class)); verify(path, times(1)).onConcurrentRename(any(ParameterizedCommand.class)); verify(path, times(1)).onDelete(any(Command.class)); verify(path, times(1)).onConcurrentDelete(any(ParameterizedCommand.class)); verify(path, times(1)).onConcurrentUpdate(any(ParameterizedCommand.class)); verify(registeredDocumentsMenuBuilder, times(1)).registerDocument(document); }
@Test public void testRegisterDocumentAlreadyRegistered() { final TestDocument document = createTestDocument(); registerDocument(document); registerDocument(document); assertEquals(1, editor.documents.size()); }
@Test public void testRenameCommand() { final TestDocument document = createTestDocument(); final ObservablePath path = document.getLatestPath(); registerDocument(document); final ArgumentCaptor<Command> renameCommandCaptor = ArgumentCaptor.forClass(Command.class); verify(path, times(1)).onRename(renameCommandCaptor.capture()); final Command renameCommand = renameCommandCaptor.getValue(); assertNotNull(renameCommand); renameCommand.execute(); verify(editorView, times(2)).refreshTitle(any(String.class)); verify(editorView, times(1)).showBusyIndicator(any(String.class)); verify(editor, times(2)).getDocumentTitle(eq(document)); verify(editor, times(1)).refreshDocument(eq(document)); verify(changeTitleEvent, times(1)).fire(any(ChangeTitleWidgetEvent.class)); }
@Test @SuppressWarnings("unchecked") public void testConcurrentUpdate() { final TestDocument document = createTestDocument(); final ObservablePath path = document.getLatestPath(); registerDocument(document); final ArgumentCaptor<ParameterizedCommand> updateCommandCaptor = ArgumentCaptor.forClass(ParameterizedCommand.class); verify(path, times(1)).onConcurrentUpdate(updateCommandCaptor.capture()); final ParameterizedCommand updateCommand = updateCommandCaptor.getValue(); assertNotNull(updateCommand); final ObservablePath.OnConcurrentUpdateEvent info = mock(ObservablePath.OnConcurrentUpdateEvent.class); updateCommand.execute(info); verify(document, times(1)).setConcurrentUpdateSessionInfo(eq(info)); }