Search in sources :

Example 46 with StandardRepresentation

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

the class ShouldContainOnlyKeys_create_Test method should_not_display_unexpected_elements_when_there_are_none.

@Test
public void should_not_display_unexpected_elements_when_there_are_none() {
    ErrorMessageFactory factory = shouldContainOnlyKeys(mapOf(entry("color", "green")), newArrayList("jedi", "color"), newLinkedHashSet("jedi"), Collections.emptySet());
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting:%n" + "  <{\"color\"=\"green\"}>%n" + "to contain only following keys:%n" + "  <[\"jedi\", \"color\"]>%n" + "but could not find the following keys:%n" + "  <[\"jedi\"]>%n"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 47 with StandardRepresentation

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

the class ShouldContainOnlyNulls_create_Test method should_create_error_message_with_no_any_element.

@Test
public void should_create_error_message_with_no_any_element() {
    ErrorMessageFactory factory = shouldContainOnlyNulls(newArrayList());
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + "  <[]>%n" + "to contain only null elements but it was empty"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 48 with StandardRepresentation

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

the class ShouldContainOnly_create_Test method should_not_display_unexpected_elements_when_there_are_none_with_custom_comparison_strategy.

@Test
public void should_not_display_unexpected_elements_when_there_are_none_with_custom_comparison_strategy() {
    ErrorMessageFactory factory = shouldContainOnly(newArrayList("Yoda"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), Collections.emptySet(), CASE_INSENSITIVE_COMPARISON_STRATEGY);
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + "  <[\"Yoda\"]>%n" + "to contain only:%n" + "  <[\"Luke\", \"Yoda\"]>%n" + "but could not find the following elements:%n" + "  <[\"Luke\"]>%n" + "when comparing values using CaseInsensitiveStringComparator"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 49 with StandardRepresentation

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

the class ShouldContainOnly_create_Test method should_create_error_message_with_custom_comparison_strategy.

@Test
public void should_create_error_message_with_custom_comparison_strategy() {
    ErrorMessageFactory factory = shouldContainOnly(newArrayList("Yoda", "Han"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), newLinkedHashSet("Han"), CASE_INSENSITIVE_COMPARISON_STRATEGY);
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + "  <[\"Yoda\", \"Han\"]>%n" + "to contain only:%n" + "  <[\"Luke\", \"Yoda\"]>%n" + "elements not found:%n" + "  <[\"Luke\"]>%n" + "and elements not expected:%n" + "  <[\"Han\"]>%n" + "when comparing values using CaseInsensitiveStringComparator"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 50 with StandardRepresentation

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

the class ShouldContainPattern_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(format("[Test] %nExpecting:%n  \"Frodo\"%nto contain pattern:%n  \".*Orc.*\""));
}
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