Search in sources :

Example 1 with Description

use of org.assertj.core.description.Description in project gwt-test-utils by gwt-test-utils.

the class GwtGenericAssert method propertyComparisonFailed.

/**
     * Returns a <code>{@link AssertionError}</code> describing a property comparison failure. A
     * default description is set if the default error message is not overrided and a custom
     * description is not applied. In both case, the resulting description would be prefixed by the
     * message eventually supplied through {@link GwtGenericAssert#withPrefix(String)}.
     *
     * @param propertyName the compared property name
     * @param actual       the actual value.
     * @param expected     the expected value.
     * @return a {@code AssertionError} describing the comparison failure.
     */
protected AssertionError propertyComparisonFailed(String propertyName, Object actual, Object expected) {
    GwtWritableAssertionInfo info = new GwtWritableAssertionInfo();
    info.prefix(gwtInfo.prefix());
    info.overridingErrorMessage(gwtInfo.overridingErrorMessage());
    Description d = gwtInfo.superDescription();
    String newDescription = d != null ? d.value() + " " + propertyName : this.actual.getClass().getSimpleName() + "'s " + propertyName;
    info.description(newDescription);
    return failures.failure(info, shouldBeEqual(actual, expected, new StandardRepresentation()));
}
Also used : Description(org.assertj.core.description.Description) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation)

Example 2 with Description

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

the class Failures_failure_with_ErrorMessage_Test method should_use_ErrorMessage_when_overriding_error_message_is_not_specified.

@Test
public void should_use_ErrorMessage_when_overriding_error_message_is_not_specified() {
    Description description = new TestDescription("description");
    info.description(description);
    when(errorMessage.create(description, info.representation())).thenReturn("[description] my message");
    AssertionError failure = failures.failure(info, errorMessage);
    assertThat(failure).hasMessage("[description] my message");
}
Also used : Description(org.assertj.core.description.Description) TestDescription(org.assertj.core.internal.TestDescription) TestDescription(org.assertj.core.internal.TestDescription) Test(org.junit.Test)

Example 3 with Description

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

the class SetAssert_raw_set_assertions_chained_after_superclass_method_Test method raw_set_assertions_mixed_with_inherited_methods.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Ignore
@Test
public void raw_set_assertions_mixed_with_inherited_methods() {
    Description description = emptyDescription();
    Set set = new java.util.HashSet<>();
    set.add("Key1");
    set.add("Key2");
    assertThat(set).as("desc").containsOnly("Key1", "Key2");
    // try all base assertions followed by set specific ones using generics
    assertThat(set).as("desc").usingDefaultComparator().as(description).describedAs(description).describedAs("describedAs").has(null).hasSameClassAs(set).hasToString(set.toString()).is(null).isEqualTo(set).isExactlyInstanceOf(Map.class).isIn(new HashSet<>()).isIn(Map.class).isInstanceOf(Map.class).isInstanceOfAny(Map.class, String.class).isNot(null).isNotEqualTo(null).isNotEmpty().isNotExactlyInstanceOf(String.class).isNotIn(new HashSet<>()).isNotIn(Map.class).isNotInstanceOf(Map.class).isNotInstanceOfAny(Map.class, String.class).isNotNull().isNotOfAnyClassIn(Map.class, String.class).isNotSameAs(null).isOfAnyClassIn(Map.class, String.class).isSameAs("").overridingErrorMessage("").withFailMessage("").withThreadDumpOnError().usingDefaultComparator().contains("Key1", atIndex(0));
}
Also used : Description(org.assertj.core.description.Description) EmptyTextDescription.emptyDescription(org.assertj.core.description.EmptyTextDescription.emptyDescription) HashSet(java.util.HashSet) Set(java.util.Set) Map(java.util.Map) HashSet(java.util.HashSet) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with Description

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

the class ListAssert_raw_list_assertions_chained_after_superclass_method_Test method raw_list_assertions_mixed_with_inherited_methods.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Ignore
@Test
public void raw_list_assertions_mixed_with_inherited_methods() {
    Description description = emptyDescription();
    List list = new java.util.ArrayList<>();
    list.add("Key1");
    list.add("Key2");
    assertThat(list).as("desc").containsOnly("Key1", "Key2");
    // try all base assertions followed by list specific ones using generics
    assertThat(list).as("desc").usingDefaultComparator().isSorted().as(description).isSorted().describedAs(description).describedAs("describedAs").has(null).hasSameClassAs(list).hasToString(list.toString()).is(null).isEqualTo(list).isExactlyInstanceOf(Map.class).isIn(new ArrayList<>()).isIn(Map.class).isInstanceOf(Map.class).isInstanceOfAny(Map.class, String.class).isNot(null).isNotEqualTo(null).isNotEmpty().isNotExactlyInstanceOf(String.class).isNotIn(new ArrayList<>()).isNotIn(Map.class).isNotInstanceOf(Map.class).isNotInstanceOfAny(Map.class, String.class).isNotNull().isNotOfAnyClassIn(Map.class, String.class).isNotSameAs(null).isOfAnyClassIn(Map.class, String.class).isSameAs("").overridingErrorMessage("").withFailMessage("").withThreadDumpOnError().usingDefaultComparator().contains("Key1", atIndex(0));
}
Also used : Description(org.assertj.core.description.Description) EmptyTextDescription.emptyDescription(org.assertj.core.description.EmptyTextDescription.emptyDescription) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with Description

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

the class WritableAssertionInfo_descriptionText_Test method should_return_text_of_description.

@Test
public void should_return_text_of_description() {
    Description description = mock(Description.class);
    info.description(description);
    when(description.value()).thenReturn("Yoda");
    assertThat(info.descriptionText()).isEqualTo("Yoda");
}
Also used : Description(org.assertj.core.description.Description) Test(org.junit.Test)

Aggregations

Description (org.assertj.core.description.Description)19 Test (org.junit.Test)13 EmptyTextDescription.emptyDescription (org.assertj.core.description.EmptyTextDescription.emptyDescription)6 TestDescription (org.assertj.core.internal.TestDescription)5 TextDescription (org.assertj.core.description.TextDescription)4 Map (java.util.Map)3 Ignore (org.junit.Ignore)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 StandardRepresentation (org.assertj.core.presentation.StandardRepresentation)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 List (java.util.List)1 Set (java.util.Set)1 BasicErrorMessageFactory (org.assertj.core.error.BasicErrorMessageFactory)1 Representation (org.assertj.core.presentation.Representation)1 TestData.someDescription (org.assertj.core.test.TestData.someDescription)1 AfterAll (org.junit.jupiter.api.AfterAll)1 DependencyResolver (org.neo4j.common.DependencyResolver)1 Config (org.neo4j.configuration.Config)1 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)1