Search in sources :

Example 51 with TextDescription

use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.

the class ShouldHaveMethods_create_Test method should_create_error_message_for_shouldNotHaveMethods.

@Test
public void should_create_error_message_for_shouldNotHaveMethods() {
    ErrorMessageFactory factory = shouldNotHaveMethods(Person.class, false, newTreeSet("getName"));
    String message = factory.create(new TextDescription("Test"), CONFIGURATION_PROVIDER.representation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + "  <org.assertj.core.test.Person>%n" + "not to have any methods but it has the following:%n" + "  <[\"getName\"]>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) Test(org.junit.Test)

Example 52 with TextDescription

use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.

the class ShouldHaveMethods_create_Test method should_create_error_message_for_shouldNotHave_Declared_Methods.

@Test
public void should_create_error_message_for_shouldNotHave_Declared_Methods() {
    ErrorMessageFactory factory = shouldNotHaveMethods(Person.class, true, newTreeSet("getName"));
    String message = factory.create(new TextDescription("Test"), CONFIGURATION_PROVIDER.representation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + "  <org.assertj.core.test.Person>%n" + "not to have any declared methods but it has the following:%n" + "  <[\"getName\"]>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) Test(org.junit.Test)

Example 53 with TextDescription

use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.

the class ShouldHaveOnlyElementsOfType_create_Test method should_create_error_message_for_array.

@Test
public void should_create_error_message_for_array() {
    Object[] array = new Object[] { "Yoda", 5L };
    ErrorMessageFactory factory = shouldHaveOnlyElementsOfType(array, String.class, Long.class);
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting:%n" + "  <[\"Yoda\", 5L]>%n" + "to only have elements of type:%n" + "  <java.lang.String>%n" + "but found:%n" + "  <java.lang.Long>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 54 with TextDescription

use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.

the class ShouldHaveSameContent_create_Test method should_create_error_message_inputstream_even_if_content_contains_format_specifier.

@Test
public void should_create_error_message_inputstream_even_if_content_contains_format_specifier() {
    ErrorMessageFactory factory = shouldHaveSameContent(new ByteArrayInputStream(new byte[] { 'a' }), new ByteArrayInputStream(new byte[] { 'b' }), emptyList());
    String expectedErrorMessage = format("[Test] %nInputStreams do not have same content:%n");
    assertThat(factory.create(new TextDescription("Test"), new StandardRepresentation())).isEqualTo(expectedErrorMessage);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 55 with TextDescription

use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.

the class ShouldHaveSameContent_create_Test method should_create_error_message_file_even_if_content_contains_format_specifier.

@Test
public void should_create_error_message_file_even_if_content_contains_format_specifier() {
    ErrorMessageFactory factory = shouldHaveSameContent(new FakeFile("abc"), new FakeFile("xyz"), emptyList());
    String expectedErrorMessage = format("[Test] %nFile:%n  <abc>%nand file:%n  <xyz>%ndo not have same content:%n");
    assertThat(factory.create(new TextDescription("Test"), new StandardRepresentation())).isEqualTo(expectedErrorMessage);
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) 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