use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.
the class ShouldBeEqual_newAssertionError_differentiating_expected_and_actual_Test method should_create_AssertionError_with_message_differentiating_expected_and_actual_persons.
@Test
public void should_create_AssertionError_with_message_differentiating_expected_and_actual_persons() {
Person actual = new Person("Jake", 43);
Person expected = new Person("Jake", 47);
shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected, new StandardRepresentation());
shouldBeEqual.descriptionFormatter = mock(DescriptionFormatter.class);
when(shouldBeEqual.descriptionFormatter.format(description)).thenReturn(formattedDescription);
AssertionError error = shouldBeEqual.newAssertionError(description, new StandardRepresentation());
assertThat(error).isInstanceOf(AssertionFailedError.class).hasMessage("[my test] %n" + "Expecting:%n" + " <\"Person[name=Jake] (Person@%s)\">%n" + "to be equal to:%n" + " <\"Person[name=Jake] (Person@%s)\">%n" + "but was not.", toHexString(actual.hashCode()), toHexString(expected.hashCode()));
}
use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.
the class ShouldBeEqual_newAssertionError_without_JUnit_Test method should_create_AssertionFailedError_if_created_ComparisonFailure_is_null.
@Test
public void should_create_AssertionFailedError_if_created_ComparisonFailure_is_null() throws Exception {
when(createComparisonFailure()).thenReturn(null);
AssertionError error = factory.newAssertionError(description, new StandardRepresentation());
check(error);
}
use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.
the class ShouldBeEqual_newAssertionError_without_JUnit_Test method setUp.
@Before
public void setUp() {
Failures.instance().setRemoveAssertJRelatedElementsFromStackTrace(false);
description = new TestDescription("Jedi");
factory = (ShouldBeEqual) shouldBeEqual("Luke", "Yoda", new StandardRepresentation());
constructorInvoker = mock(ConstructorInvoker.class, withSettings().defaultAnswer(CALLS_REAL_METHODS));
factory.constructorInvoker = constructorInvoker;
}
use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.
the class ShouldBeEqual_newAssertionError_without_JUnit_Test method should_create_AssertionFailedError_if_error_is_thrown_when_creating_ComparisonFailure.
@Test
public void should_create_AssertionFailedError_if_error_is_thrown_when_creating_ComparisonFailure() throws Exception {
when(createComparisonFailure()).thenThrow(new AssertionError("Thrown on purpose"));
AssertionError error = factory.newAssertionError(description, new StandardRepresentation());
check(error);
}
use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.
the class ShouldBeEqual_newAssertionError_without_JUnit_and_OTA4J_Test method setUp.
@Before
public void setUp() {
Failures.instance().setRemoveAssertJRelatedElementsFromStackTrace(false);
description = new TestDescription("Jedi");
factory = (ShouldBeEqual) shouldBeEqual("Luke", "Yoda", new StandardRepresentation());
constructorInvoker = mock(ConstructorInvoker.class);
factory.constructorInvoker = constructorInvoker;
}
Aggregations