use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldNotChangeUsersEnabledStateIfNonBooleanOrFirstColumn.
@Test
void shouldNotChangeUsersEnabledStateIfNonBooleanOrFirstColumn() {
// 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(15, 0, 0);
usersTableModel.setValueAt("Some Value", 1, 0);
usersTableModel.setValueAt(true, 1, 1);
// Then
assertThat(listener.getNumberOfEvents(), is(equalTo(0)));
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 shouldModifyElement.
@Test
void shouldModifyElement() {
// Given
TestTableModelListener listener = createTestTableModelListener();
List<User> usersList = new ArrayList<>();
usersList.add(createEnabledUser());
UsersTableModel usersTableModel = new UsersTableModel(usersList);
usersTableModel.addTableModelListener(listener);
User user2 = createUser("User 2");
// When
usersTableModel.modifyElement(0, user2);
// Then
assertThat(usersTableModel.getElements().size(), is(equalTo(1)));
assertThat(usersTableModel.getElements().get(0), is(equalTo(user2)));
assertThat(usersTableModel.getElement(0), is(equalTo(user2)));
assertThat(usersTableModel.getUsers().size(), is(equalTo(1)));
assertThat(usersTableModel.getUsers().get(0), is(equalTo(user2)));
assertThat(listener.getNumberOfEvents(), is(equalTo(1)));
assertThat(listener.isRowUpdated(0), is(equalTo(true)));
}
use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldRemoveAllUsers.
@Test
void shouldRemoveAllUsers() {
// 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.removeAllUsers();
// 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)));
}
use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.
the class UsersTableModelUnitTest method shouldDisableAllUsers.
@Test
void shouldDisableAllUsers() {
// 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(false);
// Then
assertThat(usersTableModel.getValueAt(0, 0), is(equalTo((Object) false)));
assertThat(usersTableModel.getValueAt(1, 0), is(equalTo((Object) false)));
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 shouldFailToGetValueOfNonExistingRow.
@Test
void shouldFailToGetValueOfNonExistingRow() {
// Given
UsersTableModel usersTableModel = new UsersTableModel();
// When / Then
assertThrows(IndexOutOfBoundsException.class, () -> usersTableModel.getValueAt(0, 0));
}
Aggregations