use of org.assertj.core.internal.ComparatorBasedComparisonStrategy 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.internal.ComparatorBasedComparisonStrategy in project assertj-core by joel-costigliola.
the class ShouldContainSequence_create_Test method should_create_error_message_with_custom_comparison_strategy.
@Test
public void should_create_error_message_with_custom_comparison_strategy() {
ErrorMessageFactory factory = shouldContainSequence(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + " <[\"Yoda\", \"Luke\"]>%n" + "to contain sequence:%n" + " <[\"Han\", \"Leia\"]>%n" + "when comparing values using CaseInsensitiveStringComparator"));
}
use of org.assertj.core.internal.ComparatorBasedComparisonStrategy in project assertj-core by joel-costigliola.
the class ShouldContainSubsequenceOfCharSequence_create_Test method should_create_error_message_with_custom_comparison_strategy.
@Test
public void should_create_error_message_with_custom_comparison_strategy() {
String[] sequenceValues = { "{", "author", "title", "}" };
String actual = "{ 'title':'A Game of Thrones', 'author':'George Martin'}";
factory = shouldContainSubsequence(actual, sequenceValues, 1, new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %nExpecting:%n" + " <\"" + actual + "\">%n" + "to contain the following CharSequences in this order:%n" + " <[\"{\", \"author\", \"title\", \"}\"]>%n" + "but <\"title\"> was found before <\"author\">%n" + "when comparing values using CaseInsensitiveStringComparator"));
}
use of org.assertj.core.internal.ComparatorBasedComparisonStrategy in project assertj-core by joel-costigliola.
the class ShouldContain_create_Test method should_create_error_message_with_custom_comparison_strategy.
@Test
public void should_create_error_message_with_custom_comparison_strategy() {
factory = shouldContain(newArrayList("Yoda"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance));
String message = factory.create(new TextDescription("Test"));
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + " <[\"Yoda\"]>%n" + "to contain:%n" + " <[\"Luke\", \"Yoda\"]>%n" + "but could not find:%n" + " <[\"Luke\"]>%n" + "when comparing values using CaseInsensitiveStringComparator"));
}
use of org.assertj.core.internal.ComparatorBasedComparisonStrategy in project assertj-core by joel-costigliola.
the class ShouldContainsAnyOf_create_Test method should_create_error_message_with_custom_comparison_strategy.
@Test
public void should_create_error_message_with_custom_comparison_strategy() {
ErrorMessageFactory factory = shouldContainAnyOf(newArrayList("Yoda", "Han", "Han"), newArrayList("Vador", "Leia"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance));
String message = factory.create(new TextDescription("Test"), CONFIGURATION_PROVIDER.representation());
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + " <[\"Yoda\", \"Han\", \"Han\"]>%n" + "to contain at least one of the following elements:%n" + " <[\"Vador\", \"Leia\"]>%n" + "but none were found " + "when comparing values using CaseInsensitiveStringComparator"));
}
Aggregations