use of org.assertj.core.presentation.StandardRepresentation in project gwt-test-utils by gwt-test-utils.
the class GwtGenericAssert method propertyComparisonFailed.
/**
* Returns a <code>{@link AssertionError}</code> describing a property comparison failure. A
* default description is set if the default error message is not overrided and a custom
* description is not applied. In both case, the resulting description would be prefixed by the
* message eventually supplied through {@link GwtGenericAssert#withPrefix(String)}.
*
* @param propertyName the compared property name
* @param actual the actual value.
* @param expected the expected value.
* @return a {@code AssertionError} describing the comparison failure.
*/
protected AssertionError propertyComparisonFailed(String propertyName, Object actual, Object expected) {
GwtWritableAssertionInfo info = new GwtWritableAssertionInfo();
info.prefix(gwtInfo.prefix());
info.overridingErrorMessage(gwtInfo.overridingErrorMessage());
Description d = gwtInfo.superDescription();
String newDescription = d != null ? d.value() + " " + propertyName : this.actual.getClass().getSimpleName() + "'s " + propertyName;
info.description(newDescription);
return failures.failure(info, shouldBeEqual(actual, expected, new StandardRepresentation()));
}
use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.
the class ShouldBeEqual_newAssertionError_differentiating_expected_and_actual_Test method should_create_AssertionError_with_message_differentiating_expected_and_actual_persons_even_if_a_comparator_based_comparison_strategy_is_used.
@Test
public void should_create_AssertionError_with_message_differentiating_expected_and_actual_persons_even_if_a_comparator_based_comparison_strategy_is_used() {
Person actual = new Person("Jake", 43);
Person expected = new Person("Jake", 47);
ComparisonStrategy ageComparisonStrategy = new ComparatorBasedComparisonStrategy(new PersonComparator());
shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected, ageComparisonStrategy, new StandardRepresentation());
shouldBeEqual.descriptionFormatter = mock(DescriptionFormatter.class);
when(shouldBeEqual.descriptionFormatter.format(description)).thenReturn(formattedDescription);
AssertionError error = shouldBeEqual.newAssertionError(description, new StandardRepresentation());
assertThat(error).isInstanceOf(AssertionFailedError.class).hasMessage("[my test] %n" + "Expecting:%n" + " <\"Person[name=Jake] (Person@%s)\">%n" + "to be equal to:%n" + " <\"Person[name=Jake] (Person@%s)\">%n" + "when comparing values using PersonComparator%n" + "but was not.", toHexString(actual.hashCode()), toHexString(expected.hashCode()));
}
use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.
the class ShouldBeEqual_newAssertionError_differentiating_expected_and_actual_Test method should_create_AssertionError_with_message_differentiating_null_and_object_with_null_toString.
@Test
public void should_create_AssertionError_with_message_differentiating_null_and_object_with_null_toString() {
Object actual = null;
Object expected = new ToStringIsNull();
shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected, new StandardRepresentation());
shouldBeEqual.descriptionFormatter = mock(DescriptionFormatter.class);
when(shouldBeEqual.descriptionFormatter.format(description)).thenReturn(formattedDescription);
AssertionError error = shouldBeEqual.newAssertionError(description, new StandardRepresentation());
assertThat(error).isInstanceOf(AssertionFailedError.class).hasMessage("[my test] %n" + "Expecting:%n" + " <null>%n" + "to be equal to:%n" + " <\"null (ToStringIsNull@%s)\">%n" + "but was not.", toHexString(expected.hashCode()));
}
use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.
the class ShouldBeEqual_newAssertionError_differentiating_expected_and_actual_Test method should_create_AssertionError_with_message_differentiating_expected_double_and_actual_float.
@Test
public void should_create_AssertionError_with_message_differentiating_expected_double_and_actual_float() {
Float actual = 42f;
Double expected = 42d;
shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected, new StandardRepresentation());
shouldBeEqual.descriptionFormatter = mock(DescriptionFormatter.class);
when(shouldBeEqual.descriptionFormatter.format(description)).thenReturn(formattedDescription);
AssertionError error = shouldBeEqual.newAssertionError(description, new StandardRepresentation());
assertThat(error).isInstanceOf(ComparisonFailure.class).hasMessage("[my test] expected:<42.0[]> but was:<42.0[f]>");
}
use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.
the class ShouldBeEqual_newAssertionError_differentiating_expected_and_actual_Test method should_create_AssertionError_with_message_differentiating_object_with_null_toString_and_null.
@Test
public void should_create_AssertionError_with_message_differentiating_object_with_null_toString_and_null() {
Object actual = new ToStringIsNull();
Object expected = null;
shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected, new StandardRepresentation());
shouldBeEqual.descriptionFormatter = mock(DescriptionFormatter.class);
when(shouldBeEqual.descriptionFormatter.format(description)).thenReturn(formattedDescription);
AssertionError error = shouldBeEqual.newAssertionError(description, new StandardRepresentation());
assertThat(error).isInstanceOf(AssertionFailedError.class).hasMessage("[my test] %n" + "Expecting:%n" + " <\"null (ToStringIsNull@%s)\">%n" + "to be equal to:%n" + " <null>%n" + "but was not.", toHexString(actual.hashCode()));
}
Aggregations