DataFrameAsserts { public DataFrameAsserts expectRow(int pos, Object... expectedValues) { assertTrue(pos < df.height(), () -> "Row position " + pos + " is outside the DataFrame range of 0.." + (df.height() - 1)); Object[] expectedNormal = expectedValues != null ? expectedValues : new Object[]{null}; for (int i = 0; i < expectedColumns.length; i++) { String column = expectedColumns[i]; Object expected = expectedNormal[i]; Object actual = df.getColumn(i).get(pos); if (expected == null) { assertNull(actual, "Unexpected value in '" + column + "'"); } else if (expected.getClass().isArray()) { assertTrue(actual.getClass().isArray(), "Was expecting array in '" + column + "'"); expectArrayRow(column, expected, actual); } else { assertEquals(expected, actual, "Unexpected value in '" + column + "'"); } } return this; } DataFrameAsserts(DataFrame df, Index expectedColumns);  DataFrameAsserts(DataFrame df, List<String> expectedColumns);  DataFrameAsserts(DataFrame df, String... expectedColumns); DataFrameAsserts expectHeight(int expectedHeight); DataFrameAsserts expectIntColumns(int... positions); DataFrameAsserts expectIntColumns(String... labels); DataFrameAsserts expectLongColumns(int... positions); DataFrameAsserts expectLongColumns(String... labels); DataFrameAsserts expectDoubleColumns(int... positions); DataFrameAsserts expectDoubleColumns(String... labels); DataFrameAsserts expectBooleanColumns(int... positions); DataFrameAsserts expectBooleanColumns(String... labels); DataFrameAsserts expectColumn(int pos, Object... expectedValues); DataFrameAsserts expectColumn(String column, Object... expectedValues); DataFrameAsserts expectRow(int pos, Object... expectedValues); @SafeVarargs final DataFrameAsserts assertRow(int pos, Consumer<?>... valueAsserts);  }
@Test public void testExpectRows_ArryaTypeMismatch() { DataFrame df = DataFrame.newFrame("a").foldByRow(new int[]{3, 4, 5}); DataFrameAsserts asserts = new DataFrameAsserts(df, "a"); assertThrows(AssertionError.class, () -> asserts.expectRow(0, new Object[]{new long[]{3, 4, 5}})); }
@Test public void testExpectRows_Mismatch() { DataFrame df = DataFrame.newFrame("a").foldByRow("a", "b"); try { new DataFrameAsserts(df, "a") .expectRow(0, "a") .expectRow(1, "c"); throw new RuntimeException("Must have failed comparision"); } catch (AssertionFailedError f) { assertEquals("c", f.getExpected().getValue()); assertEquals("b", f.getActual().getValue()); } }