Package org.assertj.core.description

Examples of org.assertj.core.description.TextDescription


    factory = shouldBeSubsetOf(newArrayList("Yoda", "Luke"), newArrayList("Han", "Luke"), newArrayList("Yoda"));
  }

  @Test
  public void should_create_error_message() {
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals(
        "[Test] \nExpecting :\n <[\"Yoda\", \"Luke\"]>\nto be subset of\n <[\"Han\", \"Luke\"]>\nbut found those extra elements:\n <[\"Yoda\"]>",
        message);
  }
View Full Code Here


  @Test
  public void should_create_error_message_with_custom_comparison_strategy() {
    ErrorMessageFactory factory = shouldBeSubsetOf(newArrayList("Yoda", "Luke"), newArrayList("Han", "Luke"),
        newArrayList("Yoda"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals(
        "[Test] \nExpecting when comparing values using 'CaseInsensitiveStringComparator':\n <[\"Yoda\", \"Luke\"]>\nto be subset of\n <[\"Han\", \"Luke\"]>\nbut found those extra elements:\n <[\"Yoda\"]>",
        message);
  }
View Full Code Here

    factory = elementsShouldNotBe(newArrayList("Darth Vader", "Leia", "Yoda"), newArrayList("Yoda"), new TestCondition<String>("not a Jedi"));
  }

  @Test
  public void should_create_error_message() {
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \nExpecting elements:\n<[\"Yoda\"]>\n of \n<[\"Darth Vader\", \"Leia\", \"Yoda\"]>\n not to be <not a Jedi>",
        message);
  }
View Full Code Here

                                     newLinkedHashSet("Luke"), newLinkedHashSet("Han"));
  }

  @Test
  public void should_create_error_message() {
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \nExpecting:\n" +
        " <[\"Yoda\", \"Han\", \"Han\"]>\n" +
        "to contain only once:\n" +
        " <[\"Luke\", \"Yoda\"]>\n" +
        "but some elements were not found:\n" +
View Full Code Here

  @Test
  public void should_create_error_message_with_custom_comparison_strategy() {
    ErrorMessageFactory factory = shouldContainsOnlyOnce(newArrayList("Yoda", "Han"), newArrayList("Luke", "Yoda"),
                                                         newLinkedHashSet("Luke"), newLinkedHashSet("Han"), new ComparatorBasedComparisonStrategy(
                                                                                                                                                  CaseInsensitiveStringComparator.instance));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \n" +
        "Expecting:\n" +
        " <[\"Yoda\", \"Han\"]>\n" +
        "to contain only once:\n" +
        " <[\"Luke\", \"Yoda\"]>\n" +
View Full Code Here

  @Test
  public void should_create_error_message_without_not_found_elements() {
    factory = shouldContainsOnlyOnce(newArrayList("Yoda", "Han", "Han"), newArrayList("Yoda"), newLinkedHashSet(),
                                     newLinkedHashSet("Han"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \nExpecting:\n" +
        " <[\"Yoda\", \"Han\", \"Han\"]>\n" +
        "to contain only once:\n" +
        " <[\"Yoda\"]>\n" +
        "but some elements were found more than once:\n" +
View Full Code Here

  @Test
  public void should_create_error_message_without_elements_found_many_times() {
    factory = shouldContainsOnlyOnce(newArrayList("Yoda", "Han"), newArrayList("Luke"), newLinkedHashSet("Luke"),
                                     newLinkedHashSet());
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \nExpecting:\n" +
        " <[\"Yoda\", \"Han\"]>\n" +
        "to contain only once:\n" +
        " <[\"Luke\"]>\n" +
        "but some elements were not found:\n" +
View Full Code Here

public class ShouldHaveAtLeastOneElementOfType_create_Test {

  @Test
  public void should_create_error_message_for_iterable() {
  ErrorMessageFactory factory = shouldHaveAtLeastOneElementOfType(newArrayList("Yoda", "Luke"), Long.class);
  String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
  assertThat(message).isEqualTo("[Test] \n"
                                + "Expecting:\n"
                                + "  <[\"Yoda\", \"Luke\"]>\n"
                                + "to have at least one element of type:\n"
                                + "  <java.lang.Long>\n"
View Full Code Here

  }

  @Test
  public void should_create_error_message_for_array() {
  ErrorMessageFactory factory = shouldHaveAtLeastOneElementOfType(array("Yoda", "Luke"), Long.class);
  String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
  assertThat(message).isEqualTo("[Test] \n"
                                + "Expecting:\n"
                                + "  <[\"Yoda\", \"Luke\"]>\n"
                                + "to have at least one element of type:\n"
                                + "  <java.lang.Long>\n"
View Full Code Here

  @Test
  public void should_create_error_message() {
    Map<?, ?> map = mapOf(entry("name", "Yoda"), entry("color", "green"));
    ErrorMessageFactory factory = shouldContainKeys(map, newLinkedHashSet("name"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo("[Test] \nExpecting:\n <{\"name\"=\"Yoda\", \"color\"=\"green\"}>\nto contain key:\n <\"name\">");
  }
View Full Code Here

TOP

Related Classes of org.assertj.core.description.TextDescription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.