Search in sources :

Example 11 with StandardRepresentation

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

the class ShouldBeEqual_newAssertionError_without_JUnit_and_OTA4J_Test method should_create_AssertionError_if_created_ComparisonFailure_and_AssertionFailedError_is_null.

@Test
public void should_create_AssertionError_if_created_ComparisonFailure_and_AssertionFailedError_is_null() throws Exception {
    when(constructorInvoker.newInstance(any(String.class), any(Class[].class), any(Object[].class))).thenReturn(null);
    AssertionError error = factory.newAssertionError(description, new StandardRepresentation());
    check(error);
}
Also used : StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 12 with StandardRepresentation

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

the class ShouldContainSequence_create_Test method should_create_error_message_with_custom_comparison_strategy.

@Test
public void should_create_error_message_with_custom_comparison_strategy() {
    ErrorMessageFactory factory = shouldContainSequence(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + "  <[\"Yoda\", \"Luke\"]>%n" + "to contain sequence:%n" + "  <[\"Han\", \"Leia\"]>%n" + "when comparing values using CaseInsensitiveStringComparator"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) Test(org.junit.Test)

Example 13 with StandardRepresentation

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

the class ShouldContainString_create_Test method should_create_error_message_when_ignoring_case.

@Test
public void should_create_error_message_when_ignoring_case() {
    factory = shouldContainIgnoringCase("Yoda", "Luke");
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %nExpecting:%n <\"Yoda\">%nto contain:%n <\"Luke\">%n (ignoring case)"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 14 with StandardRepresentation

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

the class ShouldContainString_create_Test method should_create_error_message_with_several_string_values.

@Test
public void should_create_error_message_with_several_string_values() {
    factory = shouldContain("Yoda, Luke", array("Luke", "Vador", "Solo"), newSet("Vador", "Solo"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %nExpecting:%n <\"Yoda, Luke\">%nto contain:%n <[\"Luke\", \"Vador\", \"Solo\"]>%nbut could not find:%n <[\"Vador\", \"Solo\"]>%n "));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 15 with StandardRepresentation

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

the class ShouldContainSubsequenceOfCharSequence_create_Test method should_create_error_message.

@Test
public void should_create_error_message() {
    String[] sequenceValues = { "{", "author", "title", "}" };
    String actual = "{ 'title':'A Game of Thrones', 'author':'George Martin'}";
    factory = shouldContainSubsequence(actual, sequenceValues, 1);
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %nExpecting:%n" + "  <\"" + actual + "\">%n" + "to contain the following CharSequences in this order:%n" + "  <[\"{\", \"author\", \"title\", \"}\"]>%n" + "but <\"title\"> was found before <\"author\">%n"));
}
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