/** This method should fail because the value at end point is a stringbuilder. */ @Test public void should_fail_because_value_at_end_point_is_a_stringbuilder() throws Exception { WritableAssertionInfo info = new WritableAssertionInfo(); info.description("description"); Table table = new Table(); TableAssert tableAssert = assertThat(table); try { AssertionsOnColumnOfChangeType.isBoolean( tableAssert, info, getValue(null, false), getValue(null, new StringBuilder("test")), false); fail("An exception must be raised"); } catch (AssertionError e) { Assertions.assertThat(e.getMessage()) .isEqualTo( String.format( "[description] %n" + "Expecting that the value at end point:%n" + " <test>%n" + "to be of type%n" + " <BOOLEAN>%n" + "but was of type%n" + " <NOT_IDENTIFIED> (java.lang.StringBuilder)")); } }
/** This method tests the {@code isBoolean} assertion method. */ @Test public void test_is_boolean() throws Exception { WritableAssertionInfo info = new WritableAssertionInfo(); Table table = new Table(); TableAssert tableAssert = assertThat(table); TableAssert tableAssert2 = AssertionsOnColumnOfChangeType.isBoolean( tableAssert, info, getValue(null, true), getValue(null, true), false); Assertions.assertThat(tableAssert2).isSameAs(tableAssert); tableAssert2 = AssertionsOnColumnOfChangeType.isBoolean( tableAssert, info, getValue(null, true), getValue(null, true), true); Assertions.assertThat(tableAssert2).isSameAs(tableAssert); tableAssert2 = AssertionsOnColumnOfChangeType.isBoolean( tableAssert, info, getValue(null, null), getValue(null, true), true); Assertions.assertThat(tableAssert2).isSameAs(tableAssert); }
/** This method should fail because the value at end point have different type. */ @Test public void should_fail_because_value_at_end_point_have_different_type() throws Exception { WritableAssertionInfo info = new WritableAssertionInfo(); info.description("description"); Table table = new Table(); TableAssert tableAssert = assertThat(table); try { AssertionsOnColumnOfChangeType.isBoolean( tableAssert, info, getValue(null, false), getValue(null, "test"), false); fail("An exception must be raised"); } catch (AssertionError e) { Assertions.assertThat(e.getMessage()) .isEqualTo( String.format( "[description] %n" + "Expecting that the value at end point:%n" + " <\"test\">%n" + "to be of type%n" + " <BOOLEAN>%n" + "but was of type%n" + " <TEXT>")); } }