use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldOnlyHaveFields_create_Test method should_not_display_fields_not_found_when_there_are_none_for_declared_fields.
@Test
public void should_not_display_fields_not_found_when_there_are_none_for_declared_fields() {
ErrorMessageFactory factory = shouldOnlyHaveDeclaredFields(Player.class, newLinkedHashSet("name", "team"), EMPTY_STRING_SET, newLinkedHashSet("address"));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting%n" + " <org.assertj.core.test.Player>%n" + "to only have the following declared fields:%n" + " <[\"name\", \"team\"]>%n" + "but the following fields were unexpected:%n" + " <[\"address\"]>"));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldOnlyHaveFields_create_Test method should_not_display_unexpected_fields_when_there_are_none_for_declared_fields.
@Test
public void should_not_display_unexpected_fields_when_there_are_none_for_declared_fields() {
ErrorMessageFactory factory = shouldOnlyHaveDeclaredFields(Player.class, newLinkedHashSet("name", "team"), newLinkedHashSet("nickname"), EMPTY_STRING_SET);
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + " <org.assertj.core.test.Player>%n" + "to only have the following declared fields:%n" + " <[\"name\", \"team\"]>%n" + "but could not find the following fields:%n" + " <[\"nickname\"]>"));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldOnlyHaveFields_create_Test method should_create_error_message_for_fields.
@Test
public void should_create_error_message_for_fields() {
ErrorMessageFactory factory = shouldOnlyHaveFields(Player.class, newLinkedHashSet("name", "team"), newLinkedHashSet("nickname"), newLinkedHashSet("address"));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + " <org.assertj.core.test.Player>%n" + "to only have the following public accessible fields:%n" + " <[\"name\", \"team\"]>%n" + "fields not found:%n" + " <[\"nickname\"]>%n" + "and fields not expected:%n" + " <[\"address\"]>"));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldOnlyHaveFields_create_Test method should_create_error_message_for_declared_fields.
@Test
public void should_create_error_message_for_declared_fields() {
ErrorMessageFactory factory = shouldOnlyHaveDeclaredFields(Player.class, newLinkedHashSet("name", "team"), newLinkedHashSet("nickname"), newLinkedHashSet("address"));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + " <org.assertj.core.test.Player>%n" + "to only have the following declared fields:%n" + " <[\"name\", \"team\"]>%n" + "fields not found:%n" + " <[\"nickname\"]>%n" + "and fields not expected:%n" + " <[\"address\"]>"));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldNotContainKey_create_Test method should_create_error_message.
@Test
public void should_create_error_message() {
Map<?, ?> map = mapOf(entry("name", "Yoda"), entry("color", "green"));
ErrorMessageFactory factory = shouldNotContainKey(map, "age");
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting:%n" + " <{\"color\"=\"green\", \"name\"=\"Yoda\"}>%n" + "not to contain key:%n" + " <\"age\">"));
}
Aggregations