Search in sources :

Example 46 with TextDescription

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

the class ShouldHaveFields_create_Test method should_create_error_message_for_fields.

@Test
public void should_create_error_message_for_fields() {
    ErrorMessageFactory factory = shouldHaveFields(Person.class, newLinkedHashSet("name", "address"), newLinkedHashSet("address"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting%n" + "  <org.assertj.core.test.Person>%n" + "to have the following public accessible fields:%n" + "  <[\"name\", \"address\"]>%n" + "but it doesn't have:%n" + "  <[\"address\"]>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 47 with TextDescription

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

the class ShouldHaveFields_create_Test method should_create_error_message_for_declared_fields.

@Test
public void should_create_error_message_for_declared_fields() {
    ErrorMessageFactory factory = shouldHaveDeclaredFields(Person.class, newLinkedHashSet("name", "address"), newLinkedHashSet("address"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting%n" + "  <org.assertj.core.test.Person>%n" + "to have the following declared fields:%n" + "  <[\"name\", \"address\"]>%n" + "but it doesn't have:%n" + "  <[\"address\"]>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 48 with TextDescription

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

the class ShouldHaveMethods_create_Test method should_create_error_message_for_shouldNotHave_Public_Methods.

@Test
public void should_create_error_message_for_shouldNotHave_Public_Methods() {
    ErrorMessageFactory factory = shouldNotHaveMethods(Person.class, Modifier.toString(Modifier.PUBLIC), false, newTreeSet("getName"));
    String message = factory.create(new TextDescription("Test"), CONFIGURATION_PROVIDER.representation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + "  <org.assertj.core.test.Person>%n" + "not to have any public methods but it has the following:%n" + "  <[\"getName\"]>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) Test(org.junit.Test)

Example 49 with TextDescription

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

the class ShouldHaveMethods_create_Test method should_create_error_message_for_shouldHaveMethods_with_non_matching_modifier.

@Test
public void should_create_error_message_for_shouldHaveMethods_with_non_matching_modifier() {
    ErrorMessageFactory factory = shouldHaveMethods(Person.class, false, newTreeSet("finalize"), Modifier.toString(Modifier.PUBLIC), mapOf(entry("finalize", Modifier.toString(Modifier.PROTECTED))));
    String message = factory.create(new TextDescription("Test"), CONFIGURATION_PROVIDER.representation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + "  <org.assertj.core.test.Person>%n" + "to have public methods:%n" + "  <[\"finalize\"]>%n" + "but the following are not public:%n" + "  <{\"finalize\"=\"protected\"}>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) Test(org.junit.Test)

Example 50 with TextDescription

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

the class ShouldHaveMethods_create_Test method should_create_error_message_for_methods.

@Test
public void should_create_error_message_for_methods() {
    ErrorMessageFactory factory = shouldHaveMethods(Person.class, false, newTreeSet("getName", "getAddress"), newTreeSet("getAddress"));
    String message = factory.create(new TextDescription("Test"), CONFIGURATION_PROVIDER.representation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + "  <org.assertj.core.test.Person>%n" + "to have methods:%n" + "  <[\"getAddress\", \"getName\"]>%n" + "but could not find:%n" + "  <[\"getAddress\"]>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) 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