/** This method tests the {@code hasValues} assertion method. */ @Test @NeedReload public void test_has_values() { Table table = new Table(source, "actor"); Changes changes = new Changes(table).setStartPointNow(); updateChangesForTests(); changes.setEndPointNow(); ChangeRowAssert changeRowAssert = assertThat(changes).change().rowAtEndPoint(); ChangeRowAssert changeRowAssert2 = changeRowAssert .hasValues(4, "Murray", "Bill", "1950-09-21", "30B443AE-C0C9-4790-9BEC-CE1380808435") .hasValues( 4, "Murray", "Bill", "1950-09-21", UUID.fromString("30B443AE-C0C9-4790-9BEC-CE1380808435")); Assertions.assertThat(changeRowAssert).isSameAs(changeRowAssert2); TableRowAssert tableRowAssert = assertThat(table).row(); TableRowAssert tableRowAssert2 = tableRowAssert .hasValues( 1, "Weaver", "Susan Alexandra", "1949-10-08", "30B443AE-C0C9-4790-9BEC-CE1380808435") .hasValues( 1, "Weaver", "Susan Alexandra", "1949-10-08", UUID.fromString("30B443AE-C0C9-4790-9BEC-CE1380808435")); Assertions.assertThat(tableRowAssert).isSameAs(tableRowAssert2); }
/** This method tests the {@code row} navigation method. */ @Test public void test_column_from_table_with_assertions() throws Exception { Field fieldPosition = AbstractDbAssert.class.getDeclaredField("rowPosition"); fieldPosition.setAccessible(true); Field fieldRow = AbstractRowAssert.class.getDeclaredField("row"); fieldRow.setAccessible(true); Field fieldIndex = Position.class.getDeclaredField("nextIndex"); fieldIndex.setAccessible(true); Table table = new Table(source, "actor"); TableAssert tableAssert = assertThat(table); Position position = (Position) fieldPosition.get(tableAssert); Assertions.assertThat(fieldIndex.get(position)).isEqualTo(0); TableRowAssert tableRowAssert0 = tableAssert.row(0); Assertions.assertThat(fieldIndex.get(position)).isEqualTo(1); TableRowAssert tableRowAssert1 = tableAssert.row(1); Assertions.assertThat(fieldIndex.get(position)).isEqualTo(2); TableRowAssert tableRowAssert2 = tableAssert.row(2); Assertions.assertThat(fieldIndex.get(position)).isEqualTo(3); try { tableAssert.row(3); fail("An exception must be raised"); } catch (AssertJDBException e) { Assertions.assertThat(e.getMessage()).isEqualTo("Index 3 out of the limits [0, 3["); } TableRowAssert tableRowAssertAgain0 = tableAssert.row(0); Assertions.assertThat(tableRowAssert0).isSameAs(tableRowAssertAgain0); TableAssert tableAssertBis = assertThat(table); Position positionBis = (Position) fieldPosition.get(tableAssertBis); Assertions.assertThat(fieldIndex.get(positionBis)).isEqualTo(0); TableRowAssert tableRowAssertBis0 = tableAssertBis.row(0); Assertions.assertThat(fieldIndex.get(positionBis)).isEqualTo(1); TableRowAssert tableRowAssertBis1 = tableRowAssertBis0.row(1); Assertions.assertThat(fieldIndex.get(positionBis)).isEqualTo(2); TableRowAssert tableRowAssertBis2 = tableRowAssertBis1.row(2); Assertions.assertThat(fieldIndex.get(positionBis)).isEqualTo(3); try { tableRowAssertBis2.row(3); fail("An exception must be raised"); } catch (AssertJDBException e) { Assertions.assertThat(e.getMessage()).isEqualTo("Index 3 out of the limits [0, 3["); } try { tableRowAssertBis2.row(-1); fail("An exception must be raised"); } catch (AssertJDBException e) { Assertions.assertThat(e.getMessage()).isEqualTo("Index -1 out of the limits [0, 3["); } TableRowAssert tableRowAssertBisAgain0 = tableRowAssertBis2.row(0); Assertions.assertThat(tableRowAssertBis0).isSameAs(tableRowAssertBisAgain0); Row rowId0 = (Row) fieldRow.get(tableRowAssert0); Row rowId1 = (Row) fieldRow.get(tableRowAssert1); Row rowId2 = (Row) fieldRow.get(tableRowAssert2); Row rowIdBis0 = (Row) fieldRow.get(tableRowAssertBis0); Row rowIdBis1 = (Row) fieldRow.get(tableRowAssertBis1); Row rowIdBis2 = (Row) fieldRow.get(tableRowAssertBis2); Assertions.assertThat(rowId0.getValuesList().get(0).getValue()) .isEqualTo(rowIdBis0.getValuesList().get(0).getValue()) .isEqualTo(new BigDecimal("1")); Assertions.assertThat(rowId0.getValuesList().get(1).getValue()) .isEqualTo(rowIdBis0.getValuesList().get(1).getValue()) .isEqualTo("Weaver"); Assertions.assertThat(rowId0.getValuesList().get(2).getValue()) .isEqualTo(rowIdBis0.getValuesList().get(2).getValue()) .isEqualTo("Sigourney"); Assertions.assertThat(rowId0.getValuesList().get(3).getValue()) .isEqualTo(rowIdBis0.getValuesList().get(3).getValue()) .isEqualTo(Date.valueOf("1949-10-08")); Assertions.assertThat(rowId0.getValuesList().get(4).getValue()) .isEqualTo(rowIdBis0.getValuesList().get(4).getValue()) .isEqualTo(UUID.fromString("30B443AE-C0C9-4790-9BEC-CE1380808435")); Assertions.assertThat(rowId1.getValuesList().get(0).getValue()) .isEqualTo(rowIdBis1.getValuesList().get(0).getValue()) .isEqualTo(new BigDecimal("2")); Assertions.assertThat(rowId1.getValuesList().get(1).getValue()) .isEqualTo(rowIdBis1.getValuesList().get(1).getValue()) .isEqualTo("Phoenix"); Assertions.assertThat(rowId1.getValuesList().get(2).getValue()) .isEqualTo(rowIdBis1.getValuesList().get(2).getValue()) .isEqualTo("Joaquim"); Assertions.assertThat(rowId1.getValuesList().get(3).getValue()) .isEqualTo(rowIdBis1.getValuesList().get(3).getValue()) .isEqualTo(Date.valueOf("1974-10-28")); Assertions.assertThat(rowId1.getValuesList().get(4).getValue()) .isEqualTo(rowIdBis1.getValuesList().get(4).getValue()) .isEqualTo(UUID.fromString("16319617-AE95-4087-9264-D3D21BF611B6")); Assertions.assertThat(rowId2.getValuesList().get(0).getValue()) .isEqualTo(rowIdBis2.getValuesList().get(0).getValue()) .isEqualTo(new BigDecimal("3")); Assertions.assertThat(rowId2.getValuesList().get(1).getValue()) .isEqualTo(rowIdBis2.getValuesList().get(1).getValue()) .isEqualTo("Worthington"); Assertions.assertThat(rowId2.getValuesList().get(2).getValue()) .isEqualTo(rowIdBis2.getValuesList().get(2).getValue()) .isEqualTo("Sam"); Assertions.assertThat(rowId2.getValuesList().get(3).getValue()) .isEqualTo(rowIdBis2.getValuesList().get(3).getValue()) .isEqualTo(Date.valueOf("1976-08-02")); Assertions.assertThat(rowId2.getValuesList().get(4).getValue()) .isEqualTo(rowIdBis2.getValuesList().get(4).getValue()) .isEqualTo(UUID.fromString("D735221B-5DE5-4112-AA1E-49090CB75ADA")); }