Search in sources :

Example 26 with TextDescription

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]>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 27 with TextDescription

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."));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 28 with TextDescription

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>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Date(java.util.Date) Test(org.junit.Test)

Example 29 with TextDescription

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"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) Test(org.junit.Test)

Example 30 with TextDescription

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"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) Test(org.junit.Test)

Aggregations

TextDescription (org.assertj.core.description.TextDescription)210 Test (org.junit.Test)210 StandardRepresentation (org.assertj.core.presentation.StandardRepresentation)157 ComparatorBasedComparisonStrategy (org.assertj.core.internal.ComparatorBasedComparisonStrategy)24 PredicateDescription (org.assertj.core.presentation.PredicateDescription)8 Jedi (org.assertj.core.test.Jedi)6 Path (java.nio.file.Path)4 Integer.toHexString (java.lang.Integer.toHexString)3 Date (java.util.Date)3 Description (org.assertj.core.description.Description)3 Difference (org.assertj.core.internal.DeepDifference.Difference)3 BaseTest (org.assertj.core.api.BaseTest)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 LongPredicate (java.util.function.LongPredicate)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 LongStream (java.util.stream.LongStream)1