Search in sources :

Example 71 with TextDescription

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

the class ShouldNotEndWith_create_Test method should_create_error_message_with_custom_comparison_strategy.

@Test
public void should_create_error_message_with_custom_comparison_strategy() {
    factory = shouldNotEndWith(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting:%n" + "  <[\"Yoda\", \"Luke\"]>%n" + "not to end with:%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 72 with TextDescription

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

the class ShouldHaveSameHashCode_create_Test method should_create_error_message.

@Test
public void should_create_error_message() {
    // GIVEN
    Object actual = new FixedHashCode(123);
    Object expected = new FixedHashCode(456);
    // WHEN
    String message = shouldHaveSameHashCode(actual, expected).create(new TextDescription("Test"), STANDARD_REPRESENTATION);
    // THEN
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + "  <FixedHashCode[code=123]>%n" + "to have the same hash code as:%n" + "  <FixedHashCode[code=456]>%n" + "but actual hash code is%n" + "  <123>%n" + "while expected hash code was:%n" + "  <456>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) Test(org.junit.Test)

Example 73 with TextDescription

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

the class ShouldHaveSameHourAs_create_Test method should_create_error_message_localtime.

@Test
public void should_create_error_message_localtime() {
    factory = shouldHaveSameHourAs(LocalTime.of(12, 0), LocalTime.of(13, 0));
    assertThat(factory.create(new TextDescription("Test"), new StandardRepresentation())).isEqualTo(format("[Test] %nExpecting:%n  <12:00>%nto have same hour as:%n  <13:00>%nbut had not."));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 74 with TextDescription

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

the class ShouldHaveSameHourAs_create_Test method should_create_error_message_offset.

@Test
public void should_create_error_message_offset() {
    factory = shouldHaveSameHourAs(OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC), OffsetTime.of(13, 0, 0, 0, ZoneOffset.UTC));
    assertThat(factory.create(new TextDescription("Test"), new StandardRepresentation())).isEqualTo(format("[Test] %nExpecting:%n  <12:00Z>%nto have same hour as:%n  <13:00Z>%nbut had not."));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 75 with TextDescription

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

the class ShouldHaveSameTime_create_Test method should_create_error_message.

@Test
public void should_create_error_message() {
    Date actual = DateUtil.parseDatetime("2011-01-01T05:01:00");
    Date expected = DateUtil.parseDatetime("2011-01-01T05:01:01");
    String message = shouldHaveSameTime(actual, expected).create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + "  <2011-01-01T05:01:00.000>%n" + "to have the same time as:%n" + "  <2011-01-01T05:01:01.000>%n" + "but actual time is%n" + "  <" + actual.getTime() + "L>%n" + "and expected was:%n" + "  <" + expected.getTime() + "L>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Date(java.util.Date) 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