UserGroupsExplorer implements IsWidget { public void show(final Set<Group> groups, final boolean canRemove) { clear(); this.canRemove = canRemove; groupList.show(groups, new EntitiesList.Callback<Group>() { @Override public String getEntityType() { return UsersManagementWidgetsConstants.INSTANCE.groupsAssigned(); } @Override public boolean canRead() { return false; } @Override public boolean canRemove() { return UserGroupsExplorer.this.canRemove; } @Override public boolean canSelect() { return false; } @Override public boolean isSelected(final String id) { return groups != null && groups.contains(id); } @Override public String getIdentifier(final Group entity) { return entity.getName(); } @Override public String getTitle(final Group entity) { return entity.getName(); } @Override public void onReadEntity(final String identifier) { } @Override public void onRemoveEntity(final String identifier) { if (identifier != null) { confirmBox.show(UsersManagementWidgetsConstants.INSTANCE.confirmAction(), UsersManagementWidgetsConstants.INSTANCE.ensureRemoveGroupFromUser(), () -> { removeUserGroupEventEvent.fire(new RemoveUserGroupEvent(UserGroupsExplorer.this, identifier)); }, () -> { }); } } @Override public void onSelectEntity(String identifier, boolean isSelected) { } @Override public void onChangePage(int currentPage, int goToPage) { } }); } @Inject  UserGroupsExplorer(GroupsList groupList,
                              View view,
                              ConfirmBox confirmBox,
                              Event<RemoveUserGroupEvent> removeUserGroupEventEvent); @Override Widget asWidget(); @PostConstruct void init(); void show(final Set<Group> groups,
                     final boolean canRemove); void clear();  }
@Test public void show() { final boolean canRemove = false; final Set<Group> groups = new LinkedHashSet<Group>(buildGroupsList(10)); presenter.show(new HashSet<Group>(groups), canRemove); assertFalse(presenter.canRemove); verify(view, times(1)).clear(); final ArgumentCaptor<Set> responseArgumentCaptor = ArgumentCaptor.forClass(Set.class); final ArgumentCaptor<EntitiesList.Callback> callbackArgumentCaptor = ArgumentCaptor.forClass(EntitiesList.Callback.class); verify(groupList, times(1)).show(responseArgumentCaptor.capture(), callbackArgumentCaptor.capture()); final Set<Group> responseArgumentCaptured = responseArgumentCaptor.getValue(); assertEquals(groups, responseArgumentCaptured); final EntitiesList.Callback callbackArgumentCaptured = callbackArgumentCaptor.getValue(); assertEquals(false, callbackArgumentCaptured.canRead()); assertEquals(false, callbackArgumentCaptured.canRemove()); assertEquals(false, callbackArgumentCaptured.canSelect()); int x = 0; for (Group _group : groups) { final String gname = getGroupIdentifier(x); assertEquals(gname, callbackArgumentCaptured.getIdentifier(_group)); assertEquals(gname, callbackArgumentCaptured.getTitle(_group)); assertEquals(false, callbackArgumentCaptured.isSelected(_group.getName())); x++; } }