Search in sources :

Example 11 with Description

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);
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) Description(org.assertj.core.description.Description) EmptyTextDescription.emptyDescription(org.assertj.core.description.EmptyTextDescription.emptyDescription) TestDescription(org.assertj.core.internal.TestDescription) Test(org.junit.Test)

Example 12 with Description

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();
}
Also used : Description(org.assertj.core.description.Description) TestData.someDescription(org.assertj.core.test.TestData.someDescription) Test(org.junit.Test)

Example 13 with Description

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

Example 14 with Description

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

Example 15 with 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);
}
Also used : Description(org.assertj.core.description.Description) TextDescription(org.assertj.core.description.TextDescription) TextDescription(org.assertj.core.description.TextDescription) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

Description (org.assertj.core.description.Description)16 Test (org.junit.Test)13 EmptyTextDescription.emptyDescription (org.assertj.core.description.EmptyTextDescription.emptyDescription)6 TestDescription (org.assertj.core.internal.TestDescription)5 TextDescription (org.assertj.core.description.TextDescription)4 Map (java.util.Map)3 Ignore (org.junit.Ignore)3 ArrayList (java.util.ArrayList)2 StandardRepresentation (org.assertj.core.presentation.StandardRepresentation)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 BasicErrorMessageFactory (org.assertj.core.error.BasicErrorMessageFactory)1 Representation (org.assertj.core.presentation.Representation)1 TestData.someDescription (org.assertj.core.test.TestData.someDescription)1