Package org.assertj.core.presentation

Examples of org.assertj.core.presentation.StandardRepresentation


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


        newLinkedHashSet("Han"));
  }

  @Test
  public void should_create_error_message() {
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals(
        "[Test] \nExpecting:\n <[\"Yoda\", \"Han\"]>\nto contain exactly (and in same order):\n"
            + " <[\"Luke\", \"Yoda\"]>\nbut some elements were not found:\n <[\"Luke\"]>\nand others were not expected:\n <[\"Han\"]>\n",
        message);
  }
View Full Code Here

  @Test
  public void should_create_error_message_with_custom_comparison_strategy() {
    ErrorMessageFactory factory = shouldContainExactly(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] \nExpecting:\n <[\"Yoda\", \"Han\"]>\nto contain exactly (and in same order):\n"
        + " <[\"Luke\", \"Yoda\"]>\nbut some elements were not found:\n <[\"Luke\"]>\nand others were not expected:\n"
        + " <[\"Han\"]>\nwhen comparing values using 'CaseInsensitiveStringComparator'", message);
  }
View Full Code Here

  }

  @Test
  public void should_create_error_message_when_only_elements_order_differs() {
    factory = shouldContainExactly("Luke", "Han", 1);
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals(
        "[Test] \nActual and expected have the same elements but not in the same order, at index 1 actual element was:\n"
            + " <\"Luke\">\nwhereas expected element was:\n <\"Han\">\n", message);
  }
View Full Code Here

  @Test
  public void should_create_error_message_when_only_elements_order_differs_according_to_custom_comparison_strategy() {
    factory = shouldContainExactly("Luke", "Han", 1, new ComparatorBasedComparisonStrategy(
        CaseInsensitiveStringComparator.instance));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals(
        "[Test] \nActual and expected have the same elements but not in the same order, at index 1 actual element was:\n"
            + " <\"Luke\">\nwhereas expected element was:\n <\"Han\">\nwhen comparing values using 'CaseInsensitiveStringComparator'",
        message);
  }
View Full Code Here

  @Test
  public void should_create_error_message() throws ParseException {
    ErrorMessageFactory factory = shouldBeInSameMinuteWindow(parseDatetime("2011-01-01T05:00:00"),
                                                             parseDatetime("2011-01-01T05:02:01"));

    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo("[Test] \nExpecting:\n  <2011-01-01T05:00:00>\nto be close to:\n  " +
                                    "<2011-01-01T05:02:01>\n" +
                                    "by less than one minute (strictly) but difference was: 2m and 1s");
  }
View Full Code Here

  factory = shouldBeGreaterOrEqual(6, 8);
  }

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

  }

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

    factory = shouldNotHave("Yoda", new TestCondition<String>("red lightsaber"));
  }

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

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

  @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 be exactly 2 times <a Jedi>", message);
  }
View Full Code Here

TOP

Related Classes of org.assertj.core.presentation.StandardRepresentation

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.