Search in sources :

Example 31 with TextDescription

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

the class ShouldContainKey_create_Test method should_create_error_message_with_key_condition.

@Test
public void should_create_error_message_with_key_condition() {
    Map<?, ?> map = mapOf(entry("name", "Yoda"), entry("color", "green"));
    ErrorMessageFactory factory = shouldContainKey(map, new TestCondition<>("test condition"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + "  <{\"color\"=\"green\", \"name\"=\"Yoda\"}>%n" + "to contain a key satisfying:%n" + "  <test condition>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 32 with TextDescription

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

the class ShouldContainOnlyDigits_create_Test method should_create_error_message_for_empty_string.

@Test
public void should_create_error_message_for_empty_string() {
    factory = shouldContainOnlyDigits("");
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting:%n" + "  <\"\">%n" + "to contain only digits%n" + "but could not found any digits at all"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 33 with TextDescription

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

the class ShouldContainOnlyKeys_create_Test method should_create_error_message.

@Test
public void should_create_error_message() {
    ErrorMessageFactory factory = shouldContainOnlyKeys(mapOf(entry("name", "Yoda"), entry("color", "green")), newArrayList("jedi", "color"), newLinkedHashSet("jedi"), newLinkedHashSet("name"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting:%n" + "  <{\"color\"=\"green\", \"name\"=\"Yoda\"}>%n" + "to contain only following keys:%n" + "  <[\"jedi\", \"color\"]>%n" + "keys not found:%n" + "  <[\"jedi\"]>%n" + "and keys not expected:%n" + "  <[\"name\"]>%n"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 34 with TextDescription

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

the class ShouldContainOnlyKeys_create_Test method should_not_display_unexpected_elements_when_there_are_none.

@Test
public void should_not_display_unexpected_elements_when_there_are_none() {
    ErrorMessageFactory factory = shouldContainOnlyKeys(mapOf(entry("color", "green")), newArrayList("jedi", "color"), newLinkedHashSet("jedi"), Collections.emptySet());
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting:%n" + "  <{\"color\"=\"green\"}>%n" + "to contain only following keys:%n" + "  <[\"jedi\", \"color\"]>%n" + "but could not find the following keys:%n" + "  <[\"jedi\"]>%n"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 35 with TextDescription

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

the class ShouldContainOnlyNulls_create_Test method should_create_error_message_with_no_any_element.

@Test
public void should_create_error_message_with_no_any_element() {
    ErrorMessageFactory factory = shouldContainOnlyNulls(newArrayList());
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + "  <[]>%n" + "to contain only null elements but it was empty"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) 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