Search in sources :

Example 81 with StandardRepresentation

use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.

the class ShouldOnlyHaveElementsOfTypes_create_Test method should_create_error_message.

@Test
public void should_create_error_message() {
    String message = factory.create(new TestDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + "  <[\"Yoda\", 42, \"Luke\"]>%n" + "to only have instances of:%n" + "  <[java.lang.Number, java.lang.Long]>%n" + "but these elements are not:%n" + "  <[\"Yoda\" (java.lang.String), \"Luke\" (java.lang.String)]>"));
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 82 with StandardRepresentation

use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.

the class ShouldOnlyHaveFields_create_Test method should_not_display_fields_not_found_when_there_are_none_for_declared_fields.

@Test
public void should_not_display_fields_not_found_when_there_are_none_for_declared_fields() {
    ErrorMessageFactory factory = shouldOnlyHaveDeclaredFields(Player.class, newLinkedHashSet("name", "team"), EMPTY_STRING_SET, newLinkedHashSet("address"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting%n" + "  <org.assertj.core.test.Player>%n" + "to only have the following declared fields:%n" + "  <[\"name\", \"team\"]>%n" + "but the following fields were unexpected:%n" + "  <[\"address\"]>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 83 with StandardRepresentation

use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.

the class ShouldOnlyHaveFields_create_Test method should_not_display_unexpected_fields_when_there_are_none_for_declared_fields.

@Test
public void should_not_display_unexpected_fields_when_there_are_none_for_declared_fields() {
    ErrorMessageFactory factory = shouldOnlyHaveDeclaredFields(Player.class, newLinkedHashSet("name", "team"), newLinkedHashSet("nickname"), EMPTY_STRING_SET);
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + "  <org.assertj.core.test.Player>%n" + "to only have the following declared fields:%n" + "  <[\"name\", \"team\"]>%n" + "but could not find the following fields:%n" + "  <[\"nickname\"]>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 84 with StandardRepresentation

use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.

the class ShouldOnlyHaveFields_create_Test method should_create_error_message_for_fields.

@Test
public void should_create_error_message_for_fields() {
    ErrorMessageFactory factory = shouldOnlyHaveFields(Player.class, newLinkedHashSet("name", "team"), newLinkedHashSet("nickname"), newLinkedHashSet("address"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + "  <org.assertj.core.test.Player>%n" + "to only have the following public accessible fields:%n" + "  <[\"name\", \"team\"]>%n" + "fields not found:%n" + "  <[\"nickname\"]>%n" + "and fields not expected:%n" + "  <[\"address\"]>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 85 with StandardRepresentation

use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.

the class ShouldOnlyHaveFields_create_Test method should_create_error_message_for_declared_fields.

@Test
public void should_create_error_message_for_declared_fields() {
    ErrorMessageFactory factory = shouldOnlyHaveDeclaredFields(Player.class, newLinkedHashSet("name", "team"), newLinkedHashSet("nickname"), newLinkedHashSet("address"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + "  <org.assertj.core.test.Player>%n" + "to only have the following declared fields:%n" + "  <[\"name\", \"team\"]>%n" + "fields not found:%n" + "  <[\"nickname\"]>%n" + "and fields not expected:%n" + "  <[\"address\"]>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Aggregations

StandardRepresentation (org.assertj.core.presentation.StandardRepresentation)241 Test (org.junit.Test)216 TextDescription (org.assertj.core.description.TextDescription)157 TestDescription (org.assertj.core.internal.TestDescription)48 ComparatorBasedComparisonStrategy (org.assertj.core.internal.ComparatorBasedComparisonStrategy)22 AssertionInfo (org.assertj.core.api.AssertionInfo)10 Before (org.junit.Before)9 PredicateDescription (org.assertj.core.presentation.PredicateDescription)7 Jedi (org.assertj.core.test.Jedi)6 Path (java.nio.file.Path)5 AssertionFailedError (org.opentest4j.AssertionFailedError)4 Date (java.util.Date)3 BaseTest (org.assertj.core.api.BaseTest)2 Description (org.assertj.core.description.Description)2 BigDecimalsBaseTest (org.assertj.core.internal.BigDecimalsBaseTest)2 BigIntegersBaseTest (org.assertj.core.internal.BigIntegersBaseTest)2 ComparisonFailure (org.junit.ComparisonFailure)2 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1