UserEditor implements IsWidget,
                                   org.uberfire.ext.security.management.client.editor.user.UserEditor { void onOnUserRolesUpdatedEvent(@Observes final OnUpdateUserRolesEvent onUpdateUserRolesEvent) { if (checkEventContext(onUpdateUserRolesEvent, userAssignedRolesEditor)) { userAssignedRolesEditor.flush(); final Set<Role> roles = userAssignedRolesEditor.getValue(); userAssignedRolesExplorer.getValue().clear(); userAssignedRolesExplorer.getValue().addAll(roles); userAssignedRolesExplorer.doShow(); } } @Inject  UserEditor(final ClientUserSystemManager userSystemManager,
                      final UserAttributesEditor userAttributesEditor,
                      final UserAssignedGroupsExplorer userAssignedGroupsExplorer,
                      final UserAssignedGroupsEditor userAssignedGroupsEditor,
                      final UserAssignedRolesExplorer userAssignedRolesExplorer,
                      final UserAssignedRolesEditor userAssignedRolesEditor,
                      final ACLViewer aclViewer,
                      final Event<OnEditEvent> onEditEvent,
                      final Event<OnShowEvent> onShowEvent,
                      final Event<OnDeleteEvent> onDeleteEvent,
                      final Event<OnChangePasswordEvent> onChangePasswordEvent,
                      final View view); @PostConstruct void init(); @Override Widget asWidget(); @Override String identifier(); @Override UserAttributesEditor attributesEditor(); @Override UserAssignedGroupsExplorer groupsExplorer(); @Override org.uberfire.ext.security.management.client.editor.user.UserAssignedRolesExplorer rolesExplorer(); UserAssignedGroupsEditor groupsEditor(); UserAssignedRolesEditor rolesEditor(); @Override void show(final User user); @Override void edit(final User user); @Override void flush(); @Override User getValue(); @Override void setViolations(final Set<ConstraintViolation<User>> violations); void clear(); UserEditor setEditButtonVisible(boolean isVisible); UserEditor setDeleteButtonVisible(boolean isVisible); UserEditor setChangePasswordButtonVisible(boolean isVisible); UserEditor setAttributesEditorVisible(boolean isVisible); UserEditor setAddToGroupsButtonVisible(boolean isVisible); UserEditor setPermissionsVisible(boolean isVisible); ACLViewer getACLViewer(); boolean canAssignGroups(); boolean canAssignRoles(); public View view; }
@Test public void testOnOnUserRolesUpdatedEvent() { OnUpdateUserRolesEvent onUpdateUserRolesEvent = mock(OnUpdateUserRolesEvent.class); when(onUpdateUserRolesEvent.getContext()).thenReturn(userAssignedRolesEditor); final Set<Role> explorerRoles = new HashSet<Role>(); when(userAssignedRolesExplorer.getValue()).thenReturn(explorerRoles); final Set<Role> roles = new HashSet<Role>(); roles.add(new RoleImpl("role1")); when(userAssignedRolesEditor.getValue()).thenReturn(roles); presenter.onOnUserRolesUpdatedEvent(onUpdateUserRolesEvent); assertEquals(roles, userAssignedRolesExplorer.getValue()); verify(userAssignedRolesEditor, times(1)).flush(); verify(userAssignedRolesExplorer, times(1)).doShow(); assertNoViewCalls(); }