@Test public void setupWithUpdatableBranchesTest() { final Map<String, RolePermissions> permissionsByRole = new HashMap<>(); permissionsByRole.put("CONTRIBUTOR", new RolePermissions("CONTRIBUTOR", true, false, true, true)); doReturn(new BranchPermissions("myBranch", permissionsByRole)).when(libraryService).loadBranchPermissions("mySpace", "myProject", "myBranch"); doReturn(promises.resolve(Arrays.asList(new Branch("master", mock(Path.class)), new Branch("myBranch", mock(Path.class))))).when(projectController).getUpdatableBranches(any()); presenter.setup(mock(ProjectScreenModel.class)).then(v -> { assertEquals("myBranch", presenter.selectedBranch); verify(view).init(presenter); verify(view, never()).showEmptyState(); verify(view).setupBranchSelect(any(), any(), any()); verify(libraryService).loadBranchPermissions("mySpace", "myProject", "myBranch"); return promises.resolve(); }).catch_(error -> { fail(); return promises.resolve(); }); }
@Override public Promise<Void> setup(final ProjectScreenModel model) { return projectController.getUpdatableBranches(libraryPlaces.getActiveWorkspace()).then(branches -> { view.init(this); if (branches.isEmpty()) { view.showEmptyState(); return promises.resolve(); } selectedBranch = libraryPlaces.getActiveWorkspace().getBranch().getName(); view.setupBranchSelect(branches.stream().map(Branch::getName).sorted(String::compareToIgnoreCase).map(p -> new KieSelectOption(p, p)).collect(toList()), selectedBranch, this::setBranch); return setup(libraryPlaces.getActiveWorkspace().getBranch().getName()); }); }
BranchManagementPresenter extends Section<ProjectScreenModel> { @Override public Promise<Void> setup(final ProjectScreenModel model) { return projectController.getUpdatableBranches(libraryPlaces.getActiveWorkspace()).then(branches -> { view.init(this); if (branches.isEmpty()) { view.showEmptyState(); return promises.resolve(); } selectedBranch = libraryPlaces.getActiveWorkspace().getBranch().getName(); view.setupBranchSelect(branches.stream().map(Branch::getName).sorted(String::compareToIgnoreCase).map(p -> new KieSelectOption(p, p)).collect(toList()), selectedBranch, this::setBranch); return setup(libraryPlaces.getActiveWorkspace().getBranch().getName()); }); } }
BranchManagementPresenter extends Section<ProjectScreenModel> { @Override public Promise<Void> setup(final ProjectScreenModel model) { return projectController.getUpdatableBranches(libraryPlaces.getActiveWorkspace()).then(branches -> { view.init(this); if (branches.isEmpty()) { view.showEmptyState(); return promises.resolve(); } selectedBranch = libraryPlaces.getActiveWorkspace().getBranch().getName(); view.setupBranchSelect(branches.stream().map(Branch::getName).sorted(String::compareToIgnoreCase).map(p -> new KieSelectOption(p, p)).collect(toList()), selectedBranch, this::setBranch); return setup(libraryPlaces.getActiveWorkspace().getBranch().getName()); }); } @Inject  BranchManagementPresenter(final View view,
                                     final Promises promises,
                                     final MenuItem<ProjectScreenModel> menuItem,
                                     final Event<SettingsSectionChange<ProjectScreenModel>> settingsSectionChangeEvent,
                                     final Caller<LibraryService> libraryService,
                                     final LibraryPlaces libraryPlaces,
                                     final RoleAccessListPresenter roleAccessListPresenter,
                                     final ProjectController projectController); }
BranchManagementPresenter extends Section<ProjectScreenModel> { @Override public Promise<Void> setup(final ProjectScreenModel model) { return projectController.getUpdatableBranches(libraryPlaces.getActiveWorkspace()).then(branches -> { view.init(this); if (branches.isEmpty()) { view.showEmptyState(); return promises.resolve(); } selectedBranch = libraryPlaces.getActiveWorkspace().getBranch().getName(); view.setupBranchSelect(branches.stream().map(Branch::getName).sorted(String::compareToIgnoreCase).map(p -> new KieSelectOption(p, p)).collect(toList()), selectedBranch, this::setBranch); return setup(libraryPlaces.getActiveWorkspace().getBranch().getName()); }); } @Inject  BranchManagementPresenter(final View view,
                                     final Promises promises,
                                     final MenuItem<ProjectScreenModel> menuItem,
                                     final Event<SettingsSectionChange<ProjectScreenModel>> settingsSectionChangeEvent,
                                     final Caller<LibraryService> libraryService,
                                     final LibraryPlaces libraryPlaces,
                                     final RoleAccessListPresenter roleAccessListPresenter,
                                     final ProjectController projectController); @Override Promise<Void> setup(final ProjectScreenModel model); @Override Promise<Object> validate(); @Override Promise<Void> save(final String comment,
                              final Supplier<Promise<Void>> chain); @Override int currentHashCode(); @Override SectionView<?> getView(); }
BranchManagementPresenter extends Section<ProjectScreenModel> { @Override public Promise<Void> setup(final ProjectScreenModel model) { return projectController.getUpdatableBranches(libraryPlaces.getActiveWorkspace()).then(branches -> { view.init(this); if (branches.isEmpty()) { view.showEmptyState(); return promises.resolve(); } selectedBranch = libraryPlaces.getActiveWorkspace().getBranch().getName(); view.setupBranchSelect(branches.stream().map(Branch::getName).sorted(String::compareToIgnoreCase).map(p -> new KieSelectOption(p, p)).collect(toList()), selectedBranch, this::setBranch); return setup(libraryPlaces.getActiveWorkspace().getBranch().getName()); }); } @Inject  BranchManagementPresenter(final View view,
                                     final Promises promises,
                                     final MenuItem<ProjectScreenModel> menuItem,
                                     final Event<SettingsSectionChange<ProjectScreenModel>> settingsSectionChangeEvent,
                                     final Caller<LibraryService> libraryService,
                                     final LibraryPlaces libraryPlaces,
                                     final RoleAccessListPresenter roleAccessListPresenter,
                                     final ProjectController projectController); @Override Promise<Void> setup(final ProjectScreenModel model); @Override Promise<Object> validate(); @Override Promise<Void> save(final String comment,
                              final Supplier<Promise<Void>> chain); @Override int currentHashCode(); @Override SectionView<?> getView();  }