SecurityExplorerScreen { @OnStartup public void onStartup(final PlaceRequest placeRequest) { final String activeTab = placeRequest.getParameter(ACTIVE_TAB, ROLES_TAB); userSystemManager.waitForInitialization(() -> { if (userSystemManager.isActive()) { groupsExplorer.show(); usersExplorer.show(); view.groupsEnabled(true); view.usersEnabled(true); if (activeTab.equals(USERS_TAB)) { view.rolesActive(false); view.groupsActive(false); view.usersActive(true); } else if (activeTab.equals(GROUPS_TAB)) { view.rolesActive(false); view.groupsActive(true); view.usersActive(false); } } }); } @Inject  SecurityExplorerScreen(final View view,
                                  final RolesExplorer rolesExplorer,
                                  final GroupsExplorer groupsExplorer,
                                  final UsersExplorer usersExplorer,
                                  final ErrorPopupPresenter errorPopupPresenter,
                                  final PlaceManager placeManager,
                                  final ClientUserSystemManager userSystemManager,
                                  final ClientSecurityExceptionMessageResolver exceptionMessageResolver); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getWidget(); @PostConstruct void init(); @OnStartup void onStartup(final PlaceRequest placeRequest); @OnClose void onClose(); static final String SCREEN_ID; static final String ACTIVE_TAB; static final String ROLES_TAB; static final String GROUPS_TAB; static final String USERS_TAB; }
@Test public void testOnStartupUsersTab() { final PlaceRequest placeRequest = mock(PlaceRequest.class); when(placeRequest.getParameter(eq(SecurityExplorerScreen.ACTIVE_TAB), anyString())).thenReturn(SecurityExplorerScreen.USERS_TAB); tested.onStartup(placeRequest); verify(usersExplorer, times(1)).show(); verify(groupsExplorer, times(1)).show(); verify(view, times(1)).groupsEnabled(eq(true)); verify(view, times(1)).usersEnabled(eq(true)); verify(view, times(1)).rolesActive(eq(false)); verify(view, times(1)).groupsActive(eq(false)); verify(view, times(1)).usersActive(eq(true)); }
@Test public void testOnStartupGroupsTab() { final PlaceRequest placeRequest = mock(PlaceRequest.class); when(placeRequest.getParameter(eq(SecurityExplorerScreen.ACTIVE_TAB), anyString())).thenReturn(SecurityExplorerScreen.GROUPS_TAB); tested.onStartup(placeRequest); verify(usersExplorer, times(1)).show(); verify(groupsExplorer, times(1)).show(); verify(view, times(1)).groupsEnabled(eq(true)); verify(view, times(1)).usersEnabled(eq(true)); verify(view, times(1)).rolesActive(eq(false)); verify(view, times(1)).usersActive(eq(false)); verify(view, times(1)).groupsActive(eq(true)); }