ManageSelectorImpl implements ManageSelector { @PostConstruct public void init() { view.removeAllOptions(); String currentPerspectiveId = perspectiveManager.getCurrentPerspective().getIdentifier(); availablePerspectives.keySet().forEach(perspectiveId -> addPerspective(perspectiveId, availablePerspectives.get(perspectiveId), perspectiveId.equals(currentPerspectiveId))); view.setOptionChangeCommand(() -> goToPerspective(view.getSelectedOption())); view.refresh(); }  @PostConstruct void init(); void goToPerspective(String perspectiveId); IsWidget getManageSelectorWidget();  }
@Test public void testInitManageSelector_AllPerspectivesGranted() { when(authorizationManager.authorize(any(ResourceRef.class), eq(identity))).thenReturn(true); manageSelector.init(); verify(view).removeAllOptions(); verifyInitSelectorBasicViewInteractions(); verify(view).addOption(Constants.INSTANCE.Process_Definitions(), PerspectiveIds.PROCESS_DEFINITIONS, true); verify(view).addOption(Constants.INSTANCE.Process_Instances(), PerspectiveIds.PROCESS_INSTANCES, false); verify(view).addOption(Constants.INSTANCE.Tasks(), PerspectiveIds.TASKS_ADMIN, false); verify(view).addOption(Constants.INSTANCE.ExecutionErrors(), PerspectiveIds.EXECUTION_ERRORS, false); verify(view).addOption(Constants.INSTANCE.Jobs(), PerspectiveIds.JOBS, false); verifyNoMoreInteractions(view); }
@Test public void testInitManageSelector_NotAllPerspectivesGranted() { when(authorizationManager.authorize(any(ResourceRef.class), eq(identity))).thenReturn(true, true, false, false, false); manageSelector.init(); verify(view).removeAllOptions(); verifyInitSelectorBasicViewInteractions(); verify(view, times(2)).addOption(anyString(), anyString(), anyBoolean()); verifyNoMoreInteractions(view); }