Search in sources :

Example 6 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 7 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)

Example 8 with Description

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

the class MapAssert_raw_map_assertions_chained_after_base_assertions_Test method raw_map_mixing_assertions_from_AbstractAssert_and_AbstractMapAssert.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Ignore
@Test
public void raw_map_mixing_assertions_from_AbstractAssert_and_AbstractMapAssert() {
    Description description = emptyDescription();
    Map map1 = new java.util.HashMap();
    map1.put("Key1", "Value1");
    map1.put("Key2", "Value2");
    // try all base assertions followed by map specific ones using generics
    assertThat(map1).as("desc").containsOnlyKeys("Key1", "Key2").as(description).containsOnlyKeys("Key1", "Key2").describedAs(description).describedAs("describedAs").has(null).hasSameClassAs(map1).hasToString(map1.toString()).is(null).isEqualTo(map1).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().containsOnlyKeys("Key1", "Key2");
}
Also used : Description(org.assertj.core.description.Description) EmptyTextDescription.emptyDescription(org.assertj.core.description.EmptyTextDescription.emptyDescription) ArrayList(java.util.ArrayList) Map(java.util.Map) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with Description

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

the class BasicErrorMessageFactory_create_Test method should_create_error_with_empty_description_and_configured_representation.

@Test
public void should_create_error_with_empty_description_and_configured_representation() {
    Description description = emptyDescription();
    String formattedMessage = "[] Hello Yoda";
    when(formatter.format(eq(description), same(CONFIGURATION_PROVIDER.representation()), eq("Hello %s"), eq("Yoda"))).thenReturn(formattedMessage);
    assertThat(factory.create()).isEqualTo(formattedMessage);
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) Description(org.assertj.core.description.Description) EmptyTextDescription.emptyDescription(org.assertj.core.description.EmptyTextDescription.emptyDescription) Test(org.junit.Test)

Example 10 with Description

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

the class BasicErrorMessageFactory_create_Test method should_implement_toString.

@Test
public void should_implement_toString() {
    Description description = new TestDescription("Test");
    Representation representation = new StandardRepresentation();
    String formattedMessage = "[Test] Hello Yoda";
    when(formatter.format(description, representation, "Hello %s", "Yoda")).thenReturn(formattedMessage);
    assertThat(factory.create(description, representation)).isEqualTo(formattedMessage);
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) Description(org.assertj.core.description.Description) EmptyTextDescription.emptyDescription(org.assertj.core.description.EmptyTextDescription.emptyDescription) TestDescription(org.assertj.core.internal.TestDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Representation(org.assertj.core.presentation.Representation) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Aggregations

Description (org.assertj.core.description.Description)16 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 StandardRepresentation (org.assertj.core.presentation.StandardRepresentation)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 HashSet (java.util.HashSet)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