How to use assertDateTimeParameterIsNotNull method of org.assertj.core.api.AbstractZonedDateTimeAssert class

Best Assertj code snippet using org.assertj.core.api.AbstractZonedDateTimeAssert.assertDateTimeParameterIsNotNull

Source:AbstractZonedDateTimeAssert.java Github

copy

Full Screen

...36 *37 * @param dateTime the {@link ZonedDateTime} to check38 * @throws IllegalArgumentException with an explicit message if the given {@link ZonedDateTime} is null39 */40 private static void assertDateTimeParameterIsNotNull(ZonedDateTime dateTime) {41 checkArgument(dateTime != null, NULL_DATE_TIME_PARAMETER_MESSAGE);42 }43 /**44 * Verifies that the actual {@code ZonedDateTime} is <b>strictly</b> before the given one according to the comparator in use.45 * <p>46 * <b>Breaking change</b>: since 3.15.0 the default comparator uses {@link ChronoZonedDateTime#timeLineOrder()} which only47 * compares the underlying instant and not the chronology. The underlying comparison is equivalent to comparing the epoch-second and nano-of-second.<br>48 * This behaviour can be overridden by {@link AbstractZonedDateTimeAssert#usingComparator(Comparator)}.49 * <p>50 * Example :51 * <pre><code class='java'> // assertion succeeds52 * assertThat(parse("2000-01-01T01:00:00Z")).isBefore(parse("2020-01-01T01:00:00Z"));53 *54 * // assertions fail55 * assertThat(parse("2000-01-01T01:00:00Z")).isBefore(parse("1999-01-01T01:00:00Z"));56 * assertThat(parse("2000-01-01T01:00:00Z")).isBefore(parse("2000-01-01T01:00:00Z"));57 * // fails because both ZonedDateTime refer to the same instant (on different offsets)58 * assertThat(parse("2000-01-01T01:00:00Z")).isBefore(parse("2000-01-01T00:00:00-01:00"));59 *60 * // succeeds because both ZonedDateTime refer to the same instant and ZonedDateTime natural comparator is used.61 * assertThat(parse("2000-01-02T00:00:00Z")).usingComparator(ZonedDateTime::compareTo)62 * .isBefore(parse("2000-01-02T01:00:00+01:00")); </code></pre>63 *64 * @param other the given {@link ZonedDateTime}.65 * @return this assertion object.66 * @throws AssertionError if the actual {@code ZonedDateTime} is {@code null}.67 * @throws IllegalArgumentException if other {@code ZonedDateTime} is {@code null}.68 * @throws AssertionError if the actual {@code ZonedDateTime} is not strictly before the given one.69 */70 public SELF isBefore(ZonedDateTime other) {71 assertDateTimeParameterIsNotNull(other);72 comparables.assertIsBefore(info, actual, other);73 return myself;74 }75 /**76 * Same assertion as {@link #isBefore(ZonedDateTime)} but the {@link ZonedDateTime} is built from given String, which77 * must follow <a78 * href="http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_DATE_TIME"79 * >ISO date-time format</a> to allow calling {@link ZonedDateTime#parse(CharSequence, DateTimeFormatter)} method.80 * <p>81 * <b>Breaking change</b>: since 3.15.0 the default comparator uses {@link ChronoZonedDateTime#timeLineOrder()} which only82 * compares the underlying instant and not the chronology. The underlying comparison is equivalent to comparing the epoch-second and nano-of-second.<br>83 * This behaviour can be overridden by {@link AbstractZonedDateTimeAssert#usingComparator(Comparator)}.84 * <p>85 * Example :86 * <pre><code class='java'> // assertion succeeds87 * assertThat(parse("2000-01-01T01:00:00Z")).isBefore("2020-01-01T01:00:00Z");88 *89 * // assertions fail90 * assertThat(parse("2000-01-01T01:00:00Z")).isBefore("1999-01-01T01:00:00Z");91 * assertThat(parse("2000-01-01T01:00:00Z")).isBefore("2000-01-01T01:00:00Z");92 * // fails because both ZonedDateTime refer to the same instant (on different offsets)93 * assertThat(parse("2000-01-01T01:00:00Z")).isBefore("2000-01-01T00:00:00-01:00");94 *95 * // succeeds because both ZonedDateTime refer to the same instant and ZonedDateTime natural comparator is used.96 * assertThat(parse("2000-01-02T00:00:00Z")).usingComparator(ZonedDateTime::compareTo)97 * .isBefore("2000-01-02T01:00:00+01:00"); </code></pre>98 *99 * @param dateTimeAsString String representing a {@link ZonedDateTime}.100 * @return this assertion object.101 * @throws AssertionError if the actual {@code ZonedDateTime} is {@code null}.102 * @throws IllegalArgumentException if given String is null or can't be converted to a {@link ZonedDateTime}.103 * @throws AssertionError if the actual {@code ZonedDateTime} is not strictly before the {@link ZonedDateTime} built104 * from given String.105 */106 public SELF isBefore(String dateTimeAsString) {107 assertDateTimeAsStringParameterIsNotNull(dateTimeAsString);108 return isBefore(parse(dateTimeAsString));109 }110 /**111 * Verifies that the actual {@code ZonedDateTime} is before or equals to the given one according to the comparator in use.112 * <p>113 * <b>Breaking change</b>: since 3.15.0 the default comparator uses {@link ChronoZonedDateTime#timeLineOrder()} which only114 * compares the underlying instant and not the chronology. The underlying comparison is equivalent to comparing the epoch-second and nano-of-second.<br>115 * This behaviour can be overridden by {@link AbstractZonedDateTimeAssert#usingComparator(Comparator)}.116 * <p>117 * Example :118 * <pre><code class='java'> // assertions succeed119 * assertThat(parse("2000-01-01T01:00:00Z")).isBeforeOrEqualTo(parse("2020-01-01T01:00:00Z"))120 * .isBeforeOrEqualTo(parse("2000-01-01T01:00:00Z"))121 * // same instant (on different offsets)122 * .isBeforeOrEqualTo(parse("2000-01-01T00:00:00-01:00"));123 *124 * // assertions fail125 * assertThat(parse("2000-01-01T01:00:00Z")).isBeforeOrEqualTo(parse("1999-01-01T01:00:00Z"));126 * // even though the same instant, fails because of ZonedDateTime natural comparator is used and ZonedDateTime are on different offsets127 * assertThat(parse("2000-01-01T01:00:00Z")).usingComparator(ZonedDateTime::compareTo)128 * .isBeforeOrEqualTo(parse("2000-01-01T00:00:00-01:00")); </code></pre>129 *130 * @param other the given {@link ZonedDateTime}.131 * @return this assertion object.132 * @throws AssertionError if the actual {@code ZonedDateTime} is {@code null}.133 * @throws IllegalArgumentException if other {@code ZonedDateTime} is {@code null}.134 * @throws AssertionError if the actual {@code ZoneDateTime} is not before or equals to the given one.135 */136 public SELF isBeforeOrEqualTo(ZonedDateTime other) {137 assertDateTimeParameterIsNotNull(other);138 comparables.assertIsBeforeOrEqualTo(info, actual, other);139 return myself;140 }141 /**142 * Same assertion as {@link #isBeforeOrEqualTo(ZonedDateTime)} but the {@link ZonedDateTime} is built from given143 * String which must follow <a144 * href="http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_DATE_TIME"145 * >ISO date-time format</a> to allow calling {@link ZonedDateTime#parse(CharSequence, DateTimeFormatter)} method.146 * <p>147 * <b>Breaking change</b>: since 3.15.0 the default comparator uses {@link ChronoZonedDateTime#timeLineOrder()} which only148 * compares the underlying instant and not the chronology. The underlying comparison is equivalent to comparing the epoch-second and nano-of-second.<br>149 * This behaviour can be overridden by {@link AbstractZonedDateTimeAssert#usingComparator(Comparator)}.150 * <p>151 * Example :152 * <pre><code class='java'> // assertions succeed153 * assertThat(parse("2000-01-01T01:00:00Z")).isBeforeOrEqualTo("2020-01-01T01:00:00Z")154 * .isBeforeOrEqualTo("2000-01-01T01:00:00Z")155 * // same instant (on different offsets)156 * .isBeforeOrEqualTo("2000-01-01T00:00:00-01:00");157 *158 * // assertions fail159 * assertThat(parse("2000-01-01T01:00:00Z")).isBeforeOrEqualTo("1999-01-01T01:00:00Z");160 * // even though the same instant, fails because of ZonedDateTime natural comparator is used and ZonedDateTime are on different offsets161 * assertThat(parse("2000-01-01T01:00:00Z")).usingComparator(ZonedDateTime::compareTo)162 * .isBeforeOrEqualTo("2000-01-01T00:00:00-01:00"); </code></pre>163 *164 * @param dateTimeAsString String representing a {@link ZonedDateTime}.165 * @return this assertion object.166 * @throws AssertionError if the actual {@code ZonedDateTime} is {@code null}.167 * @throws IllegalArgumentException if given String is null or can't be converted to a {@link ZonedDateTime}.168 * @throws AssertionError if the actual {@code ZonedDateTime} is not before or equals to the {@link ZonedDateTime}169 * built from given String.170 */171 public SELF isBeforeOrEqualTo(String dateTimeAsString) {172 assertDateTimeAsStringParameterIsNotNull(dateTimeAsString);173 return isBeforeOrEqualTo(parse(dateTimeAsString));174 }175 /**176 * Verifies that the actual {@code ZonedDateTime} is after or equals to the given one according to the comparator in use.177 * <p>178 * <b>Breaking change</b>: since 3.15.0 the default comparator uses {@link ChronoZonedDateTime#timeLineOrder()} which only179 * compares the underlying instant and not the chronology. The underlying comparison is equivalent to comparing the epoch-second and nano-of-second.<br>180 * This behaviour can be overridden by {@link AbstractZonedDateTimeAssert#usingComparator(Comparator)}.181 * <p>182 * Example :183 * <pre><code class='java'> // assertions succeed184 * assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo(parse("2000-01-01T00:00:00Z"))185 * .isAfterOrEqualTo(parse("1999-12-31T23:59:59Z"))186 * // same instant in different offset187 * .isAfterOrEqualTo(parse("2000-01-01T00:00:00-01:00"));188 *189 * // assertions fail190 * assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo(parse("2001-01-01T00:00:00Z"));191 * // fails even though they refer to the same instant due to ZonedDateTime natural comparator192 * assertThat(parse("2000-01-01T00:00:00Z")).usingComparator(ZonedDateTime::compareTo)193 * .isAfterOrEqualTo(parse("2000-01-01T01:00:00+01:00"));</code></pre>194 *195 * @param other the given {@link ZonedDateTime}.196 * @return this assertion object.197 * @throws AssertionError if the actual {@code ZonedDateTime} is {@code null}.198 * @throws IllegalArgumentException if other {@code ZonedDateTime} is {@code null}.199 * @throws AssertionError if the actual {@code ZonedDateTime} is not after or equals to the given one.200 */201 public SELF isAfterOrEqualTo(ZonedDateTime other) {202 assertDateTimeParameterIsNotNull(other);203 comparables.assertIsAfterOrEqualTo(info, actual, other);204 return myself;205 }206 /**207 * Same assertion as {@link #isAfterOrEqualTo(ZonedDateTime)} but the {@link ZonedDateTime} is built from given208 * String which must follow <a209 * href="http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_DATE_TIME"210 * >ISO date-time format</a> to allow calling {@link ZonedDateTime#parse(CharSequence, DateTimeFormatter)} method.211 * <p>212 * <b>Breaking change</b>: since 3.15.0 the default comparator uses {@link ChronoZonedDateTime#timeLineOrder()} which only213 * compares the underlying instant and not the chronology. The underlying comparison is equivalent to comparing the epoch-second and nano-of-second.<br>214 * This behaviour can be overridden by {@link AbstractZonedDateTimeAssert#usingComparator(Comparator)}.215 * <p>216 * Example :217 * <pre><code class='java'> // assertions succeed218 * assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo("2000-01-01T00:00:00Z")219 * .isAfterOrEqualTo("1999-12-31T23:59:59Z")220 * // same instant in different offset221 * .isAfter("2000-01-01T00:00:00-01:00");222 *223 * // assertions fail224 * assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo("2001-01-01T00:00:00Z");225 * // fails even though they refer to the same instant due to ZonedDateTime natural comparator226 * assertThat(parse("2000-01-01T00:00:00Z")).usingComparator(ZonedDateTime::compareTo)227 * .isAfterOrEqualTo("2000-01-01T01:00:00+01:00");</code></pre>228 *229 * @param dateTimeAsString String representing a {@link ZonedDateTime}.230 * @return this assertion object.231 * @throws AssertionError if the actual {@code ZonedDateTime} is {@code null}.232 * @throws IllegalArgumentException if given String is null or can't be converted to a {@link ZonedDateTime}.233 * @throws AssertionError if the actual {@code ZonedDateTime} is not after or equals to the {@link ZonedDateTime}234 * built from given String.235 */236 public SELF isAfterOrEqualTo(String dateTimeAsString) {237 assertDateTimeAsStringParameterIsNotNull(dateTimeAsString);238 return isAfterOrEqualTo(parse(dateTimeAsString));239 }240 /**241 * Verifies that the actual {@code ZonedDateTime} is <b>strictly</b> after the given one according to the comparator in use.242 * <p>243 * <b>Breaking change</b>: since 3.15.0 the default comparator uses {@link ChronoZonedDateTime#timeLineOrder()} which only244 * compares the underlying instant and not the chronology. The underlying comparison is equivalent to comparing the epoch-second and nano-of-second.<br>245 * This behaviour can be overridden by {@link AbstractZonedDateTimeAssert#usingComparator(Comparator)}.246 * <p>247 * Example :248 * <pre><code class='java'> // assertion succeeds249 * assertThat(parse("2000-01-01T01:00:00Z")).isAfter(parse("1999-01-01T00:00:00Z"));250 *251 * // assertions fail252 * assertThat(parse("2000-01-01T01:00:00Z")).isAfter(parse("2001-01-01T01:00:00Z"));253 * assertThat(parse("2000-01-01T01:00:00Z")).isAfter(parse("2000-01-01T01:00:00Z"));254 * // fails because both ZonedDateTime refer to the same instant (on different offsets)255 * assertThat(parse("2000-01-01T01:00:00Z")).isAfter(parse("2000-01-01T00:00:00-01:00"));256 *257 * // even though they refer to the same instant assertion succeeds because of different offset258 * assertThat(parse("2000-01-01T01:00:00Z")).usingComparator(ZonedDateTime::compareTo)259 * .isAfter(parse("2000-01-01T00:00:00-01:00"));</code></pre>260 *261 * @param other the given {@link ZonedDateTime}.262 * @return this assertion object.263 * @throws AssertionError if the actual {@code ZonedDateTime} is {@code null}.264 * @throws IllegalArgumentException if other {@code ZonedDateTime} is {@code null}.265 * @throws AssertionError if the actual {@code ZonedDateTime} is not strictly after the given one.266 */267 public SELF isAfter(ZonedDateTime other) {268 assertDateTimeParameterIsNotNull(other);269 comparables.assertIsAfter(info, actual, other);270 return myself;271 }272 /**273 * Same assertion as {@link #isAfter(ZonedDateTime)} but the {@link ZonedDateTime} is built from given String, which274 * must follow <a275 * href="http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_DATE_TIME"276 * >ISO date-time format</a> to allow calling {@link ZonedDateTime#parse(CharSequence, DateTimeFormatter)} method.277 * <p>278 * <b>Breaking change</b>: since 3.15.0 the default comparator uses {@link ChronoZonedDateTime#timeLineOrder()} which only279 * compares the underlying instant and not the chronology. The underlying comparison is equivalent to comparing the epoch-second and nano-of-second.<br>280 * This behaviour can be overridden by {@link AbstractZonedDateTimeAssert#usingComparator(Comparator)}.281 * <p>282 * Example :283 * <pre><code class='java'> // assertion succeeds284 * assertThat(parse("2000-01-01T01:00:00Z")).isAfter("1999-01-01T00:00:00Z");285 *286 * // assertions fail287 * assertThat(parse("2000-01-01T01:00:00Z")).isAfter("2001-01-01T01:00:00Z");288 * assertThat(parse("2000-01-01T01:00:00Z")).isAfter("2000-01-01T01:00:00Z");289 * // fails because both ZonedDateTime refer to the same instant (on different offsets)290 * assertThat(parse("2000-01-01T01:00:00Z")).isAfter("2000-01-01T00:00:00-01:00");291 *292 * // even though they refer to the same instant assertion succeeds because of different offset293 * assertThat(parse("2000-01-01T01:00:00Z")).usingComparator(ZonedDateTime::compareTo)294 * .isAfter("2000-01-01T00:00:00-01:00");</code></pre>295 *296 * @param dateTimeAsString String representing a {@link ZonedDateTime}.297 * @return this assertion object.298 * @throws AssertionError if the actual {@code ZonedDateTime} is {@code null}.299 * @throws IllegalArgumentException if given String is null or can't be converted to a {@link ZonedDateTime}.300 * @throws AssertionError if the actual {@code ZonedDateTime} is not strictly after the {@link ZonedDateTime} built from the given String.301 */302 public SELF isAfter(String dateTimeAsString) {303 assertDateTimeAsStringParameterIsNotNull(dateTimeAsString);304 return isAfter(parse(dateTimeAsString));305 }306 /**307 * Verifies that actual and given {@code ZonedDateTime} have same year, month, day, hour, minute and second fields,308 * (nanosecond fields are ignored in comparison).309 * <p>310 * Note that given {@link ZonedDateTime} is converted in the actual's {@link java.time.ZoneId} before comparison.311 * <p>312 * Assertion can fail with dateTimes in same chronological nanosecond time window, e.g :313 * <p>314 * 2000-01-01T00:00:<b>01.000000000</b> and 2000-01-01T00:00:<b>00.999999999</b>.315 * <p>316 * Assertion fails as second fields differ even if time difference is only 1ns.317 * <p>318 * Code example :319 * <pre><code class='java'> // successful assertions320 * ZonedDateTime dateTime1 = ZonedDateTime.of(2000, 1, 1, 0, 0, 1, 0);321 * ZonedDateTime dateTime2 = ZonedDateTime.of(2000, 1, 1, 0, 0, 1, 456);322 * assertThat(dateTime1).isEqualToIgnoringNanos(dateTime2);323 *324 * // failing assertions (even if time difference is only 1ms)325 * ZonedDateTime dateTimeA = ZonedDateTime.of(2000, 1, 1, 0, 0, 1, 0);326 * ZonedDateTime dateTimeB = ZonedDateTime.of(2000, 1, 1, 0, 0, 0, 999999999);327 * assertThat(dateTimeA).isEqualToIgnoringNanos(dateTimeB);</code></pre>328 *329 * @param other the given {@link ZonedDateTime}.330 * @return this assertion object.331 * @throws AssertionError if the actual {@code ZonedDateTime} is {@code null}.332 * @throws IllegalArgumentException if other {@code ZonedDateTime} is {@code null}.333 * @throws AssertionError if the actual {@code ZonedDateTime} is are not equal with nanoseconds ignored.334 */335 public SELF isEqualToIgnoringNanos(ZonedDateTime other) {336 Objects.instance().assertNotNull(info, actual);337 assertDateTimeParameterIsNotNull(other);338 ZonedDateTime otherInActualTimeZone = sameInstantInActualTimeZone(other);339 if (!areEqualIgnoringNanos(actual, otherInActualTimeZone)) {340 throw Failures.instance().failure(info, shouldBeEqualIgnoringNanos(actual, otherInActualTimeZone));341 }342 return myself;343 }344 /**345 * Verifies that actual and given {@link ZonedDateTime} have same year, month, day, hour and minute fields (second and346 * nanosecond fields are ignored in comparison).347 * <p>348 * Note that given {@link ZonedDateTime} is converted in the actual's {@link java.time.ZoneId} before comparison.349 * <p>350 * Assertion can fail with ZonedDateTimes in same chronological second time window, e.g :351 * <p>352 * 2000-01-01T00:<b>01:00</b>.000 and 2000-01-01T00:<b>00:59</b>.000.353 * <p>354 * Assertion fails as minute fields differ even if time difference is only 1ns.355 * <p>356 * Code example :357 * <pre><code class='java'> // successful assertions358 * ZonedDateTime dateTime1 = ZonedDateTime.of(2000, 1, 1, 23, 50, 0, 0);359 * ZonedDateTime dateTime2 = ZonedDateTime.of(2000, 1, 1, 23, 50, 10, 456);360 * assertThat(dateTime1).isEqualToIgnoringSeconds(dateTime2);361 *362 * // failing assertions (even if time difference is only 1ns)363 * ZonedDateTime dateTimeA = ZonedDateTime.of(2000, 1, 1, 23, 50, 00, 0);364 * ZonedDateTime dateTimeB = ZonedDateTime.of(2000, 1, 1, 23, 49, 59, 999999999);365 * assertThat(dateTimeA).isEqualToIgnoringSeconds(dateTimeB);</code></pre>366 *367 * @param other the given {@link ZonedDateTime}.368 * @return this assertion object.369 * @throws AssertionError if the actual {@code ZonedDateTime} is {@code null}.370 * @throws IllegalArgumentException if other {@code ZonedDateTime} is {@code null}.371 * @throws AssertionError if the actual {@code ZonedDateTime} is are not equal with second and nanosecond fields372 * ignored.373 */374 public SELF isEqualToIgnoringSeconds(ZonedDateTime other) {375 Objects.instance().assertNotNull(info, actual);376 assertDateTimeParameterIsNotNull(other);377 ZonedDateTime otherInActualTimeZone = sameInstantInActualTimeZone(other);378 if (!areEqualIgnoringSeconds(actual, otherInActualTimeZone)) {379 throw Failures.instance().failure(info, shouldBeEqualIgnoringSeconds(actual, otherInActualTimeZone));380 }381 return myself;382 }383 /**384 * Verifies that actual and given {@code ZonedDateTime} have same year, month, day and hour fields (minute, second and385 * nanosecond fields are ignored in comparison).386 * <p>387 * Note that given {@link ZonedDateTime} is converted in the actual's {@link java.time.ZoneId} before comparison.388 * <p>389 * Assertion can fail with dateTimes in same chronological second time window, e.g :390 * <p>391 * 2000-01-01T<b>01:00</b>:00.000 and 2000-01-01T<b>00:59:59</b>.000.392 * <p>393 * Time difference is only 1s but hour fields differ.394 * <p>395 * Code example :396 * <pre><code class='java'> // successful assertions397 * ZonedDateTime dateTime1 = ZonedDateTime.of(2000, 1, 1, 23, 50, 0, 0);398 * ZonedDateTime dateTime2 = ZonedDateTime.of(2000, 1, 1, 23, 00, 2, 7);399 * assertThat(dateTime1).isEqualToIgnoringMinutes(dateTime2);400 *401 * // failing assertions (even if time difference is only 1ms)402 * ZonedDateTime dateTimeA = ZonedDateTime.of(2000, 1, 1, 01, 00, 00, 000);403 * ZonedDateTime dateTimeB = ZonedDateTime.of(2000, 1, 1, 00, 59, 59, 999);404 * assertThat(dateTimeA).isEqualToIgnoringMinutes(dateTimeB);</code></pre>405 *406 * @param other the given {@link ZonedDateTime}.407 * @return this assertion object.408 * @throws AssertionError if the actual {@code ZonedDateTime} is {@code null}.409 * @throws IllegalArgumentException if other {@code ZonedDateTime} is {@code null}.410 * @throws AssertionError if the actual {@code ZonedDateTime} is are not equal ignoring minute, second and nanosecond411 * fields.412 */413 public SELF isEqualToIgnoringMinutes(ZonedDateTime other) {414 Objects.instance().assertNotNull(info, actual);415 assertDateTimeParameterIsNotNull(other);416 ZonedDateTime otherInActualTimeZone = sameInstantInActualTimeZone(other);417 if (!areEqualIgnoringMinutes(actual, otherInActualTimeZone)) {418 throw Failures.instance().failure(info, shouldBeEqualIgnoringMinutes(actual, otherInActualTimeZone));419 }420 return myself;421 }422 /**423 * Verifies that actual and given {@code ZonedDateTime} have same year, month and day fields (hour, minute, second and424 * nanosecond fields are ignored in comparison).425 * <p>426 * Note that given {@link ZonedDateTime} is converted in the actual's {@link java.time.ZoneId} before comparison.427 * <p>428 * Assertion can fail with dateTimes in same chronological minute time window, e.g :429 * <p>430 * 2000-01-<b>01T23:59</b>:00.000 and 2000-01-02T<b>00:00</b>:00.000.431 * <p>432 * Time difference is only 1min but day fields differ.433 * <p>434 * Code example :435 * <pre><code class='java'> // successful assertions436 * ZonedDateTime dateTime1 = ZonedDateTime.of(2000, 1, 1, 23, 59, 59, 999, ZoneId.systemDefault());437 * ZonedDateTime dateTime2 = ZonedDateTime.of(2000, 1, 1, 00, 00, 00, 000, ZoneId.systemDefault());438 * assertThat(dateTime1).isEqualToIgnoringHours(dateTime2);439 *440 * // failing assertions (even if time difference is only 1ms)441 * ZonedDateTime dateTimeA = ZonedDateTime.of(2000, 1, 2, 00, 00, 00, 000, ZoneId.systemDefault());442 * ZonedDateTime dateTimeB = ZonedDateTime.of(2000, 1, 1, 23, 59, 59, 999, ZoneId.systemDefault());443 * assertThat(dateTimeA).isEqualToIgnoringHours(dateTimeB);</code></pre>444 *445 * @param other the given {@link ZonedDateTime}.446 * @return this assertion object.447 * @throws AssertionError if the actual {@code ZonedDateTime} is {@code null}.448 * @throws IllegalArgumentException if other {@code ZonedDateTime} is {@code null}.449 * @throws AssertionError if the actual {@code ZonedDateTime} is are not equal with second and nanosecond fields450 * ignored.451 */452 public SELF isEqualToIgnoringHours(ZonedDateTime other) {453 Objects.instance().assertNotNull(info, actual);454 assertDateTimeParameterIsNotNull(other);455 ZonedDateTime otherInActualTimeZone = sameInstantInActualTimeZone(other);456 if (!haveSameYearMonthAndDayOfMonth(actual, otherInActualTimeZone)) {457 throw Failures.instance().failure(info, shouldBeEqualIgnoringHours(actual, otherInActualTimeZone));458 }459 return myself;460 }461 /**462 * Verifies that the actual {@link ZonedDateTime} is equal to the given one according to the comparator in use.463 * <p>464 * <b>Breaking change</b>: since 3.15.0 the default comparator uses {@link ChronoZonedDateTime#timeLineOrder()} which only465 * compares the underlying instant and not the chronology. The underlying comparison is equivalent to comparing the epoch-second and nano-of-second.<br>466 * This behaviour can be overridden by {@link AbstractZonedDateTimeAssert#usingComparator(Comparator)}.467 * <p>468 * Example :...

Full Screen

Full Screen

assertDateTimeParameterIsNotNull

Using AI Code Generation

copy

Full Screen

1import org.junit.jupiter.api.Test;2import org.junit.jupiter.api.extension.ExtendWith;3import org.mockito.junit.jupiter.MockitoExtension;4import java.time.ZonedDateTime;5import static org.assertj.core.api.Assertions.assertThat;6@ExtendWith(MockitoExtension.class)7public class AssertJZonedDateTimeTest {8 public void test() {9 ZonedDateTime zonedDateTime = ZonedDateTime.now();10 assertThat(zonedDateTime).isNotNull();11 }12}

Full Screen

Full Screen

assertDateTimeParameterIsNotNull

Using AI Code Generation

copy

Full Screen

1assertThat(ZonedDateTime.now()).assertDateTimeParameterIsNotNull(ZonedDateTime.now());2assertThat(ZonedDateTime.now()).assertDateTimeParameterIsNotNull(ZonedDateTime.now(), ZonedDateTime.now());3assertThat(ZonedDateTime.now()).assertDateTimeParameterIsNotNull(ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now());4assertThat(ZonedDateTime.now()).assertDateTimeParameterIsNotNull(ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now());5assertThat(ZonedDateTime.now()).assertDateTimeParameterIsNotNull(ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now());6assertThat(ZonedDateTime.now()).assertDateTimeParameterIsNotNull(ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now());7assertThat(ZonedDateTime.now()).assertDateTimeParameterIsNotNull(ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now());8assertThat(ZonedDateTime.now()).assertDateTimeParameterIsNotNull(ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now());9assertThat(ZonedDateTime.now()).assertDateTimeParameter

Full Screen

Full Screen

assertDateTimeParameterIsNotNull

Using AI Code Generation

copy

Full Screen

1assertThat(ZonedDateTime.now()).assertDateTimeParameterIsNotNull(ZonedDateTime.now());2assertThat(OffsetDateTime.now()).assertDateTimeParameterIsNotNull(OffsetDateTime.now());3assertThat(LocalDateTime.now()).assertDateTimeParameterIsNotNull(LocalDateTime.now());4assertThat(LocalDate.now()).assertDateTimeParameterIsNotNull(LocalDate.now());5assertThat(LocalTime.now()).assertDateTimeParameterIsNotNull(LocalTime.now());6assertThat(OffsetTime.now()).assertDateTimeParameterIsNotNull(OffsetTime.now());7assertThat(Instant.now()).assertDateTimeParameterIsNotNull(Instant.now());8assertThat(Duration.ofMinutes(2)).assertDateTimeParameterIsNotNull(Duration.ofMinutes(2));9assertThat(Period.ofDays(2)).assertDateTimeParameterIsNotNull(Period.ofDays(2));10assertThat(Year.of(2020)).assertDateTimeParameterIsNotNull(Year.of(2020));11assertThat(YearMonth.of(2020, 12)).assertDateTimeParameterIsNotNull(YearMonth.of(2020, 12));12assertThat(MonthDay.of(12, 31)).assertDateTimeParameterIsNotNull(MonthDay.of(12, 31));13assertThat(ZonedDateTime.now()).assertDateTimeParameterIsNotNull(ZonedDateTime.now());

Full Screen

Full Screen

assertDateTimeParameterIsNotNull

Using AI Code Generation

copy

Full Screen

1assertThat(ZonedDateTime.of(2015, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)).assertDateTimeParameterIsNotNull(ZonedDateTime.now());2assertThat(ZonedDateTime.of(2015, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)).assertDateTimeParameterIsNotNull(ZonedDateTime.now());3assertThat(ZonedDateTime.of(2015, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)).assertDateTimeParameterIsNotNull(ZonedDateTime.now());4assertThat(ZonedDateTime.of(2015, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)).assertDateTimeParameterIsNotNull(ZonedDateTime.now());5assertThat(ZonedDateTime.of(2015, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)).assertDateTimeParameterIsNotNull(ZonedDateTime.now());6assertThat(ZonedDateTime.of(2015, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)).assertDateTimeParameterIsNotNull(ZonedDateTime.now());7assertThat(ZonedDateTime.of(2015, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)).assertDateTimeParameterIsNotNull(ZonedDateTime.now());8assertThat(ZonedDateTime.of(2015, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)).assertDateTimeParameterIsNotNull(ZonedDateTime.now());9assertThat(ZonedDateTime.of(2015, 1, 1, 0,

Full Screen

Full Screen

assertDateTimeParameterIsNotNull

Using AI Code Generation

copy

Full Screen

1ZonedDateTime zoneDateTime = ZonedDateTime.now();2assertThat(zoneDateTime).assertDateTimeParameterIsNotNull();3ZonedDateTime zoneDateTime = null;4assertThat(zoneDateTime).assertDateTimeParameterIsNotNull();5assertDateTimeParameterIsNotNull(ZonedDateTime)6assertDateTimeParameterIsNotNull(ZonedDateTime actual)7assertDateTimeParameterIsNotNull(ZonedDateTime, String)8assertDateTimeParameterIsNotNull(ZonedDateTime actual, String message)9assertDateTimeParameterIsNotNull(ZonedDateTime, String, Object...)10assertDateTimeParameterIsNotNull(ZonedDateTime actual, String message, Object... args)11assertDateTimeParameterIsNotNull(ZonedDateTime, Supplier)12assertDateTimeParameterIsNotNull(ZonedDateTime actual, Supplier<String> messageSupplier)

Full Screen

Full Screen

assertDateTimeParameterIsNotNull

Using AI Code Generation

copy

Full Screen

1org.assertj.core.api.AbstractZonedDateTimeAssert<org.threeten.bp.ZonedDateTime> assertDateTimeParameterIsNotNull(org.threeten.bp.ZonedDateTime actual, java.lang.String paramName)2org.assertj.core.api.AbstractAssert<?, org.threeten.bp.ZonedDateTime> assertThat(org.threeten.bp.ZonedDateTime actual)3org.assertj.core.api.AbstractAssert<?, org.threeten.bp.ZonedDateTime> assertThat(org.threeten.bp.ZonedDateTime actual, org.assertj.core.api.ZonedDateTimeAssert.ZonedDateTimeOffsetRepresentation offsetRepresentation)4org.assertj.core.api.AbstractAssert<?, org.threeten.bp.ZonedDateTime> assertThat(org.threeten.bp.ZonedDateTime actual, org.assertj.core.api.ZonedDateTimeAssert.ZonedDateTimeOffsetRepresentation offsetRepresentation, org.assertj.core.api.ZonedDateTimeAssert.ZonedDateTimeStrictness strictness)5org.assertj.core.api.AbstractAssert<?, org.threeten.bp.ZonedDateTime> assertThat(org.threeten.bp.ZonedDateTime actual, org.assertj.core.api.ZonedDateTimeAssert.ZonedDateTimeStrictness strictness)6org.assertj.core.api.ThrowableAssert.ThrowingCallable assertThatExceptionOfType(java.lang.Class<? extends java.lang.Throwable> exceptionType)7org.assertj.core.api.ThrowableAssert.ThrowingCallable assertThatIllegalArgumentException()

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful