Search in sources :

Example 21 with UsersTableModel

use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.

the class UsersTableModelUnitTest method shouldHaveJustThreeColumns.

@Test
void shouldHaveJustThreeColumns() {
    // Given
    UsersTableModel usersTableModel = new UsersTableModel();
    // When / Then
    assertThat(usersTableModel.getColumnCount(), is(equalTo(3)));
    assertThat(usersTableModel.getColumnName(0), is(notNullValue()));
    assertThat(usersTableModel.getColumnName(1), is(notNullValue()));
    assertThat(usersTableModel.getColumnName(2), is(notNullValue()));
}
Also used : UsersTableModel(org.zaproxy.zap.extension.users.UsersTableModel) Test(org.junit.jupiter.api.Test)

Example 22 with UsersTableModel

use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.

the class UsersTableModelUnitTest method shouldFailToModifyNonExistingElement.

@Test
void shouldFailToModifyNonExistingElement() {
    // Given
    List<User> usersList = new ArrayList<>();
    usersList.add(createEnabledUser());
    UsersTableModel usersTableModel = new UsersTableModel(usersList);
    // When / Then
    assertThrows(IndexOutOfBoundsException.class, () -> usersTableModel.modifyElement(1, createUser()));
}
Also used : ArrayList(java.util.ArrayList) UsersTableModel(org.zaproxy.zap.extension.users.UsersTableModel) Test(org.junit.jupiter.api.Test)

Example 23 with UsersTableModel

use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.

the class UsersTableModelUnitTest method shouldAddTableModelListeners.

@Test
void shouldAddTableModelListeners() {
    // Given
    TableModelListener listener = createTestTableModelListener();
    UsersTableModel usersTableModel = new UsersTableModel();
    // When
    usersTableModel.addTableModelListener(listener);
    // Then
    assertThat(usersTableModel.getTableModelListeners(), is(arrayContaining(listener)));
}
Also used : TableModelListener(javax.swing.event.TableModelListener) UsersTableModel(org.zaproxy.zap.extension.users.UsersTableModel) Test(org.junit.jupiter.api.Test)

Example 24 with UsersTableModel

use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.

the class UsersTableModelUnitTest method shouldFailToGetNonExistingElement.

@Test
void shouldFailToGetNonExistingElement() {
    // Given
    UsersTableModel usersTableModel = new UsersTableModel();
    // When / Then
    assertThrows(IndexOutOfBoundsException.class, () -> usersTableModel.getElement(1));
}
Also used : UsersTableModel(org.zaproxy.zap.extension.users.UsersTableModel) Test(org.junit.jupiter.api.Test)

Example 25 with UsersTableModel

use of org.zaproxy.zap.extension.users.UsersTableModel in project zaproxy by zaproxy.

the class UsersTableModelUnitTest method shouldReturnNullValueAndColumnClassForNonExistingColumns.

@Test
void shouldReturnNullValueAndColumnClassForNonExistingColumns() {
    // Given
    List<User> usersList = new ArrayList<>();
    usersList.add(createUser());
    // When
    UsersTableModel usersTableModel = new UsersTableModel(usersList);
    // Then
    assertThat(usersTableModel.getColumnClass(3), is(equalTo(null)));
    assertThat(usersTableModel.getValueAt(0, 3), is(equalTo(null)));
}
Also used : ArrayList(java.util.ArrayList) UsersTableModel(org.zaproxy.zap.extension.users.UsersTableModel) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)49 UsersTableModel (org.zaproxy.zap.extension.users.UsersTableModel)49 ArrayList (java.util.ArrayList)15 User (org.zaproxy.zap.users.User)8 TableModelListener (javax.swing.event.TableModelListener)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1