use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldRemoveTableModelListeners.
@Test
void shouldRemoveTableModelListeners() {
// Given
TableModelListener listener = createTestTableModelListener();
UsersTableModel usersTableModel = new UsersTableModel();
usersTableModel.addTableModelListener(listener);
// When
usersTableModel.removeTableModelListener(listener);
// Then
assertThat(usersTableModel.getTableModelListeners(), is(emptyArray()));
}
use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldReturnUserEnabledStateFromFirstColumn.
@Test
void shouldReturnUserEnabledStateFromFirstColumn() {
// Given
List<User> usersList = new ArrayList<>();
usersList.add(createUser());
usersList.add(createEnabledUser());
// When
UsersTableModel usersTableModel = new UsersTableModel(usersList);
// Then
assertTrue(usersTableModel.getColumnClass(0) == Boolean.class);
assertThat(usersTableModel.getValueAt(0, 0), is(equalTo((Object) false)));
assertThat(usersTableModel.getValueAt(1, 0), is(equalTo((Object) true)));
}
use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldEnableAllUsers.
@Test
void shouldEnableAllUsers() {
// Given
TestTableModelListener listener = createTestTableModelListener();
List<User> usersList = new ArrayList<>();
usersList.add(createUser());
usersList.add(createEnabledUser());
UsersTableModel usersTableModel = new UsersTableModel(usersList);
usersTableModel.addTableModelListener(listener);
// When
usersTableModel.setAllEnabled(true);
// Then
assertThat(usersTableModel.getValueAt(0, 0), is(equalTo((Object) true)));
assertThat(usersTableModel.getValueAt(1, 0), is(equalTo((Object) true)));
assertThat(listener.getNumberOfEvents(), is(equalTo(1)));
assertThat(listener.isCellChanged(0, 0), is(equalTo(true)));
assertThat(listener.isCellChanged(1, 0), is(equalTo(true)));
}
use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldSetUsers.
@Test
void shouldSetUsers() {
// Given
TestTableModelListener listener = createTestTableModelListener();
UsersTableModel usersTableModel = new UsersTableModel();
usersTableModel.addTableModelListener(listener);
List<User> usersList = new ArrayList<>();
User user = createUser();
usersList.add(user);
// When
usersTableModel.setUsers(usersList);
// Then
assertThat(usersTableModel.getRowCount(), is(equalTo(1)));
assertThat(usersTableModel.getElements().size(), is(equalTo(1)));
assertThat(usersTableModel.getElements().get(0), is(equalTo(user)));
assertThat(usersTableModel.getElement(0), is(equalTo(user)));
assertThat(usersTableModel.getUsers().size(), is(equalTo(1)));
assertThat(usersTableModel.getUsers().get(0), is(equalTo(user)));
assertThat(listener.getNumberOfEvents(), is(equalTo(1)));
assertThat(listener.isDataChanged(), is(equalTo(true)));
}
use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldBeEditableJustTheFirstColumnEvenIfHasNoUsers.
@Test
void shouldBeEditableJustTheFirstColumnEvenIfHasNoUsers() {
// Given
UsersTableModel usersTableModel = new UsersTableModel();
// When / Then
assertThat(usersTableModel.isCellEditable(0, 0), is(equalTo(true)));
assertThat(usersTableModel.isCellEditable(0, 1), is(equalTo(false)));
}
Aggregations