Class TableAssert<R,​C,​V>

    • Constructor Detail

      • TableAssert

        protected TableAssert​(com.google.common.collect.Table<R,​C,​V> actual)
    • Method Detail

      • hasRowCount

        public TableAssert<R,​C,​V> hasRowCount​(int expectedSize)
        Verifies that the actual Table has the expected number of rows.

        Example :

         Table <Integer, Integer, String> actual = HashBasedTable.create();
        
         actual.put(1, 3, "Millard Fillmore");
         actual.put(1, 4, "Franklin Pierce");
         actual.put(2, 5, "Grover Cleveland");
        
         assertThat(actual).hasRowCount(2);
        Parameters:
        expectedSize - The columns to look for in the actual Table
        Returns:
        this TableAssert for assertion chaining.
        Throws:
        java.lang.IllegalArgumentException - if the expected size is negative
        java.lang.AssertionError - if the actual Table is null.
        java.lang.AssertionError - if the actual Table does not have the expected row size.
      • hasColumnCount

        public TableAssert<R,​C,​V> hasColumnCount​(int expectedSize)
        Verifies that the actual Table has the expected number of columns.

        Example :

         Table<Integer, Integer, String> actual = HashBasedTable.create();
        
         actual.put(1, 3, "Millard Fillmore");
         actual.put(1, 4, "Franklin Pierce");
         actual.put(2, 5, "Grover Cleveland");
        
         assertThat(actual).hasColumnCount(3);
        Parameters:
        expectedSize - The columns to look for in the actual Table
        Returns:
        this TableAssert for assertion chaining.
        Throws:
        java.lang.IllegalArgumentException - if the expected size is negative
        java.lang.AssertionError - if the actual Table is null.
        java.lang.AssertionError - if the actual Table does not have the expected column size.
      • hasSize

        public TableAssert<R,​C,​V> hasSize​(int expectedSize)
        Verifies that the actual Table has the expected number of cells.

        Example :

         Table<Integer, Integer, String> actual = HashBasedTable.create();
        
         actual.put(1, 3, "Millard Fillmore");
         actual.put(1, 4, "Franklin Pierce");
         actual.put(2, 5, "Grover Cleveland");
        
         assertThat(actual).hasSize(3);
        Parameters:
        expectedSize - The columns to look for in the actual Table
        Returns:
        this TableAssert for assertion chaining.
        Throws:
        java.lang.IllegalArgumentException - if the expected size is negative
        java.lang.AssertionError - if the actual Table is null.
        java.lang.AssertionError - if the actual Table does not have the expected number of cells.
      • containsRows

        public TableAssert<R,​C,​V> containsRows​(R... rows)
        Verifies that the actual Table contains the given rows.

        Example :

         Table<Integer, Integer, String> actual = HashBasedTable.create();
        
         actual.put(1, 3, "Millard Fillmore");
         actual.put(1, 4, "Franklin Pierce");
         actual.put(2, 5, "Grover Cleveland");
        
         assertThat(actual).containsRows(1, 2);
        Parameters:
        rows - The columns to look for in the actual Table
        Returns:
        this TableAssert for assertion chaining.
        Throws:
        java.lang.IllegalArgumentException - if no param rows have been set.
        java.lang.AssertionError - if the actual Table is null.
        java.lang.AssertionError - if the actual Table does not contain the given rows.
      • containsColumns

        public TableAssert<R,​C,​V> containsColumns​(C... columns)
        Verifies that the actual Table contains the given columns.

        Example :

         Table<Integer, Integer, String> actual = HashBasedTable.create();
        
         actual.put(1, 3, "Millard Fillmore");
         actual.put(1, 4, "Franklin Pierce");
         actual.put(2, 5, "Grover Cleveland");
        
         assertThat(actual).containsColumns(3, 4);
        Parameters:
        columns - The columns to look for in the actual Table
        Returns:
        this TableAssert for assertion chaining.
        Throws:
        java.lang.IllegalArgumentException - if no param columns have been set.
        java.lang.AssertionError - if the actual Table is null.
        java.lang.AssertionError - if the actual Table does not contain the given columns.
      • containsValues

        public TableAssert<R,​C,​V> containsValues​(V... values)
        Verifies that the actual Table contains the given values for any key.

        Example :

         Table<Integer, Integer, String> actual = HashBasedTable.create();
        
         actual.put(1, 3, "Millard Fillmore");
         actual.put(1, 4, "Franklin Pierce");
         actual.put(2, 5, "Grover Cleveland");
        
         assertThat(actual).containsValues("Franklin Pierce", "Millard Fillmore");
        Parameters:
        values - The values to look for in the actual Table
        Returns:
        this TableAssert for assertion chaining.
        Throws:
        java.lang.IllegalArgumentException - if no param values have been set.
        java.lang.AssertionError - if the actual Table is null.
        java.lang.AssertionError - if the actual Table does not contain the given values.
      • containsCell

        public TableAssert<R,​C,​V> containsCell​(R row,
                                                           C column,
                                                           V expectedValue)
        Verifies that the actual Table contains the mapping of row/column to value.

        Example :

         Table<Integer, Integer, String> actual = HashBasedTable.create();
        
         actual.put(1, 3, "Millard Fillmore");
         actual.put(1, 4, "Franklin Pierce");
         actual.put(2, 5, "Grover Cleveland");
        
         assertThat(actual).containsCell(1, 3, "Millard Fillmore");
        Parameters:
        row - The row key to lookup in the actual Table
        column - The column key to lookup in the actual Table
        expectedValue - The value to look for in the actual Table
        Returns:
        this TableAssert for assertion chaining.
        Throws:
        java.lang.AssertionError - if the actual Table is null.
        java.lang.AssertionError - if the row key is null.
        java.lang.AssertionError - if the column key is null.
        java.lang.AssertionError - if the expected value is null.
      • isEmpty

        public void isEmpty()
        Verifies that the actual Table is empty.

        Example :

         Table<Integer, Integer, String> actual = HashBasedTable.create();
        
         assertThat(actual).isEmpty();
        Throws:
        java.lang.AssertionError - if the actual Table is null.
        java.lang.AssertionError - if the actual Table is not empty.
      • checkExpectedSizeArgument

        private void checkExpectedSizeArgument​(int expectedSize)