@Test public void testOnStartupNoRepositoryNoProject() throws Exception { when(workbenchContext.getActiveOrganizationalUnit()).thenReturn(organizationalUnit); final PlaceRequest placeRequest = mock(PlaceRequest.class); presenter.onStartup(placeRequest); verify(view, times(1)).setModulesViewVisible(eq(false)); verify(view, times(1)).clearDataView(); verify(modulesView, times(1)).enableActions(eq(true)); }
private void doRepositoryStructureInitialization(final DeploymentMode mode) { view.showBusyIndicator(Constants.INSTANCE.CreatingRepositoryStructure()); repositoryStructureService.call(new RemoteCallback<Path>() { }).initRepositoryStructure(view.getDataPresenterGav(), projectContext.getActiveRepository(), mode);
private boolean updateView() { if (model == null) { this.model = new RepositoryStructureModel(); view.setDataPresenterMode(RepositoryStructureDataView.ViewMode.CREATE_STRUCTURE); view.getModulesView().setMode(ProjectModulesView.ViewMode.MODULES_VIEW); initDataPresenter(); view.setModulesViewVisible(false); view.setDataPresenterMode(RepositoryStructureDataView.ViewMode.EDIT_MULTI_MODULE_PROJECT); view.getModulesView().setMode(ProjectModulesView.ViewMode.MODULES_VIEW); initDataPresenter(); view.setModulesViewVisible(true); view.setDataPresenterMode(RepositoryStructureDataView.ViewMode.EDIT_SINGLE_MODULE_PROJECT); view.getModulesView().setMode(ProjectModulesView.ViewMode.PROJECTS_VIEW); initDataPresenter(); view.setModulesViewVisible(false); view.setDataPresenterMode(RepositoryStructureDataView.ViewMode.EDIT_UNMANAGED_REPOSITORY); view.getModulesView().setMode(ProjectModulesView.ViewMode.PROJECTS_VIEW); view.setModulesViewVisible(true);
@Inject public RepositoryStructurePresenter(final RepositoryStructureView view, final Caller<POMService> pomService, final Caller<RepositoryStructureService> repositoryStructureService, final RepositoryStructureTitle repositoryStructureTitle, final Event<ProjectContextChangeEvent> contextChangeEvent, final ConflictingRepositoriesPopup conflictingRepositoriesPopup, final RepositoryStructureMenu menus, final PlaceManager placeManager, final ProjectContext projectContext, final ProjectWizard wizard, final RepositoryManagedStatusUpdater repositoryManagedStatusUpdater) { this.view = view; this.pomService = pomService; this.repositoryStructureService = repositoryStructureService; this.repositoryStructureTitle = repositoryStructureTitle; this.contextChangeEvent = contextChangeEvent; this.conflictingRepositoriesPopup = conflictingRepositoriesPopup; this.menus = menus; this.placeManager = placeManager; this.projectContext = projectContext; this.wizard = wizard; this.repositoryManagedStatusUpdater = repositoryManagedStatusUpdater; this.repositoryManagedStatusUpdater.bind(view, history, this); projectContext.addChangeHandler(this); view.setPresenter(this); view.getModulesView().setPresenter(this); }
times(1)).clearDataView(); verify(modulesView, times(1)).enableActions(eq(true)); verify(view, times(1)).showBusyIndicator(Constants.INSTANCE.Loading()); verify(view, times(1)).hideBusyIndicator(); times(1)).setDataPresenterMode(eq(RepositoryStructureDataView.ViewMode.EDIT_MULTI_MODULE_PROJECT)); verify(modulesView, times(1)).setMode(eq(ProjectModulesView.ViewMode.MODULES_VIEW)); verify(view, times(1)).setDataPresenterModel(eq(pom.getGav())); verify(view, times(1)).setModulesViewVisible(eq(true));
@Test public void testOnStartupWithRepositoryWithProjectNoModel() throws Exception { when(workbenchContext.getActiveOrganizationalUnit()).thenReturn(organizationalUnit); when(workbenchContext.getActiveRepository()).thenReturn(repository); when(workbenchContext.getActiveProject()).thenReturn(project); final RepositoryStructureModel model = null; when(repositoryStructureService.load(eq(repository), anyString())).thenReturn(model); final PlaceRequest placeRequest = mock(PlaceRequest.class); presenter.onStartup(placeRequest); verify(view, times(1)).setModulesViewVisible(eq(false)); verify(view, times(1)).clearDataView(); verify(modulesView, times(1)).enableActions(eq(true)); verify(view, times(1)).showBusyIndicator(Constants.INSTANCE.Loading()); verify(view, times(1)).hideBusyIndicator(); }
@Test public void testOnInitRepositoryStructureNonClashingGAV() { when(workbenchContext.getActiveOrganizationalUnit()).thenReturn(organizationalUnit); when(workbenchContext.getActiveRepository()).thenReturn(repository); when(workbenchContext.getActiveProject()).thenReturn(project); final RepositoryStructureModel model = new RepositoryStructureModel(); final POM pom = new POM(new GAV("groupId", "artifactId", "version")); model.setManaged(true); model.setPOM(pom); when(repositoryStructureService.load(eq(repository), anyString())).thenReturn(model); final PlaceRequest placeRequest = mock(PlaceRequest.class); presenter.onStartup(placeRequest); presenter.onInitRepositoryStructure(); verify(view, times(2)).showBusyIndicator(eq(Constants.INSTANCE.Loading())); verify(view, times(1)).showBusyIndicator(eq(Constants.INSTANCE.CreatingRepositoryStructure())); verify(view, times(3)).hideBusyIndicator(); }
@Override public void loadModel(final Repository repository, final String branch) { view.showBusyIndicator(Constants.INSTANCE.Loading()); clearView(); repositoryStructureService.call(getLoadModelSuccessCallback(), new HasBusyIndicatorDefaultErrorCallback(view)).load(repository, branch); }
@Override public void callback(final RepositoryStructureModel model) { view.hideBusyIndicator(); setModel(model); } };
private POM makeMultiModulePom() { final POM pom = new POM(); final GAV parentGAV = view.getDataPresenterGav(); pom.setParent(parentGAV); pom.getGav().setGroupId(parentGAV.getGroupId()); pom.getGav().setVersion(parentGAV.getVersion()); return pom; }
private void enableActions(final boolean value) { view.getModulesView().enableActions(value); }
@Override public void clearView() { view.clearDataView(); dataProvider.getList().clear(); enableActions(true); }
private void initDataPresenter() { if (model == null) { return; } if (model.getPathToPOM() != null) { view.setDataPresenterModel(model.getPOM().getGav()); } else if (model.isSingleProject()) { final Project project = model.getOrphanProjects().get(0); final POM pom = model.getOrphanProjectsPOM().get(project.getIdentifier()); if (pom != null) { if (pom.getGav() != null) { view.setDataPresenterModel(pom.getGav()); } } } }
private void processContextChange() { if (projectContext.getActiveRepository() == null) { clearView(); view.setModulesViewVisible(false); enableActions(false); } else { final boolean repoOrBranchChanged = repositoryStructureContext.repositoryOrBranchChanged(projectContext.getActiveRepository(), projectContext.getActiveBranch()); if (repoOrBranchChanged || repositoryStructureContext.activeProjectChanged(projectContext.getActiveProject())) { if (repoOrBranchChanged || history.alreadyUpToDate(projectContext.getActiveProject())) { loadModel(projectContext.getActiveRepository(), projectContext.getActiveBranch()); } history.reset(); repositoryStructureContext.reset(projectContext.getActiveRepository(), projectContext.getActiveBranch(), projectContext.getActiveProject()); } } }
@WorkbenchPartView public IsWidget asWidget() { return view.asWidget(); }
times(1)).clearDataView(); verify(modulesView, times(1)).enableActions(eq(true)); verify(view, times(1)).showBusyIndicator(Constants.INSTANCE.Loading()); verify(view, times(1)).hideBusyIndicator(); times(1)).setDataPresenterMode(eq(RepositoryStructureDataView.ViewMode.EDIT_SINGLE_MODULE_PROJECT)); verify(modulesView, times(1)).setMode(eq(ProjectModulesView.ViewMode.PROJECTS_VIEW)); verify(view, times(1)).setDataPresenterModel(any(GAV.class)); verify(view, times(1)).setModulesViewVisible(eq(false));
times(1)).showBusyIndicator(eq(Constants.INSTANCE.Loading())); verify(view, times(1)).showBusyIndicator(eq(Constants.INSTANCE.CreatingRepositoryStructure())); verify(view, times(1)).hideBusyIndicator();
private void deleteSelectedModule(final Project project) { view.showBusyIndicator(Constants.INSTANCE.Deleting()); history.setLastDeletedModule(project); repositoryStructureService.call(getModuleDeletedSuccessCallback(project), new HasBusyIndicatorDefaultErrorCallback(view)).delete(project.getPomXMLPath(), "Module removed"); }
@Override public void callback(final Path response) { view.hideBusyIndicator(); loadModel(projectContext.getActiveRepository(), projectContext.getActiveBranch()); } },
anyString())).thenReturn(model); when(view.getDataPresenterGav()).thenReturn(new GAV("groupId", "artifactId", "version"));