use of org.assertj.core.description.Description in project assertj-core by joel-costigliola.
the class BasicErrorMessageFactory_create_Test method should_create_error_with_configured_representation.
@Test
public void should_create_error_with_configured_representation() {
Description description = new TestDescription("Test");
String formattedMessage = "[Test] Hello Yoda";
when(formatter.format(eq(description), same(CONFIGURATION_PROVIDER.representation()), eq("Hello %s"), eq("Yoda"))).thenReturn(formattedMessage);
assertThat(factory.create(description)).isEqualTo(formattedMessage);
}
use of org.assertj.core.description.Description in project assertj-core by joel-costigliola.
the class AbstractAssert_describedAs_with_description_Test method should_set_empty_description_if_description_is_null.
@Test
public void should_set_empty_description_if_description_is_null() {
Description description = null;
assertions.describedAs(description);
assertThat(assertions.descriptionText()).isEmpty();
}
use of org.assertj.core.description.Description in project assertj-core by joel-costigliola.
the class Failures_failure_with_AssertionErrorFactory_Test method should_use_AssertionErrorFactory_when_overriding_error_message_is_not_specified.
@Test
public void should_use_AssertionErrorFactory_when_overriding_error_message_is_not_specified() {
MyOwnAssertionError expectedError = new MyOwnAssertionError("[description] my message");
Description description = new TestDescription("description");
info.description(description);
when(errorFactory.newAssertionError(description, info.representation())).thenReturn(expectedError);
AssertionError failure = failures.failure(info, errorFactory);
assertThat(failure).isSameAs(expectedError);
}
use of org.assertj.core.description.Description in project assertj-core by joel-costigliola.
the class MessageFormatter_format_Test method should_format_message.
@Test
public void should_format_message() {
Description description = new TextDescription("Test");
String s = messageFormatter.format(description, STANDARD_REPRESENTATION, "Hello %s", "World");
assertThat(s).isEqualTo("[Test] Hello \"World\"");
verify(descriptionFormatter).format(description);
}
use of org.assertj.core.description.Description in project assertj-core by joel-costigliola.
the class MessageFormatter_format_Test method should_format_message_and_correctly_escape_percentage.
@Test
@UseDataProvider("messages")
public void should_format_message_and_correctly_escape_percentage(String input, String formatted) {
// GIVEN
Description description = new TextDescription("Test");
// WHEN
String finalMessage = messageFormatter.format(description, STANDARD_REPRESENTATION, input);
// THEN
assertThat(finalMessage).isEqualTo("[Test] " + formatted);
}
Aggregations