Package org.assertj.core.description

Examples of org.assertj.core.description.TextDescription


public class ShouldNotContainString_create_Test {

  @Test
  public void should_create_error_message() {
    ErrorMessageFactory factory = shouldNotContain("Yoda", "od");
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nnot to contain:\n <\"od\"> ", message);
  }
View Full Code Here


  @Test
  public void should_create_error_message_with_custom_comparison_strategy() {
    ErrorMessageFactory factory = shouldNotContain("Yoda", "od", new ComparatorBasedComparisonStrategy(
        CaseInsensitiveStringComparator.instance));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nnot to contain:\n <\"od\"> when comparing values using 'CaseInsensitiveStringComparator'",
        message);
  }
View Full Code Here

  @Test
  public void should_create_error_message() {
    ErrorMessageFactory factory = shouldBeAtIndex(newArrayList("Yoda", "Luke"), new TestCondition<String>("red lightsaber"), atIndex(1),
        "Luke");
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \nExpecting:\n <\"Luke\">\nat index <1> to be:\n <red lightsaber>\nin:\n <[\"Yoda\", \"Luke\"]>\n", message);
  }
View Full Code Here

  @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());
    assertEquals("[Test] \nExpecting:\n <{\"name\"=\"Yoda\", \"color\"=\"green\"}>\nnot to contain key:\n <\"age\">", message);
  }
View Full Code Here

  public void should_create_error_message() {
    String[] sequenceValues = { "{", "author", "title", "}" };
    String actual = "{ 'title':'A Game of Thrones', 'author':'George Martin'}";

    factory = shouldContainSequence(actual, sequenceValues, 1);
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \nExpecting:\n <\"" + actual + "\">\n"
        + "to contain the following CharSequences in this order:\n"
        + " <[\"{\", \"author\", \"title\", \"}\"]>\n"
        + "but <\"title\"> was found before <\"author\">\n", message);
  }
View Full Code Here

    String[] sequenceValues = { "{", "author", "title", "}" };
    String actual = "{ 'title':'A Game of Thrones', 'author':'George Martin'}";

    factory = shouldContainSequence(actual, sequenceValues, 1,
                                    new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \nExpecting:\n <\"" + actual + "\">\n"
        + "to contain the following CharSequences in this order:\n"
        + " <[\"{\", \"author\", \"title\", \"}\"]>\n"
        + "but <\"title\"> was found before <\"author\">\n"
        + "when comparing values using 'CaseInsensitiveStringComparator'", message);
View Full Code Here

    factory = elementsShouldHaveAtLeast(newArrayList("Yoda", "Solo", "Leia"), 2, new TestCondition<String>("Jedi power"));
  }

  @Test
  public void should_create_error_message() {
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \nExpecting elements:\n<[\"Yoda\", \"Solo\", \"Leia\"]>\n to have at least 2 times <Jedi power>", message);
  }
View Full Code Here

  factory = shouldBeLess(8, 6);
  }

  @Test
  public void should_create_error_message() {
  String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
  assertThat(message).isEqualTo("[Test] \n" +
                                "Expecting:\n" +
                                " <8>\n" +
                                "to be less than:\n" +
                                " <6> ");
View Full Code Here

  }

  @Test
  public void should_create_error_message_with_custom_comparison_strategy() {
  factory = shouldBeLess(8, 6, new ComparatorBasedComparisonStrategy(new AbsValueComparator<Integer>()));
  String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
  assertThat(message).isEqualTo("[Test] \n" +
                                "Expecting:\n" +
                                " <8>\n" +
                                "to be less than:\n" +
                                " <6> when comparing values using 'AbsValueComparator'");
View Full Code Here

  public void should_create_error_message_with_all_fields_differences() {
    factory = shouldBeEqualToIgnoringGivenFields(new Jedi("Yoda", "blue"), newArrayList("name", "lightSaberColor"),
                                                 newArrayList((Object) "Yoda", "blue"),
                                                 newArrayList((Object) "Yoda", "green"),
                                                 newArrayList("someIgnoredField"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo("[Test] \n" +
                                  "Expecting values:\n" +
                                  "  <[\"Yoda\", \"green\"]>\n" +
                                  "in fields:\n" +
                                  "  <[\"name\", \"lightSaberColor\"]>\n" +
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.