UserAttributesEditor implements IsWidget,
                                             org.uberfire.ext.security.management.client.editor.user.UserAttributesEditor { void onAttributeCreated(@Observes final CreateUserAttributeEvent createUserAttributeEvent) { final Entry<String, String> entry = createUserAttributeEvent.getAttribute(); final String name = entry.getKey(); final String value = entry.getValue(); UserManager.UserAttribute attribute = getSupportedAttribute(name); attributes.put(attribute, value); redraw(); } @Inject  UserAttributesEditor(final ClientUserSystemManager userSystemManager,
                                final ConfirmBox confirmBox,
                                final Event<CreateUserAttributeEvent> createUserAttributeEventEvent,
                                final Event<UpdateUserAttributeEvent> updateUserAttributeEventEvent,
                                final Event<DeleteUserAttributeEvent> deleteUserAttributeEventEvent,
                                final Event<OnErrorEvent> errorEvent,
                                final NewUserAttributeEditor newUserAttributeEditor,
                                final View view); @PostConstruct void init(); @Override void show(final User user); @Override void edit(final User user); @Override void flush(); @Override Map<String, String> getValue(); @Override void setViolations(Set<ConstraintViolation<User>> constraintViolations); void clear(); @Override Widget asWidget(); public View view; }
@Test public void testOnAttributeCreated() { UserManager.UserAttribute attr2 = mock(UserManager.UserAttribute.class); when(attr2.getName()).thenReturn("attr2"); when(attr2.getDefaultValue()).thenReturn("v2"); when(attr2.isEditable()).thenReturn(true); when(attr2.isMandatory()).thenReturn(true); when(userSystemManager.getUserSupportedAttribute("attr2")).thenReturn(attr2); CreateUserAttributeEvent createUserAttributeEvent = mock(CreateUserAttributeEvent.class); Map.Entry<String, String> entry = new Map.Entry<String, String>() { @Override public String getKey() { return "attr2"; } @Override public String getValue() { return "value2"; } @Override public String setValue(String value) { return null; } }; when(createUserAttributeEvent.getAttribute()).thenReturn(entry); presenter.attributes = new HashMap<UserManager.UserAttribute, String>(); presenter.onAttributeCreated(createUserAttributeEvent); assertTrue(presenter.attributes.size() == 1); verify(view, times(0)).setCanCreate(anyBoolean()); verify(view, times(1)).redraw(); verify(view, times(1)).getColumnCount(); verify(view, times(1)).setColumnSortHandler(any(ColumnSortEvent.ListHandler.class)); verify(view, times(2)).addColumn(any(Column.class), anyString()); verify(view, times(0)).init(any(UserAttributesEditor.class)); verify(view, times(0)).initWidgets(any(NewUserAttributeEditor.View.class)); verify(view, times(0)).removeColumn(anyInt()); }