use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldHaveAnnotations_create_Test method should_create_error_message.
@Test
public void should_create_error_message() {
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting%n" + " <org.assertj.core.error.ShouldHaveAnnotations_create_Test>%n" + "to have annotations:%n" + " <[java.lang.Override, java.lang.Deprecated]>%n" + "but the following annotations were not found:%n" + " <[java.lang.SuppressWarnings]>"));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldHaveAtLeastOneElementOfType_create_Test method should_create_error_message_for_array.
@Test
public void should_create_error_message_for_array() {
ErrorMessageFactory factory = shouldHaveAtLeastOneElementOfType(array("Yoda", "Luke"), Long.class);
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting:%n" + " <[\"Yoda\", \"Luke\"]>%n" + "to have at least one element of type:%n" + " <java.lang.Long>%n" + "but had none."));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldHaveDateField_create_Test method should_create_error_message_for_fields.
@Test
public void should_create_error_message_for_fields() {
Date date = parse("2015-12-31");
ErrorMessageFactory factory = shouldHaveDateField(date, "month", 10);
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + " <2015-12-31T00:00:00.000>%n" + "to be on \"month\" <10>"));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldContainExactly_create_Test method should_display_missing_and_unexpected_elements.
@Test
public void should_display_missing_and_unexpected_elements() {
ErrorMessageFactory factory = shouldContainExactly(newArrayList("Yoda", "Han"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), newLinkedHashSet("Han"));
String message = factory.create(new TextDescription("Test"));
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + " <[\"Yoda\", \"Han\"]>%n" + "to contain exactly (and in same order):%n" + " <[\"Luke\", \"Yoda\"]>%n" + "but some elements were not found:%n" + " <[\"Luke\"]>%n" + "and others were not expected:%n" + " <[\"Han\"]>%n"));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldContainExactly_create_Test method should_display_first_wrong_element_when_only_elements_order_differs_according_to_custom_comparison_strategy.
@Test
public void should_display_first_wrong_element_when_only_elements_order_differs_according_to_custom_comparison_strategy() {
ErrorMessageFactory factory = elementsDifferAtIndex("Luke", "Han", 1, CASE_INSENSITIVE_COMPARISON_STRATEGY);
String message = factory.create(new TextDescription("Test"));
assertThat(message).isEqualTo(format("[Test] %n" + "Actual and expected have the same elements but not in the same order, at index 1 actual element was:%n" + " <\"Luke\">%nwhereas expected element was:%n" + " <\"Han\">%n" + "when comparing values using CaseInsensitiveStringComparator"));
}
Aggregations