use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldNotHaveDuplicates_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] %nFound duplicate(s):%n <[\"Yoda\"]>%nin:%n <[\"Yoda\", \"Yoda\", \"Luke\"]>%n"));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldNotHaveDuplicates_create_Test method should_create_error_message_with_custom_comparison_strategy.
@Test
public void should_create_error_message_with_custom_comparison_strategy() {
factory = shouldNotHaveDuplicates(newArrayList("Yoda", "Yoda", "Luke"), newArrayList("Yoda"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(String.format("[Test] %nFound duplicate(s):%n <[\"Yoda\"]>%nin:%n <[\"Yoda\", \"Yoda\", \"Luke\"]>%n" + "when comparing values using CaseInsensitiveStringComparator"));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldNotHaveThrown_create_Test method should_create_error_message_with_stacktrace_of_exception.
@Test
public void should_create_error_message_with_stacktrace_of_exception() {
// GIVEN
Exception exception = new Exception("boom");
ErrorMessageFactory factory = shouldNotHaveThrown(exception);
// WHEN
String message = factory.create(new TextDescription("Test"), STANDARD_REPRESENTATION);
// THEN
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting code not to raise a throwable but caught%n" + " <\"%s\">", getStackTrace(exception)));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldNotMatch_create_Test method should_create_error_message_with_predicate_description.
@Test
public void should_create_error_message_with_predicate_description() {
ErrorMessageFactory factory = shouldNotMatch("Yoda", (String color) -> color.equals("green"), new PredicateDescription("green light saber"));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %nExpecting:%n <\"Yoda\">%nnot to match 'green light saber' predicate."));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldNotStartWith_create_Test method should_create_error_message_with_custom_comparison_strategy.
@Test
public void should_create_error_message_with_custom_comparison_strategy() {
factory = shouldNotStartWith(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting:%n" + " <[\"Yoda\", \"Luke\"]>%n" + "not to start with:%n" + " <[\"Han\", \"Leia\"]>%n" + "when comparing values using CaseInsensitiveStringComparator"));
}
Aggregations