use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldChangeUsersEnabledState.
@Test
void shouldChangeUsersEnabledState() {
// 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.setValueAt(true, 0, 0);
usersTableModel.setValueAt(false, 1, 0);
// Then
assertThat(usersTableModel.getValueAt(0, 0), is(equalTo((Object) true)));
assertThat(usersTableModel.getValueAt(1, 0), is(equalTo((Object) false)));
assertThat(listener.getNumberOfEvents(), is(equalTo(2)));
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 shouldNotNotifyOfEnabledStateChangesIfItHasNoUsers.
@Test
void shouldNotNotifyOfEnabledStateChangesIfItHasNoUsers() {
// Given
TestTableModelListener listener = createTestTableModelListener();
UsersTableModel usersTableModel = new UsersTableModel();
usersTableModel.addTableModelListener(listener);
// When
usersTableModel.setAllEnabled(true);
// Then
assertThat(listener.getNumberOfEvents(), is(equalTo(0)));
}
use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldReturnUserNameFromThirdColumn.
@Test
void shouldReturnUserNameFromThirdColumn() {
// Given
List<User> usersList = new ArrayList<>();
usersList.add(createUser("User 1"));
usersList.add(createUser("User 2"));
// When
UsersTableModel usersTableModel = new UsersTableModel(usersList);
// Then
assertTrue(usersTableModel.getColumnClass(2) == String.class);
assertThat(usersTableModel.getValueAt(0, 2), is(equalTo((Object) "User 1")));
assertThat(usersTableModel.getValueAt(1, 2), is(equalTo((Object) "User 2")));
}
use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldFailToCreateInstanceWithUndefinedUsersList.
@Test
void shouldFailToCreateInstanceWithUndefinedUsersList() {
// Given
List<User> undefinedUsersList = null;
// When / Then
assertThrows(NullPointerException.class, () -> new UsersTableModel(undefinedUsersList));
}
use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldClearElements.
@Test
void shouldClearElements() {
// 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.clear();
// Then
assertThat(usersTableModel.getRowCount(), is(equalTo(0)));
assertThat(usersTableModel.getElements(), is(empty()));
assertThat(usersTableModel.getUsers(), is(empty()));
assertThat(listener.getNumberOfEvents(), is(equalTo(1)));
assertThat(listener.isDataChanged(), is(equalTo(true)));
}
Aggregations