@Test public void testSetupWithOneSectionSetupRejection() { final Section<ProjectScreenModel> section1 = newMockedSection(); final Section<ProjectScreenModel> section2 = newMockedSection(); doReturn(new ArrayList<>(Arrays.asList(section1, section2))).when(sectionManager).getSections(); doReturn(promises.reject("Test")).when(presenter).setupSections(any()); presenter.setupUsingCurrentSection(); verify(view).init(eq(presenter)); verify(view).showBusyIndicator(); verify(projectScreenService).load(any()); verify(presenter).setupSections(any()); // All sections are setup regardless of exceptions/rejections verify(notificationEvent).fire(any()); }
@Test public void setupUsingCurrentSection() { final Section<ProjectScreenModel> section = newMockedSection(); doReturn(new ArrayList<>(singletonList(section))).when(sectionManager).getSections(); doReturn(true).when(sectionManager).manages(any()); doReturn(promises.resolve()).when(sectionManager).goToCurrentSection(); doReturn(promises.resolve()).when(presenter).setupSections(any()); doReturn(true).when(libraryPermissions).userCanUpdateProject(any()); presenter.setupUsingCurrentSection(); verify(view).init(eq(presenter)); verify(view).showBusyIndicator(); verify(view, never()).disableActions(); verify(projectScreenService).load(any()); verify(presenter).setupSections(any()); verify(sectionManager).goToCurrentSection(); verify(view).hideBusyIndicator(); verify(sectionManager, never()).goToFirstAvailable(); verify(notificationEvent, never()).fire(any()); }
@Test public void setupUsingCurrentSectionWithoutPermission() { final Section<ProjectScreenModel> section = newMockedSection(); doReturn(new ArrayList<>(singletonList(section))).when(sectionManager).getSections(); doReturn(true).when(sectionManager).manages(any()); doReturn(promises.resolve()).when(sectionManager).goToCurrentSection(); doReturn(promises.resolve()).when(presenter).setupSections(any()); doReturn(false).when(libraryPermissions).userCanUpdateProject(any()); presenter.setupUsingCurrentSection(); verify(view).init(eq(presenter)); verify(view).showBusyIndicator(); verify(view).disableActions(); verify(projectScreenService).load(any()); verify(presenter).setupSections(any()); verify(sectionManager).goToCurrentSection(); verify(view).hideBusyIndicator(); verify(sectionManager, never()).goToFirstAvailable(); verify(notificationEvent, never()).fire(any()); }
@Test public void setupUsingCurrentSectionWithRemovalDueToErrors() { final Section<ProjectScreenModel> section = newMockedSection(); doReturn(new ArrayList<>(singletonList(section))).when(sectionManager).getSections(); doReturn(false).when(sectionManager).manages(eq(section)); doReturn(promises.resolve()).when(sectionManager).goToFirstAvailable(); doReturn(promises.resolve()).when(presenter).setupSections(any()); presenter.setupUsingCurrentSection(); verify(view).init(eq(presenter)); verify(view).showBusyIndicator(); verify(projectScreenService).load(any()); verify(presenter).setupSections(any()); verify(sectionManager).goToFirstAvailable(); verify(view).hideBusyIndicator(); verify(sectionManager, never()).goToCurrentSection(); verify(notificationEvent, never()).fire(any()); }
protected WorkspaceProject renameIfNecessary(final OrganizationalUnit ou, final WorkspaceProject project) { String name = project.getName(); Collection<WorkspaceProject> projectsWithSameName = projectService.getAllWorkspaceProjectsByName(ou, name); if (projectsWithSameName.size() > 1) { name = this.projectService.createFreshProjectName(ou, project.getName()); } if (!name.equals(project.getName())) { final Path pomXMLPath = project.getMainModule().getPomXMLPath(); final ProjectScreenModel model = projectScreenService.load(pomXMLPath); model.getPOM().setName(name); projectScreenService.save(pomXMLPath, model, ""); return projectService.resolveProject(pomXMLPath); } return project; }
doReturn(model).when(projectScreenService).load(any());
doReturn(model).when(projectScreenService).load(any());
@Test public void testLoad() throws Exception { final ProjectScreenModel model = service.load(pathToPom);
return s.load(pathToPom); }).then(model -> { this.model = model;