use of org.assertj.core.description.Description 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.description.Description in project assertj-core by joel-costigliola.
the class Failures_failure_with_ErrorMessage_Test method should_use_ErrorMessage_when_overriding_error_message_is_not_specified.
@Test
public void should_use_ErrorMessage_when_overriding_error_message_is_not_specified() {
Description description = new TestDescription("description");
info.description(description);
when(errorMessage.create(description, info.representation())).thenReturn("[description] my message");
AssertionError failure = failures.failure(info, errorMessage);
assertThat(failure).hasMessage("[description] my message");
}
use of org.assertj.core.description.Description in project assertj-core by joel-costigliola.
the class SetAssert_raw_set_assertions_chained_after_superclass_method_Test method raw_set_assertions_mixed_with_inherited_methods.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Ignore
@Test
public void raw_set_assertions_mixed_with_inherited_methods() {
Description description = emptyDescription();
Set set = new java.util.HashSet<>();
set.add("Key1");
set.add("Key2");
assertThat(set).as("desc").containsOnly("Key1", "Key2");
// try all base assertions followed by set specific ones using generics
assertThat(set).as("desc").usingDefaultComparator().as(description).describedAs(description).describedAs("describedAs").has(null).hasSameClassAs(set).hasToString(set.toString()).is(null).isEqualTo(set).isExactlyInstanceOf(Map.class).isIn(new HashSet<>()).isIn(Map.class).isInstanceOf(Map.class).isInstanceOfAny(Map.class, String.class).isNot(null).isNotEqualTo(null).isNotEmpty().isNotExactlyInstanceOf(String.class).isNotIn(new HashSet<>()).isNotIn(Map.class).isNotInstanceOf(Map.class).isNotInstanceOfAny(Map.class, String.class).isNotNull().isNotOfAnyClassIn(Map.class, String.class).isNotSameAs(null).isOfAnyClassIn(Map.class, String.class).isSameAs("").overridingErrorMessage("").withFailMessage("").withThreadDumpOnError().usingDefaultComparator().contains("Key1", atIndex(0));
}
use of org.assertj.core.description.Description in project assertj-core by joel-costigliola.
the class ListAssert_raw_list_assertions_chained_after_superclass_method_Test method raw_list_assertions_mixed_with_inherited_methods.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Ignore
@Test
public void raw_list_assertions_mixed_with_inherited_methods() {
Description description = emptyDescription();
List list = new java.util.ArrayList<>();
list.add("Key1");
list.add("Key2");
assertThat(list).as("desc").containsOnly("Key1", "Key2");
// try all base assertions followed by list specific ones using generics
assertThat(list).as("desc").usingDefaultComparator().isSorted().as(description).isSorted().describedAs(description).describedAs("describedAs").has(null).hasSameClassAs(list).hasToString(list.toString()).is(null).isEqualTo(list).isExactlyInstanceOf(Map.class).isIn(new ArrayList<>()).isIn(Map.class).isInstanceOf(Map.class).isInstanceOfAny(Map.class, String.class).isNot(null).isNotEqualTo(null).isNotEmpty().isNotExactlyInstanceOf(String.class).isNotIn(new ArrayList<>()).isNotIn(Map.class).isNotInstanceOf(Map.class).isNotInstanceOfAny(Map.class, String.class).isNotNull().isNotOfAnyClassIn(Map.class, String.class).isNotSameAs(null).isOfAnyClassIn(Map.class, String.class).isSameAs("").overridingErrorMessage("").withFailMessage("").withThreadDumpOnError().usingDefaultComparator().contains("Key1", atIndex(0));
}
use of org.assertj.core.description.Description in project assertj-core by joel-costigliola.
the class WritableAssertionInfo_descriptionText_Test method should_return_text_of_description.
@Test
public void should_return_text_of_description() {
Description description = mock(Description.class);
info.description(description);
when(description.value()).thenReturn("Yoda");
assertThat(info.descriptionText()).isEqualTo("Yoda");
}
Aggregations