Package org.assertj.core.presentation

Examples of org.assertj.core.presentation.StandardRepresentation


  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

  @Test
  public void should_create_error_message_with_single_field_difference() {
    factory = shouldBeEqualToIgnoringGivenFields(new Jedi("Yoda", "blue"), newArrayList("lightSaberColor"),
                                                 newArrayList((Object) "blue"), newArrayList((Object) "green"),
                                                 newArrayList("someIgnoredField"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo("[Test] \n" +
                                  "Expecting value <\"green\"> in field <\"lightSaberColor\"> " +
                                  "but was <\"blue\"> in <Yoda the Jedi>.\n" +
                                  "Comparison was performed on all fields but <[\"someIgnoredField\"]>");
  }
View Full Code Here

  public void should_create_error_message_with_all_fields_differences_without_ignored_fields() {
    List<String> ignoredFields = newArrayList();
    factory = shouldBeEqualToIgnoringGivenFields(new Jedi("Yoda", "blue"), newArrayList("name", "lightSaberColor"),
                                                 newArrayList((Object) "Yoda", "blue"),
                                                 newArrayList((Object) "Yoda", "green"), ignoredFields);
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo("[Test] \nExpecting values:\n" +
                                  "  <[\"Yoda\", \"green\"]>\n" +
                                  "in fields:\n" +
                                  "  <[\"name\", \"lightSaberColor\"]>\n" +
                                  "but were:\n" +
View Full Code Here

  public void should_create_error_message_with_single_field_difference_without_ignored_fields() {
    List<String> ignoredFields = newArrayList();
    factory = shouldBeEqualToIgnoringGivenFields(new Jedi("Yoda", "blue"), newArrayList("lightSaberColor"),
                                                 newArrayList((Object) "blue"), newArrayList((Object) "green"),
                                                 ignoredFields);
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo("[Test] \nExpecting value <\"green\"> " +
                                  "in field <\"lightSaberColor\"> " +
                                  "but was <\"blue\"> in <Yoda the Jedi>.\n" +
                                  "Comparison was performed on all fields");
  }
View Full Code Here

  private ErrorMessageFactory factory;

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

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

  }

  @Test
  public void should_create_error_message_when_ignoring_case() {
    factory = shouldContainIgnoringCase("Yoda", "Luke");
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nto contain:\n <\"Luke\">\n (ignoring case)", message);
  }
View Full Code Here

  }

  @Test
  public void should_create_error_message_with_several_string_values() {
    factory = shouldContain("Yoda, Luke", array("Luke", "Vador", "Solo"), newSet("Vador", "Solo"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertEquals("[Test] \nExpecting:\n <\"Yoda, Luke\">\nto contain:\n <[\"Luke\", \"Vador\", \"Solo\"]>\nbut could not find:\n <[\"Vador\", \"Solo\"]>\n ",
                 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.