@Test public void testDuplicateCommand() { doNothing().when(projectScreenService).copy(any(), any()); final CopyPopUpView copyPopUpView = mock(CopyPopUpView.class); doReturn(copyPopUpView).when(copyPopUpPresenter).getView(); this.presenter.getDuplicateCommand().execute(new FileNameAndCommitMessage("newFileName", "commitMessage")); verify(copyPopUpView).hide(); verify(view).showBusyIndicator(anyString()); verify(projectScreenService).copy(presenter.workspaceProject, "newFileName"); verify(view).hideBusyIndicator(); verify(notificationEvent).fire(any()); verify(promises).resolve(); }
@Test public void testCopyNoPOM() throws Exception { final WorkspaceProject project = mock(WorkspaceProject.class); final OrganizationalUnit ou = mock(OrganizationalUnit.class); final Path projectRoot = mock(Path.class); doReturn(ou).when(project).getOrganizationalUnit(); doReturn(projectRoot).when(project).getRootPath(); final Repository newRepository = mock(Repository.class); final Path newRepositoryRoot = PathFactory.newPath("root", "file:///root"); doReturn(Optional.of(new Branch("master", newRepositoryRoot))).when(newRepository).getDefaultBranch(); doReturn(newRepository).when(repositoryCopier).copy(ou, "newName", projectRoot); doReturn(null).when(pomService).load(any(Path.class)); service.copy(project, "newName"); verify(repositoryCopier).copy(ou, "newName", projectRoot); verify(metadataService, never()).getMetadata(any(Path.class)); verify(pomService, never()).save(any(Path.class), any(POM.class), any(Metadata.class), anyString(), anyBoolean()); }
doReturn(metadata).when(metadataService).getMetadata(any(Path.class)); service.copy(project, "newName");
CommandWithFileNameAndCommitMessage getDuplicateCommand() { return details -> { copyPopUpPresenter.getView().hide(); view.showBusyIndicator(view.getLoadingMessage()); promises.promisify(projectScreenService, s -> { s.copy(workspaceProject, details.getNewFileName()); }).then(i -> { view.hideBusyIndicator(); notificationEvent.fire(new NotificationEvent(view.getItemSuccessfullyDuplicatedMessage(), NotificationEvent.NotificationType.SUCCESS)); return promises.resolve(); }).catch_(this::onError); }; }