### Question:
DataModelerScreenPresenter extends KieEditor<String> { void onCopy() { validationService.call(checkMessages -> { if (((List<ValidationMessage>) checkMessages).isEmpty()) { showCopyPopup(); } else { validationPopup.showCopyValidationMessages(() -> showCopyPopup(), () -> { }, ((List<ValidationMessage>) checkMessages)); } }).validateForCopy(versionRecordManager.getPathToLatest(), context.getDataObject()); } @Inject  DataModelerScreenPresenter(DataModelerScreenView baseView,
                                      SessionInfo sessionInfo); @WorkbenchPartTitle String getTitleText(); @WorkbenchPartTitleDecoration IsWidget getTitle(); @WorkbenchPartView IsWidget getView(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @OnStartup void onStartup(final ObservablePath path,
                          final PlaceRequest place); @OnFocus void onFocus(); @Override void showDocks(); @Override void hideDocks(); @OnMayClose boolean onMayClose(); @OnClose @Override void onClose(); void onSafeDelete(); void onSafeRename(); DataModel getDataModel(); String getSource(); void setSource(String source); @Override void onSourceTabSelected(); @Override void onOverviewSelected(); @Override void onEditTabSelected(); static final String EDITOR_ID; }### Answer:
@Test public void onCopyValidationSucceededTest() { when(validationService.validateForCopy(any(Path.class), any(DataObject.class))).thenReturn(Collections.emptyList()); presenter.context = mock(DataModelerContext.class); presenter.onCopy(); verify(copyPopUpPresenter, times(1)).show(any(Path.class), any(JavaAssetUpdateValidator.class), any(CommandWithFileNameAndCommitMessage.class)); verify(validationPopup, never()).showCopyValidationMessages(any(Command.class), any(Command.class), anyListOf(ValidationMessage.class)); }
@Test public void onCopyValidationFailedTest() { when(validationService.validateForCopy(any(Path.class), any(DataObject.class))).thenReturn(Arrays.asList(new ValidationMessage())); presenter.context = mock(DataModelerContext.class); presenter.onCopy(); verify(copyPopUpPresenter, never()).show(any(Path.class), any(JavaAssetUpdateValidator.class), any(CommandWithFileNameAndCommitMessage.class)); verify(validationPopup, times(1)).showCopyValidationMessages(any(Command.class), any(Command.class), anyListOf(ValidationMessage.class)); }
@Test public void onCopyWithTargetPathTest() { prepareOnCopyTest(); presenter.onCopy(); verify(copyPopUpPresenter, times(1)).show(pathArgumentCaptor.capture(), validatorArgumentCaptor.capture(), commandWithFileNameArgumentCaptor.capture()); Path targetPath = mock(Path.class); when(copyPopUpPresenterView.getTargetPath()).thenReturn(targetPath); commandWithFileNameArgumentCaptor.getValue().execute(commitMessage); verify(modelerService, times(1)).copy(path, FILE_NAME, null, targetPath, COMMIT_MESSAGE, true); }
@Test public void onCopyWithNoTargetPathTest() { prepareOnCopyTest(); presenter.onCopy(); verify(copyPopUpPresenter, times(1)).show(pathArgumentCaptor.capture(), validatorArgumentCaptor.capture(), commandWithFileNameArgumentCaptor.capture()); when(copyPopUpPresenterView.getTargetPath()).thenReturn(null); commandWithFileNameArgumentCaptor.getValue().execute(commitMessage); verify(modelerService, times(1)).copy(path, FILE_NAME, COMMIT_MESSAGE, true); }