Java 类org.assertj.core.api.SoftAssertionError 实例源码

项目:assertj-core    文件:BDDSoftAssertionsLineNumberTest.java   
@Test
public void should_print_line_numbers_of_failed_assertions() {
    BDDSoftAssertions softly = new BDDSoftAssertions();
  try {
    softly.then(1).isLessThan(0)
                  .isLessThan(1);
    softly.assertAll();
    fail("Should not reach here");
  } catch (SoftAssertionError e) {
    assertThat(e.getMessage()).contains(format("1) %n"
                                             + "Expecting:%n"
                                             + " <1>%n"
                                             + "to be less than:%n"
                                             + " <0> %n"
                                             + "at BDDSoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions(BDDSoftAssertionsLineNumberTest.java:34)%n"
                                             + "2) %n"
                                             + "Expecting:%n"
                                             + " <1>%n"
                                             + "to be less than:%n"
                                             + " <1> %n"
                                             + "at BDDSoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions(BDDSoftAssertionsLineNumberTest.java:35)"));
  }
}
项目:assertj-core    文件:AutoClosableSoftAssertionsLineNumberTest.java   
@Test
public void should_print_line_numbers_of_failed_assertions() {
  try {
    AutoCloseableSoftAssertions softly = new AutoCloseableSoftAssertions();
    softly.assertThat(1).isLessThan(0)
                        .isLessThan(1);
    softly.close();
    fail("Should not reach here");
  } catch (SoftAssertionError e) {
    assertThat(e.getMessage()).contains(format("1) %n"
                                             + "Expecting:%n"
                                             + " <1>%n"
                                             + "to be less than:%n"
                                             + " <0> %n"
                                             + "at AutoClosableSoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions(AutoClosableSoftAssertionsLineNumberTest.java:34)%n"
                                             + "2) %n"
                                             + "Expecting:%n"
                                             + " <1>%n"
                                             + "to be less than:%n"
                                             + " <1> %n"
                                             + "at AutoClosableSoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions(AutoClosableSoftAssertionsLineNumberTest.java:35)"));
  }
}
项目:assertj-core    文件:SoftAssertionsLineNumberTest.java   
@Test
public void should_print_line_numbers_of_failed_assertions() {
  SoftAssertions softly = new SoftAssertions();
  try {
    softly.assertThat(1).isLessThan(0)
          .isLessThan(1);
    softly.assertAll();
    fail("Should not reach here");
  } catch (SoftAssertionError e) {
    assertThat(e.getMessage()).contains(format("1) %n"
                                               + "Expecting:%n"
                                               + " <1>%n"
                                               + "to be less than:%n"
                                               + " <0> %n"
                                               + "at SoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions(SoftAssertionsLineNumberTest.java:37)%n"
                                               + "2) %n"
                                               + "Expecting:%n"
                                               + " <1>%n"
                                               + "to be less than:%n"
                                               + " <1> %n"
                                               + "at SoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions(SoftAssertionsLineNumberTest.java:38)"));
  }
}
项目:putput    文件:SoftAssertions.java   
/**
 * Verifies that no proxied assertion methods have failed.
 *
 * @throws SoftAssertionError if any proxied assertion objects threw
 */
public void assertAll() {
  List<Throwable> errors = collector.errors();
  if (!errors.isEmpty()) {
    throw new SoftAssertionError(extractProperty("message", String.class).from(errors));
  }
}
项目:parkandrideAPI    文件:AbstractReportingITest.java   
void checkSheetContents(Workbook workbook, int sheetIndex, List<String>... rows) {
    try (AutoCloseableSoftAssertions softly = new AutoCloseableSoftAssertions()) {
        checkSheetContents(softly, workbook, sheetIndex, rows);
    } catch (SoftAssertionError sae) {
        System.out.println("===========\nACTUAL\n===========");
        printSheet(workbook.getSheetAt(sheetIndex));
        System.out.println("===========\nEXPECTED\n===========");
        printSheet(asList(rows));
        throw sae;
    }
}
项目:uom-lib    文件:SoftAssertions.java   
/**
 * Verifies that no proxied assertion methods have failed.
 *
 * @throws SoftAssertionError if any proxied assertion objects threw
 */
public void assertAll() {
  List<Throwable> errors = collector.errors();
  if (!errors.isEmpty()) {
    throw new SoftAssertionError(extractProperty("message", String.class).from(errors));
  }
}
项目:assertj-core    文件:SoftAssertionsLineNumberTest.java   
@Test
public void should_print_line_numbers_of_failed_assertions_even_if_it_came_from_nested_calls() {
  SoftAssertions softly = new SoftAssertions();
  try {
    softly.assertThat(Optional.empty()).contains("Foo");
    // nested proxied call to isNotNull
    softly.assertThat((Predicate<String>) null).accepts("a", "b", "c");
    Predicate<String> lowercasePredicate = s -> s.equals(s.toLowerCase());
    // check line number
    softly.assertThat(lowercasePredicate).accepts("a", "b", "C");
    softly.assertAll();
    fail("Should not reach here");
  } catch (SoftAssertionError e) {
    assertThat(e.getMessage()).contains(format("1) %n"
                                               + "Expecting Optional to contain:%n"
                                               + "  <\"Foo\">%n"
                                               + "but was empty.%n"
                                               + "at SoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions_even_if_it_came_from_nested_calls(SoftAssertionsLineNumberTest.java:61)%n"
                                               + "2) %n"
                                               + "Expecting actual not to be null%n"
                                               + "at SoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions_even_if_it_came_from_nested_calls(SoftAssertionsLineNumberTest.java:63)%n"
                                               + "3) %n"
                                               + "Expecting all elements of:%n"
                                               + "  <[\"a\", \"b\", \"C\"]>%n"
                                               + "to match given predicate but this element did not:%n"
                                               + "  <\"C\">%n"
                                               + "at SoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions_even_if_it_came_from_nested_calls(SoftAssertionsLineNumberTest.java:66)"));
  }
}