use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersListModelUnitTest method shouldReflectChangesToTableUsersAndSelectFirstTableUserIfNoneSelected.
@Test
void shouldReflectChangesToTableUsersAndSelectFirstTableUserIfNoneSelected() {
// Given
UsersTableModel tableModel = createUsersTableModel(2);
UsersListModel usersListModel = new UsersListModel(tableModel);
TestListDataListener listener = createTestListDataListener();
usersListModel.addListDataListener(listener);
User user = createUser();
// When
tableModel.modifyElement(1, user);
// Then
assertThat(usersListModel.getElementAt(1), is(equalTo((Object) user)));
assertThat(usersListModel.getSelectedItem(), is(equalTo((Object) tableModel.getUsers().get(0))));
assertThat(listener.getNumberOfEvents(), is(equalTo(2)));
assertThat(listener.isListItemChanged(1), is(equalTo(true)));
assertThat(listener.isListItemChanged(-1), is(equalTo(true)));
}
use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersListModelUnitTest method shouldRemoveSelectionWithSelectedItem.
@Test
void shouldRemoveSelectionWithSelectedItem() {
// Given
UsersTableModel tableModel = createUsersTableModel(2);
UsersListModel usersListModel = new UsersListModel(tableModel);
usersListModel.setSelectedItem(tableModel.getUsers().get(1));
TestListDataListener listener = createTestListDataListener();
usersListModel.addListDataListener(listener);
// When
usersListModel.setSelectedItem(null);
// Then
assertThat(usersListModel.getSelectedItem(), is(nullValue()));
assertThat(listener.getNumberOfEvents(), is(equalTo(1)));
assertThat(listener.isListItemChanged(-1), is(equalTo(true)));
}
use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldAddUser.
@Test
void shouldAddUser() {
// Given
TestTableModelListener listener = createTestTableModelListener();
UsersTableModel usersTableModel = new UsersTableModel();
usersTableModel.addTableModelListener(listener);
User user = createUser();
// When
usersTableModel.addUser(user);
// Then
assertThat(usersTableModel.getRowCount(), is(equalTo(1)));
assertThat(usersTableModel.getUsers().size(), is(equalTo(1)));
assertThat(usersTableModel.getUsers().get(0), is(equalTo(user)));
assertThat(listener.getNumberOfEvents(), is(equalTo(1)));
assertThat(listener.isRowInserted(0), is(equalTo(true)));
}
use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldNotHaveUsersByDefault.
@Test
void shouldNotHaveUsersByDefault() {
// Given
UsersTableModel usersTableModel = new UsersTableModel();
// When / Then
assertThat(usersTableModel.getRowCount(), is(equalTo(0)));
assertThat(usersTableModel.getUsers(), is(empty()));
assertThat(usersTableModel.getElements(), is(empty()));
}
Aggregations