/** This method tests the {@code hasNumberOfModifiedColumnsLessThan} assertion method. */ @Test public void test_has_number_of_modified_columns_less_than() throws Exception { WritableAssertionInfo info = new WritableAssertionInfo(); Table table = new Table(); TableAssert tableAssert = assertThat(table); Row rowAtStartPoint = getRow( null, Arrays.asList("ID", "NAME", "FIRSTNAME", "BIRTH"), Arrays.asList( getValue(null, 1), getValue(null, "Weaver"), getValue(null, "Sigourney"), getValue(null, Date.valueOf("1949-10-08")))); Row rowAtEndPoint = getRow( null, Arrays.asList("ID", "NAME", "FIRSTNAME", "BIRTH"), Arrays.asList( getValue(null, 1), getValue(null, "Weaverr"), getValue(null, "Sigourneyy"), getValue(null, Date.valueOf("1949-10-08")))); Change change = getChange(DataType.TABLE, "test", ChangeType.MODIFICATION, rowAtStartPoint, rowAtEndPoint); TableAssert tableAssert2 = AssertionsOnModifiedColumns.hasNumberOfModifiedColumnsLessThan( tableAssert, info, change, 3); Assertions.assertThat(tableAssert2).isSameAs(tableAssert); }
/** This method should fail because the number of modified columns is greater or equal. */ @Test public void should_fail_because_number_of_modified_columns_is_greater_or_equal() throws Exception { WritableAssertionInfo info = new WritableAssertionInfo(); info.description("description"); Table table = new Table(); TableAssert tableAssert = assertThat(table); Row rowAtStartPoint = getRow( null, Arrays.asList("ID", "NAME", "FIRSTNAME", "BIRTH"), Arrays.asList( getValue(null, 1), getValue(null, "Weaver"), getValue(null, "Sigourney"), getValue(null, Date.valueOf("1949-10-08")))); Row rowAtEndPoint = getRow( null, Arrays.asList("ID", "NAME", "FIRSTNAME", "BIRTH"), Arrays.asList( getValue(null, 1), getValue(null, "Weaverr"), getValue(null, "Sigourneyy"), getValue(null, Date.valueOf("1949-10-08")))); Change change = getChange(DataType.TABLE, "test", ChangeType.MODIFICATION, rowAtStartPoint, rowAtEndPoint); try { AssertionsOnModifiedColumns.hasNumberOfModifiedColumnsLessThan(tableAssert, info, change, 1); fail("An exception must be raised"); } catch (AssertionError e) { Assertions.assertThat(e.getMessage()) .isEqualTo( String.format( "[description] %n" + "Expecting :%n" + " number of modifications is less than 1%n" + "but was:%n" + " 2")); } }