/** * Same assertion as {@link AbstractAssert#isEqualTo(Object) isEqualTo(Date date)} but given Date is represented as String * either with ISO date format (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if actual and given Date represented as String are not equal. * @throws AssertionError if the given date as String could not be converted to a Date. */ public DateAssert isEqualTo(String dateAsString) { return isEqualTo(parse(dateAsString)); }
/** * Creates a new instance of <code>{@link DateAssert}</code>. * @param actual the actual value. * @return the created assertion object. */ public static DateAssert assertThat(Date actual) { return new DateAssert(actual); }
/** * Same assertion as {@link #isAfter(Date)} but given Date is represented as String either with ISO date format (yyyy-MM-dd) or * user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if given date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is not strictly after the given Date represented as String. * @throws AssertionError if the given date as String could not be converted to a Date. */ public DateAssert isAfter(String dateAsString) { return isAfter(parse(dateAsString)); }
/** * Same assertion as {@link #isInSameDayAs(Date)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws NullPointerException if dateAsString parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same day of month. */ public DateAssert isInSameDayAs(String dateAsString) { return isInSameDayAs(parse(dateAsString)); }
/** * Same assertion as {@link #isBeforeOrEqualsTo(Date)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if given date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is not before or equals to the given Date represented as String. * @throws AssertionError if the given date as String could not be converted to a Date. */ public DateAssert isBeforeOrEqualsTo(String dateAsString) { return isBeforeOrEqualsTo(parse(dateAsString)); }
/** * Same assertion as {@link Assert#isIn(Object...)} but given Dates are represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param datesAsString the given Dates represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if actual is not in given Dates represented as String. * @throws AssertionError if one of the given date as String could not be converted to a Date. */ public DateAssert isIn(String... datesAsString) { Date[] dates = new Date[datesAsString.length]; for (int i = 0; i < datesAsString.length; i++) { dates[i] = parse(datesAsString[i]); } return isIn(dates); }
/** * Same assertion as {@link #isCloseTo(Date, long)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @param deltaInMilliseconds the delta used for date comparison, expressed in milliseconds * @return this assertion object. * @throws NullPointerException if dateAsString parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} week is not close to the given date by less than delta. */ public DateAssert isCloseTo(String dateAsString, long deltaInMilliseconds) { return isCloseTo(parse(dateAsString), deltaInMilliseconds); }
/** * Same assertion as {@link #isAfterOrEqualsTo(Date)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if given date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is not after or equals to the given Date represented as String. * @throws AssertionError if the given date as String could not be converted to a Date. */ public DateAssert isAfterOrEqualsTo(String dateAsString) { return isAfterOrEqualsTo(parse(dateAsString)); }
/** * Same assertion as {@link #isBefore(Date)} but given Date is represented as String either with ISO date format (yyyy-MM-dd) or * user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if given date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is not strictly before the given Date represented as String. * @throws AssertionError if the given date as String could not be converted to a Date. */ public DateAssert isBefore(String dateAsString) { return isBefore(parse(dateAsString)); }
/** * Same assertion as {@link #isBetween(Date, Date)} but given Dates are represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param start the period start (inclusive), expected not to be null. * @param end the period end (exclusive), expected not to be null. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if start Date as String is {@code null}. * @throws NullPointerException if end Date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is not in [start, end[ period. * @throws AssertionError if one of the given date as String could not be converted to a Date. */ public DateAssert isBetween(String start, String end) { return isBetween(parse(start), parse(end)); }
assertThat(unParceled.searchPage).isEqualTo(original.searchPage); assertThat(unParceled.searchPagePosition).isEqualTo(original.searchPagePosition); assertThat(unParceled.createdAt).isEqualTo(original.createdAt);
/** * Verifies that the actual {@code Date} is in [start, end[ period (start included, end excluded). * @param start the period start (inclusive), expected not to be null. * @param end the period end (exclusive), expected not to be null. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if start {@code Date} is {@code null}. * @throws NullPointerException if end {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not in [start, end[ period. */ public DateAssert isBetween(Date start, Date end) { return isBetween(start, end, true, false); }
/** * Same assertion as {@link Assert#isIn(Iterable)} but given Dates are represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}).<br> * Method signature could not be <code>isIn(Collection<String>)</code> because it would be same signature as * <code>isIn(Collection<Date>)</code> since java collection type are erased at runtime. * @param datesAsString the given Dates represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if actual is not in given Dates represented as String. * @throws AssertionError if one of the given date as String could not be converted to a Date. */ public DateAssert isInWithStringDateCollection(Collection<String> datesAsString) { Collection<Date> dates = new ArrayList<Date>(datesAsString.size()); for (String dateAsString : datesAsString) { dates.add(parse(dateAsString)); } return isIn(dates); }