@Theory public void test_isBeforeOrEqual_assertion( ZonedDateTime referenceDate, ZonedDateTime dateBefore, ZonedDateTime dateAfter) { // GIVEN testAssumptions(referenceDate, dateBefore, dateAfter); // WHEN assertThat(dateBefore).isBeforeOrEqualTo(referenceDate); assertThat(dateBefore).isBeforeOrEqualTo(referenceDate.toString()); assertThat(referenceDate).isBeforeOrEqualTo(referenceDate); assertThat(referenceDate).isBeforeOrEqualTo(referenceDate.toString()); // THEN verify_that_isBeforeOrEqual_assertion_fails_and_throws_AssertionError(dateAfter, referenceDate); }
@Theory public void test_isIn_assertion(ZonedDateTime referenceDate) { // WHEN assertThat(referenceDate) .isIn(referenceDate.toString(), referenceDate.plus(1, ChronoUnit.MILLIS).toString()); // THEN verify_that_isIn_assertion_fails_and_throws_AssertionError(referenceDate); }
private static void verify_that_isNotIn_assertion_fails_and_throws_AssertionError( ZonedDateTime reference) { try { assertThat(reference).isNotIn(reference.toString(), reference.plusNanos(1).toString()); } catch (AssertionError e) { // AssertionError was expected return; } fail("Should have thrown AssertionError"); }
private static void verify_that_isBeforeOrEqual_assertion_fails_and_throws_AssertionError( ZonedDateTime dateToCheck, ZonedDateTime reference) { try { assertThat(dateToCheck).isBeforeOrEqualTo(reference); } catch (AssertionError e) { // AssertionError was expected, test same assertion with String based parameter try { assertThat(dateToCheck).isBeforeOrEqualTo(reference.toString()); } catch (AssertionError e2) { // AssertionError was expected (again) return; } } fail("Should have thrown AssertionError"); }