Search in sources :

Example 96 with StandardRepresentation

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

the class ShouldHaveSameSizeAs_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(String.format("[Test] %n" + "Actual and expected should have same size but actual size is:%n" + " <2>%n" + "while expected is:%n" + " <4>%n" + "Actual was:%n" + "<['a', 'b']>"));
}
Also used : StandardRepresentation(org.assertj.core.presentation.StandardRepresentation)

Example 97 with StandardRepresentation

use of org.assertj.core.presentation.StandardRepresentation 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)

Example 98 with StandardRepresentation

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

the class ShouldHaveSize_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(String.format("[Test] %nExpected size:<2> but was:<4> in:%n<['a', 'b']>"));
}
Also used : StandardRepresentation(org.assertj.core.presentation.StandardRepresentation)

Example 99 with StandardRepresentation

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

the class ShouldHaveTime_create_Test method should_create_error_message.

@Test
public void should_create_error_message() {
    Date date = DateUtil.parseDatetime("2011-01-01T05:01:00");
    String message = shouldHaveTime(date, 123).create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + " <2011-01-01T05:01:00.000>%n" + "to have time:%n" + " <123L>%n" + "but was:%n" + " <" + date.getTime() + "L>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Date(java.util.Date) Test(org.junit.Test)

Example 100 with StandardRepresentation

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

the class ShouldMatchPattern_create_Test method should_create_error_message_escaping_percent.

@Test
public void should_create_error_message_escaping_percent() {
    factory = shouldMatch("%%E", "fffff");
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %nExpecting:%n \"%%%%E\"%nto match pattern:%n \"fffff\""));
}
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