Search in sources :

Example 6 with ComparatorBasedComparisonStrategy

use of org.assertj.core.internal.ComparatorBasedComparisonStrategy in project assertj-core by joel-costigliola.

the class ShouldBeIn_create_Test method should_create_error_message_with_custom_comparison_strategy.

@Test
public void should_create_error_message_with_custom_comparison_strategy() {
    factory = shouldBeIn("Yoda", array("Luke", "Leia"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %nExpecting:%n <\"Yoda\">%nto be in:%n <[\"Luke\", \"Leia\"]>%nwhen 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 7 with ComparatorBasedComparisonStrategy

use of org.assertj.core.internal.ComparatorBasedComparisonStrategy in project assertj-core by joel-costigliola.

the class ShouldBeSubsetOf_create_Test method should_create_error_message_with_custom_comparison_strategy.

@Test
public void should_create_error_message_with_custom_comparison_strategy() {
    ErrorMessageFactory factory = shouldBeSubsetOf(newArrayList("Yoda", "Luke"), newArrayList("Han", "Luke"), newArrayList("Yoda"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %nExpecting when comparing values using CaseInsensitiveStringComparator:%n <[\"Yoda\", \"Luke\"]>%nto be subset of%n <[\"Han\", \"Luke\"]>%nbut found these extra elements:%n <[\"Yoda\"]>"));
}
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 8 with ComparatorBasedComparisonStrategy

use of org.assertj.core.internal.ComparatorBasedComparisonStrategy in project assertj-core by joel-costigliola.

the class StringsBaseTest method setUp.

@Before
public void setUp() {
    failures = spy(new Failures());
    strings = new Strings();
    strings.failures = failures;
    comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance);
    stringsWithCaseInsensitiveComparisonStrategy = new Strings(comparisonStrategy);
    stringsWithCaseInsensitiveComparisonStrategy.failures = failures;
}
Also used : ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) Failures(org.assertj.core.internal.Failures) Strings(org.assertj.core.internal.Strings) Before(org.junit.Before)

Example 9 with ComparatorBasedComparisonStrategy

use of org.assertj.core.internal.ComparatorBasedComparisonStrategy in project assertj-core by joel-costigliola.

the class FloatsBaseTest method setUp.

@Before
public void setUp() {
    failures = spy(new Failures());
    floats = new Floats();
    floats.setFailures(failures);
    absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(new AbsValueComparator<Float>());
    floatsWithAbsValueComparisonStrategy = new Floats(absValueComparisonStrategy);
    floatsWithAbsValueComparisonStrategy.failures = failures;
}
Also used : AbsValueComparator(org.assertj.core.util.AbsValueComparator) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) Failures(org.assertj.core.internal.Failures) Floats(org.assertj.core.internal.Floats) Before(org.junit.Before)

Example 10 with ComparatorBasedComparisonStrategy

use of org.assertj.core.internal.ComparatorBasedComparisonStrategy in project assertj-core by joel-costigliola.

the class IterablesBaseTest method setUp.

@Before
public void setUp() {
    actual = newArrayList("Luke", "Yoda", "Leia");
    failures = spy(new Failures());
    iterables = new Iterables();
    iterables.failures = failures;
    comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance);
    iterablesWithCaseInsensitiveComparisonStrategy = new Iterables(comparisonStrategy);
    iterablesWithCaseInsensitiveComparisonStrategy.failures = failures;
    info = someInfo();
}
Also used : ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) Failures(org.assertj.core.internal.Failures) Iterables(org.assertj.core.internal.Iterables) Before(org.junit.Before)

Aggregations

ComparatorBasedComparisonStrategy (org.assertj.core.internal.ComparatorBasedComparisonStrategy)64 Test (org.junit.Test)26 TextDescription (org.assertj.core.description.TextDescription)24 StandardRepresentation (org.assertj.core.presentation.StandardRepresentation)22 CheckReturnValue (org.assertj.core.util.CheckReturnValue)18 Failures (org.assertj.core.internal.Failures)10 Before (org.junit.Before)10 ObjectArrays (org.assertj.core.internal.ObjectArrays)8 Iterables (org.assertj.core.internal.Iterables)6 AbsValueComparator (org.assertj.core.util.AbsValueComparator)5 IgnoringFieldsComparator (org.assertj.core.internal.IgnoringFieldsComparator)4 Integers (org.assertj.core.internal.Integers)3 Lists (org.assertj.core.internal.Lists)3 Longs (org.assertj.core.internal.Longs)3 Objects (org.assertj.core.internal.Objects)3 OnFieldsComparator (org.assertj.core.internal.OnFieldsComparator)3 Characters (org.assertj.core.internal.Characters)2 Comparables (org.assertj.core.internal.Comparables)2 Doubles (org.assertj.core.internal.Doubles)2 Floats (org.assertj.core.internal.Floats)2