Skip to content

Commit

Permalink
Formatting + comment
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-costigliola committed Jan 2, 2018
1 parent 3f169d9 commit c8bdb25
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 63 deletions.
Expand Up @@ -80,86 +80,86 @@ public String toString() {
@Test
public void iterable_assertions_with_specific_comparator_by_element_field_or_type_examples() {

Dude dude = new Dude("Frodo", 1.2);
Dude tallerDude = new Dude("Frodo", 1.3);
Dude dude = new Dude("Frodo", 1.2);
Dude tallerDude = new Dude("Frodo", 1.3);

Comparator<Double> closeEnough = new AtPrecisionComparator<>(0.5);
Comparator<Double> closeEnough = new AtPrecisionComparator<>(0.5);

Dude[] hobbits = new Dude[] { dude };
Dude[] hobbits = new Dude[] { dude };

// assertions will pass
assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingFieldByFieldElementComparator()
.contains(tallerDude);
// assertions will pass
assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingFieldByFieldElementComparator()
.contains(tallerDude);

assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingElementComparatorOnFields("height")
.contains(tallerDude);
assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingElementComparatorOnFields("height")
.contains(tallerDude);

assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingElementComparatorIgnoringFields("name")
.contains(tallerDude);
assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingElementComparatorIgnoringFields("name")
.contains(tallerDude);

assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingRecursiveFieldByFieldElementComparator()
.contains(tallerDude);
assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingRecursiveFieldByFieldElementComparator()
.contains(tallerDude);

assertThat(asList(dude)).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingFieldByFieldElementComparator()
.contains(tallerDude);
assertThat(asList(dude)).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingFieldByFieldElementComparator()
.contains(tallerDude);

assertThat(asList(dude)).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingElementComparatorOnFields("height")
.contains(tallerDude);
assertThat(asList(dude)).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingElementComparatorOnFields("height")
.contains(tallerDude);

assertThat(asList(dude)).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingElementComparatorIgnoringFields("name")
.contains(tallerDude);
assertThat(asList(dude)).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingElementComparatorIgnoringFields("name")
.contains(tallerDude);

assertThat(asList(dude)).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingRecursiveFieldByFieldElementComparator()
.contains(tallerDude);
assertThat(asList(dude)).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingRecursiveFieldByFieldElementComparator()
.contains(tallerDude);

assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingFieldByFieldElementComparator()
.contains(tallerDude);
assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingFieldByFieldElementComparator()
.contains(tallerDude);

assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingElementComparatorOnFields("height")
.contains(tallerDude);
assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingElementComparatorOnFields("height")
.contains(tallerDude);

assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingElementComparatorIgnoringFields("name")
.contains(tallerDude);
assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingElementComparatorIgnoringFields("name")
.contains(tallerDude);

assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingRecursiveFieldByFieldElementComparator()
.contains(tallerDude);
assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingRecursiveFieldByFieldElementComparator()
.contains(tallerDude);

assertThat(asList(dude)).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingFieldByFieldElementComparator()
.contains(tallerDude);
assertThat(asList(dude)).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingFieldByFieldElementComparator()
.contains(tallerDude);

assertThat(asList(dude)).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingElementComparatorOnFields("height")
.contains(tallerDude);
assertThat(asList(dude)).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingElementComparatorOnFields("height")
.contains(tallerDude);

assertThat(asList(dude)).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingElementComparatorIgnoringFields("name")
.contains(tallerDude);
assertThat(asList(dude)).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingElementComparatorIgnoringFields("name")
.contains(tallerDude);

assertThat(asList(dude)).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingRecursiveFieldByFieldElementComparator()
.contains(tallerDude);
assertThat(asList(dude)).usingComparatorForElementFieldsWithType(closeEnough, Double.class)
.usingRecursiveFieldByFieldElementComparator()
.contains(tallerDude);

Dude reallyTallDude = new Dude("Frodo", 1.9);
try {
assertThat(asList(dude)).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingFieldByFieldElementComparator()
.contains(reallyTallDude);
} catch (AssertionError e) {
logAssertionErrorMessage("contains for Iterable usingComparatorForElementFieldsWithNames", e);
}
Dude reallyTallDude = new Dude("Frodo", 1.9);
try {
assertThat(asList(dude)).usingComparatorForElementFieldsWithNames(closeEnough, "height")
.usingFieldByFieldElementComparator()
.contains(reallyTallDude);
} catch (AssertionError e) {
logAssertionErrorMessage("contains for Iterable usingComparatorForElementFieldsWithNames", e);
}
}

@Test
Expand Down
Expand Up @@ -22,13 +22,13 @@ public class UseRegisteredRepresentationExample extends AbstractAssertionsExampl
@Test
public void should_use_given_representation_in_assertion_error_messages() {

//

Example example = new Example();
// this assertion fails with error : "expected:<[null]> but was:<[Example]>"
try {
assertThat(example).isNull(); // example is not null !
} catch (AssertionError e1) {
// example is represented with MyRepresentation that was registered as a service in
// src/test/resources/META-INF/services/org.assertj.core.presentation.Representation
assertThat(e1).hasMessageContaining("EXAMPLE");
}
}
Expand Down

0 comments on commit c8bdb25

Please sign in to comment.