How to use parse method of org.assertj.core.api.AbstractOffsetTimeAssert class

Best Assertj code snippet using org.assertj.core.api.AbstractOffsetTimeAssert.parse

Source:AbstractOffsetTimeAssert.java Github

copy

Full Screen

...44 /**45 * Verifies that the actual {@code OffsetTime} is <b>strictly</b> before the given one.46 * <p>47 * Example :48 * <pre><code class='java'> assertThat(parse("12:00:00Z")).isBefore(parse("13:00:00Z"));</code></pre>49 *50 * @param other the given {@link java.time.OffsetTime}.51 * @return this assertion object.52 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.53 * @throws IllegalArgumentException if other {@code OffsetTime} is {@code null}.54 * @throws AssertionError if the actual {@code OffsetTime} is not strictly before the given one.55 */56 public SELF isBefore(OffsetTime other) {57 Objects.instance().assertNotNull(info, actual);58 assertOffsetTimeParameterIsNotNull(other);59 if (!actual.isBefore(other)) {60 throw Failures.instance().failure(info, shouldBeBefore(actual, other));61 }62 return myself;63 }64 /**65 * Same assertion as {@link #isBefore(java.time.OffsetTime)} but the {@link java.time.OffsetTime} is built from given66 * String, which67 * must follow <a href=68 * "http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_OFFSET_TIME"69 * >ISO OffsetTime format</a> to allow calling {@link java.time.OffsetTime#parse(CharSequence)} method.70 * <p>71 * Example :72 * <pre><code class='java'> // you can express expected OffsetTime as String (AssertJ taking care of the conversion)73 * assertThat(parse("12:59Z")).isBefore("13:00Z");</code></pre>74 *75 * @param offsetTimeAsString String representing a {@link java.time.OffsetTime}.76 * @return this assertion object.77 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.78 * @throws IllegalArgumentException if given String is null or can't be converted to a {@link java.time.OffsetTime}.79 * @throws AssertionError if the actual {@code OffsetTime} is not strictly before the {@link java.time.OffsetTime}80 * built81 * from given String.82 */83 public SELF isBefore(String offsetTimeAsString) {84 assertOffsetTimeAsStringParameterIsNotNull(offsetTimeAsString);85 return isBefore(parse(offsetTimeAsString));86 }87 /**88 * Verifies that the actual {@code OffsetTime} is before or equals to the given one.89 * <p>90 * Example :91 * <pre><code class='java'> assertThat(parse("12:00:00Z")).isBeforeOrEqualTo(parse("12:00:00Z"))92 * .isBeforeOrEqualTo(parse("12:00:01Z"));</code></pre>93 *94 * @param other the given {@link java.time.OffsetTime}.95 * @return this assertion object.96 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.97 * @throws IllegalArgumentException if other {@code OffsetTime} is {@code null}.98 * @throws AssertionError if the actual {@code OffsetTime} is not before or equals to the given one.99 */100 public SELF isBeforeOrEqualTo(OffsetTime other) {101 Objects.instance().assertNotNull(info, actual);102 assertOffsetTimeParameterIsNotNull(other);103 if (actual.isAfter(other)) {104 throw Failures.instance().failure(info, shouldBeBeforeOrEqualTo(actual, other));105 }106 return myself;107 }108 /**109 * Same assertion as {@link #isBeforeOrEqualTo(java.time.OffsetTime)} but the {@link java.time.OffsetTime} is built110 * from given111 * String, which must follow <a href=112 * "http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_OFFSET_TIME"113 * >ISO OffsetTime format</a> to allow calling {@link java.time.OffsetTime#parse(CharSequence)} method.114 * <p>115 * Example :116 * <pre><code class='java'> // you can express expected OffsetTime as String (AssertJ taking care of the conversion)117 * assertThat(parse("12:00:00Z")).isBeforeOrEqualTo("12:00:00Z")118 * .isBeforeOrEqualTo("13:00:00Z");</code></pre>119 *120 * @param offsetTimeAsString String representing a {@link java.time.OffsetTime}.121 * @return this assertion object.122 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.123 * @throws IllegalArgumentException if given String is null or can't be converted to a {@link java.time.OffsetTime}.124 * @throws AssertionError if the actual {@code OffsetTime} is not before or equals to the {@link java.time.OffsetTime}125 * built from given String.126 */127 public SELF isBeforeOrEqualTo(String offsetTimeAsString) {128 assertOffsetTimeAsStringParameterIsNotNull(offsetTimeAsString);129 return isBeforeOrEqualTo(parse(offsetTimeAsString));130 }131 /**132 * Verifies that the actual {@code OffsetTime} is after or equals to the given one.133 * <p>134 * Example :135 * <pre><code class='java'> assertThat(parse("13:00:00Z")).isAfterOrEqualTo(parse("13:00:00Z"))136 * .isAfterOrEqualTo(parse("12:00:00Z"));</code></pre>137 *138 * @param other the given {@link java.time.OffsetTime}.139 * @return this assertion object.140 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.141 * @throws IllegalArgumentException if other {@code OffsetTime} is {@code null}.142 * @throws AssertionError if the actual {@code OffsetTime} is not after or equals to the given one.143 */144 public SELF isAfterOrEqualTo(OffsetTime other) {145 Objects.instance().assertNotNull(info, actual);146 assertOffsetTimeParameterIsNotNull(other);147 if (actual.isBefore(other)) {148 throw Failures.instance().failure(info, shouldBeAfterOrEqualTo(actual, other));149 }150 return myself;151 }152 /**153 * Same assertion as {@link #isAfterOrEqualTo(java.time.OffsetTime)} but the {@link java.time.OffsetTime} is built154 * from given155 * String, which must follow <a href=156 * "http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_OFFSET_TIME"157 * >ISO OffsetTime format</a> to allow calling {@link java.time.OffsetTime#parse(CharSequence)} method.158 * <p>159 * Example :160 * <pre><code class='java'> // you can express expected OffsetTime as String (AssertJ taking care of the conversion)161 * assertThat(parse("13:00:00Z")).isAfterOrEqualTo("13:00:00Z")162 * .isAfterOrEqualTo("12:00:00Z");</code></pre>163 *164 * @param offsetTimeAsString String representing a {@link java.time.OffsetTime}.165 * @return this assertion object.166 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.167 * @throws IllegalArgumentException if given String is null or can't be converted to a {@link java.time.OffsetTime}.168 * @throws AssertionError if the actual {@code OffsetTime} is not after or equals to the {@link java.time.OffsetTime}169 * built from170 * given String.171 */172 public SELF isAfterOrEqualTo(String offsetTimeAsString) {173 assertOffsetTimeAsStringParameterIsNotNull(offsetTimeAsString);174 return isAfterOrEqualTo(parse(offsetTimeAsString));175 }176 /**177 * Verifies that the actual {@code OffsetTime} is <b>strictly</b> after the given one.178 * <p>179 * Example :180 * <pre><code class='java'> assertThat(parse("13:00:00Z")).isAfter(parse("12:00:00Z"));</code></pre>181 *182 * @param other the given {@link java.time.OffsetTime}.183 * @return this assertion object.184 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.185 * @throws IllegalArgumentException if other {@code OffsetTime} is {@code null}.186 * @throws AssertionError if the actual {@code OffsetTime} is not strictly after the given one.187 */188 public SELF isAfter(OffsetTime other) {189 Objects.instance().assertNotNull(info, actual);190 assertOffsetTimeParameterIsNotNull(other);191 if (!actual.isAfter(other)) {192 throw Failures.instance().failure(info, shouldBeAfter(actual, other));193 }194 return myself;195 }196 /**197 * Same assertion as {@link #isAfter(java.time.OffsetTime)} but the {@link java.time.OffsetTime} is built from given a198 * String that199 * must follow <a href=200 * "http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_OFFSET_TIME"201 * >ISO OffsetTime format</a> to allow calling {@link java.time.OffsetTime#parse(CharSequence)} method.202 * <p>203 * Example :204 * <pre><code class='java'> // you can express expected OffsetTime as String (AssertJ taking care of the conversion)205 * assertThat(parse("13:00:00Z")).isAfter("12:00:00Z");</code></pre>206 *207 * @param offsetTimeAsString String representing a {@link java.time.OffsetTime}.208 * @return this assertion object.209 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.210 * @throws IllegalArgumentException if given String is null or can't be converted to a {@link java.time.OffsetTime}.211 * @throws AssertionError if the actual {@code OffsetTime} is not strictly after the {@link java.time.OffsetTime}212 * built from given String.213 */214 public SELF isAfter(String offsetTimeAsString) {215 assertOffsetTimeAsStringParameterIsNotNull(offsetTimeAsString);216 return isAfter(parse(offsetTimeAsString));217 }218 /**219 * Same assertion as {@link #isEqualTo(Object)} (where Object is expected to be {@link java.time.OffsetTime}) but here220 * you221 * pass {@link java.time.OffsetTime} String representation that must follow <a href=222 * "http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_OFFSET_TIME"223 * >ISO OffsetTime format</a> to allow calling {@link java.time.OffsetTime#parse(CharSequence)} method.224 * <p>225 * Example :226 * <pre><code class='java'> // you can express expected OffsetTime as String (AssertJ taking care of the conversion)227 * assertThat(parse("13:00:00Z")).isEqualTo("13:00:00Z");</code></pre>228 *229 * @param offsetTimeAsString String representing a {@link java.time.OffsetTime}.230 * @return this assertion object.231 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.232 * @throws IllegalArgumentException if given String is null or can't be converted to a {@link java.time.OffsetTime}.233 * @throws AssertionError if the actual {@code OffsetTime} is not equal to the {@link java.time.OffsetTime} built from234 * given String.235 */236 public SELF isEqualTo(String offsetTimeAsString) {237 assertOffsetTimeAsStringParameterIsNotNull(offsetTimeAsString);238 return isEqualTo(parse(offsetTimeAsString));239 }240 /**241 * Same assertion as {@link #isNotEqualTo(Object)} (where Object is expected to be {@link java.time.OffsetTime}) but242 * here you243 * pass {@link java.time.OffsetTime} String representation that must follow <a href=244 * "http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_OFFSET_TIME"245 * >ISO OffsetTime format</a> to allow calling {@link java.time.OffsetTime#parse(CharSequence)} method.246 * <p>247 * Example :248 * <pre><code class='java'> // you can express expected OffsetTime as String (AssertJ taking care of the conversion)249 * assertThat(parse("13:00:00Z")).isNotEqualTo("12:00:00Z");</code></pre>250 *251 * @param offsetTimeAsString String representing a {@link java.time.OffsetTime}.252 * @return this assertion object.253 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.254 * @throws IllegalArgumentException if given String is null or can't be converted to a {@link java.time.OffsetTime}.255 * @throws AssertionError if the actual {@code OffsetTime} is equal to the {@link java.time.OffsetTime} built from256 * given String.257 */258 public SELF isNotEqualTo(String offsetTimeAsString) {259 assertOffsetTimeAsStringParameterIsNotNull(offsetTimeAsString);260 return isNotEqualTo(parse(offsetTimeAsString));261 }262 /**263 * Same assertion as {@link #isIn(Object...)} (where Objects are expected to be {@link java.time.OffsetTime}) but here264 * you265 * pass {@link java.time.OffsetTime} String representations that must follow <a href=266 * "http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_OFFSET_TIME"267 * >ISO OffsetTime format</a> to allow calling {@link java.time.OffsetTime#parse(CharSequence)} method.268 * <p>269 * Example :270 * <pre><code class='java'> // you can express expected OffsetTimes as String (AssertJ taking care of the conversion)271 * assertThat(parse("13:00:00Z")).isIn("12:00:00Z", "13:00:00Z");</code></pre>272 *273 * @param offsetTimesAsString String array representing {@link java.time.OffsetTime}s.274 * @return this assertion object.275 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.276 * @throws IllegalArgumentException if given String is null or can't be converted to a {@link java.time.OffsetTime}.277 * @throws AssertionError if the actual {@code OffsetTime} is not in the {@link java.time.OffsetTime}s built from278 * given Strings.279 */280 public SELF isIn(String... offsetTimesAsString) {281 checkIsNotNullAndNotEmpty(offsetTimesAsString);282 return isIn(convertToOffsetTimeArray(offsetTimesAsString));283 }284 /**285 * Same assertion as {@link #isNotIn(Object...)} (where Objects are expected to be {@link java.time.OffsetTime}) but286 * here you287 * pass {@link java.time.OffsetTime} String representations that must follow <a href=288 * "http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_OFFSET_TIME"289 * >ISO OffsetTime format</a> to allow calling {@link java.time.OffsetTime#parse(CharSequence)} method.290 * <p>291 * Example :292 * <pre><code class='java'> // you can express expected OffsetTimes as String (AssertJ taking care of the conversion)293 * assertThat(parse("13:00:00Z")).isNotIn("12:00:00Z", "14:00:00Z");</code></pre>294 *295 * @param offsetTimesAsString Array of String representing a {@link java.time.OffsetTime}.296 * @return this assertion object.297 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.298 * @throws IllegalArgumentException if given String is null or can't be converted to a {@link java.time.OffsetTime}.299 * @throws AssertionError if the actual {@code OffsetTime} is in the {@link java.time.OffsetTime}s built from given300 * Strings.301 */302 public SELF isNotIn(String... offsetTimesAsString) {303 checkIsNotNullAndNotEmpty(offsetTimesAsString);304 return isNotIn(convertToOffsetTimeArray(offsetTimesAsString));305 }306 private static Object[] convertToOffsetTimeArray(String... offsetTimesAsString) {307 OffsetTime[] dates = new OffsetTime[offsetTimesAsString.length];308 for (int i = 0; i < offsetTimesAsString.length; i++) {309 dates[i] = OffsetTime.parse(offsetTimesAsString[i]);310 }311 return dates;312 }313 private void checkIsNotNullAndNotEmpty(Object[] values) {314 checkArgument(values != null, "The given OffsetTime array should not be null");315 checkArgument(values.length > 0, "The given OffsetTime array should not be empty");316 }317 /**318 * Check that the {@link java.time.OffsetTime} string representation to compare actual {@link java.time.OffsetTime} to319 * is not null,320 * otherwise throws a {@link IllegalArgumentException} with an explicit message321 *322 * @param OffsetTimeAsString String representing the {@link java.time.OffsetTime} to compare actual with323 * @throws IllegalArgumentException with an explicit message if the given {@link String} is null324 */325 private static void assertOffsetTimeAsStringParameterIsNotNull(String OffsetTimeAsString) {326 checkArgument(OffsetTimeAsString != null,327 "The String representing the OffsetTime to compare actual with should not be null");328 }329 /**330 * Check that the {@link java.time.OffsetTime} to compare actual {@link java.time.OffsetTime} to is not null, in that331 * case throws a {@link IllegalArgumentException} with an explicit message332 *333 * @param other the {@link java.time.OffsetTime} to check334 * @throws IllegalArgumentException with an explicit message if the given {@link java.time.OffsetTime} is null335 */336 private static void assertOffsetTimeParameterIsNotNull(OffsetTime other) {337 checkArgument(other != null, "The OffsetTime to compare actual with should not be null");338 }339 /**340 * Verifies that actual and given {@code OffsetTime} have same hour, minute and second fields (nanosecond fields are341 * ignored in comparison).342 * <p>343 * Assertion can fail with OffsetTimes in same chronological nanosecond time window, e.g :344 * <p>345 * 23:00:<b>01.000000000</b>+01:00 and 23:00:<b>00.999999999</b>+01:00.346 * <p>347 * Assertion fails as second fields differ even if time difference is only 1ns.348 * <p>349 * Code example :350 * <pre><code class='java'> // successful assertions351 * OffsetTime OffsetTime1 = OffsetTime.of(12, 0, 1, 0, ZoneOffset.UTC);352 * OffsetTime OffsetTime2 = OffsetTime.of(12, 0, 1, 456, ZoneOffset.UTC);353 * assertThat(OffsetTime1).isEqualToIgnoringNanos(OffsetTime2);354 *355 * // failing assertions (even if time difference is only 1ns)356 * OffsetTime OffsetTimeA = OffsetTime.of(12, 0, 1, 0, ZoneOffset.UTC);357 * OffsetTime OffsetTimeB = OffsetTime.of(12, 0, 0, 999999999, ZoneOffset.UTC);358 * assertThat(OffsetTimeA).isEqualToIgnoringNanos(OffsetTimeB);</code></pre>359 *360 * @param other the given {@link java.time.OffsetTime}.361 * @return this assertion object.362 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.363 * @throws IllegalArgumentException if other {@code OffsetTime} is {@code null}.364 * @throws AssertionError if the actual {@code OffsetTime} is not equal with nanoseconds ignored.365 */366 public SELF isEqualToIgnoringNanos(OffsetTime other) {367 Objects.instance().assertNotNull(info, actual);368 assertOffsetTimeParameterIsNotNull(other);369 if (!areEqualIgnoringNanos(actual, other)) {370 throw Failures.instance().failure(info, shouldBeEqualIgnoringNanos(actual, other));371 }372 return myself;373 }374 /**375 * Verifies that actual and given {@link java.time.OffsetTime} have same hour and minute fields (second and nanosecond376 * fields are377 * ignored in comparison).378 * <p>379 * Assertion can fail with OffsetTimes in same chronological second time window, e.g :380 * <p>381 * 23:<b>01:00</b>.000+01:00 and 23:<b>00:59</b>.000+01:00.382 * <p>383 * Assertion fails as minute fields differ even if time difference is only 1s.384 * <p>385 * Code example :386 * <pre><code class='java'> // successful assertions387 * OffsetTime OffsetTime1 = OffsetTime.of(23, 50, 0, 0, ZoneOffset.UTC);388 * OffsetTime OffsetTime2 = OffsetTime.of(23, 50, 10, 456, ZoneOffset.UTC);389 * assertThat(OffsetTime1).isEqualToIgnoringSeconds(OffsetTime2);390 *391 * // failing assertions (even if time difference is only 1ms)392 * OffsetTime OffsetTimeA = OffsetTime.of(23, 50, 00, 000, ZoneOffset.UTC);393 * OffsetTime OffsetTimeB = OffsetTime.of(23, 49, 59, 999, ZoneOffset.UTC);394 * assertThat(OffsetTimeA).isEqualToIgnoringSeconds(OffsetTimeB);</code></pre>395 *396 * @param other the given {@link java.time.OffsetTime}.397 * @return this assertion object.398 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.399 * @throws IllegalArgumentException if other {@code OffsetTime} is {@code null}.400 * @throws AssertionError if the actual {@code OffsetTime} is not equal with second and nanosecond fields401 * ignored.402 */403 public SELF isEqualToIgnoringSeconds(OffsetTime other) {404 Objects.instance().assertNotNull(info, actual);405 assertOffsetTimeParameterIsNotNull(other);406 if (!areEqualIgnoringSeconds(actual, other)) {407 throw Failures.instance().failure(info, shouldBeEqualIgnoringSeconds(actual, other));408 }409 return myself;410 }411 /**412 * Verifies that actual and given {@link java.time.OffsetTime} have same hour, minute, second and nanosecond fields).413 * <p>414 * Code examples :415 * <pre><code class='java'> // successful assertions416 * OffsetTime offsetTime = OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC);417 * OffsetTime offsetTime2 = OffsetTime.of(12, 0, 0, 0, ZoneOffset.MAX);418 * assertThat(offsetTime).isEqualToIgnoringTimezone(offsetTime2);419 *420 * // failing assertions (even if time difference is only 1ms)421 * OffsetTime offsetTime = OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC);422 * OffsetTime offsetTime2 = OffsetTime.of(12, 1, 0, 0, ZoneOffset.UTC);423 * assertThat(offsetTime).isEqualToIgnoringTimezone(offsetTime2); </code></pre>424 *425 * @param other the given {@link java.time.OffsetTime}.426 * @return this assertion object.427 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.428 * @throws IllegalArgumentException if other {@code OffsetTime} is {@code null}.429 * @throws AssertionError if the actual {@code OffsetTime} is not equal with timezone ignored.430 */431 public SELF isEqualToIgnoringTimezone(OffsetTime other) {432 Objects.instance().assertNotNull(info, actual);433 assertOffsetTimeParameterIsNotNull(other);434 if (!areEqualIgnoringTimezone(actual, other)) {435 throw Failures.instance().failure(info, shouldBeEqualIgnoringTimezone(actual, other));436 }437 return myself;438 }439 /**440 * Verifies that actual and given {@code OffsetTime} have same hour fields (minute, second and nanosecond fields are441 * ignored in comparison).442 * <p>443 * Assertion can fail with OffsetTimes in same chronological second time window, e.g :444 * <p>445 * <b>01:00</b>:00.000+01:00 and <b>00:59:59</b>.000+01:00.446 * <p>447 * Time difference is only 1s but hour fields differ.448 * <p>449 * Code example :450 * <pre><code class='java'> // successful assertions451 * OffsetTime OffsetTime1 = OffsetTime.of(23, 50, 0, 0, ZoneOffset.UTC);452 * OffsetTime OffsetTime2 = OffsetTime.of(23, 00, 2, 7, ZoneOffset.UTC);453 * assertThat(OffsetTime1).hasSameHourAs(OffsetTime2);454 *455 * // failing assertions (even if time difference is only 1ms)456 * OffsetTime OffsetTimeA = OffsetTime.of(01, 00, 00, 000, ZoneOffset.UTC);457 * OffsetTime OffsetTimeB = OffsetTime.of(00, 59, 59, 999, ZoneOffset.UTC);458 * assertThat(OffsetTimeA).hasSameHourAs(OffsetTimeB); </code></pre>459 *460 * @param other the given {@link java.time.OffsetTime}.461 * @return this assertion object.462 * @throws AssertionError if the actual {@code OffsetTime} is {@code null}.463 * @throws IllegalArgumentException if other {@code OffsetTime} is {@code null}.464 * @throws AssertionError if the actual {@code OffsetTime} is not equal ignoring minute, second and nanosecond465 * fields.466 */467 public SELF hasSameHourAs(OffsetTime other) {468 Objects.instance().assertNotNull(info, actual);469 assertOffsetTimeParameterIsNotNull(other);470 if (!haveSameHourField(actual, other)) {471 throw Failures.instance().failure(info, shouldHaveSameHourAs(actual, other));472 }473 return myself;474 }475 /**476 * Verifies that the actual {@link OffsetTime} is in the [start, end] period (start and end included).477 * <p>478 * Example:479 * <pre><code class='java'> OffsetTime offsetTime = OffsetTime.now();480 *481 * // assertions succeed:482 * assertThat(offsetTime).isBetween(offsetTime.minusSeconds(1), offsetTime.plusSeconds(1))483 * .isBetween(offsetTime, offsetTime.plusSeconds(1))484 * .isBetween(offsetTime.minusSeconds(1), offsetTime)485 * .isBetween(offsetTime, offsetTime);486 *487 * // assertions fail:488 * assertThat(offsetTime).isBetween(offsetTime.minusSeconds(10), offsetTime.minusSeconds(1));489 * assertThat(offsetTime).isBetween(offsetTime.plusSeconds(1), offsetTime.plusSeconds(10));</code></pre>490 *491 * @param startInclusive the start value (inclusive), expected not to be null.492 * @param endInclusive the end value (inclusive), expected not to be null.493 * @return this assertion object.494 * @throws AssertionError if the actual value is {@code null}.495 * @throws NullPointerException if start value is {@code null}.496 * @throws NullPointerException if end value is {@code null}.497 * @throws AssertionError if the actual value is not in [start, end] period.498 *499 * @since 3.7.1500 */501 public SELF isBetween(OffsetTime startInclusive, OffsetTime endInclusive) {502 comparables.assertIsBetween(info, actual, startInclusive, endInclusive, true, true);503 return myself;504 }505 /**506 * Same assertion as {@link #isBetween(OffsetTime, OffsetTime)} but here you pass {@link OffsetTime} String representations507 * which must follow <a href="http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_OFFSET_TIME">ISO OffsetTime format</a>508 * to allow calling {@link OffsetTime#parse(CharSequence)} method.509 * <p>510 * Example:511 * <pre><code class='java'> OffsetTime oneAm = OffsetTime.parse("01:00:00+02:00");512 *513 * // assertions succeed:514 * assertThat(oneAm).isBetween("00:59:59+02:00", "01:00:01+02:00")515 * .isBetween("01:00:00+02:00", "01:00:01+02:00")516 * .isBetween("00:59:59+02:00", "01:00:00+02:00")517 * .isBetween("01:00:00+02:00", "01:00:00+02:00")518 *519 * // assertion fails:520 * assertThat(oneAm).isBetween("01:00:01+02:00", "02:00:01+02:00");</code></pre>521 *522 * @param startInclusive the start value (inclusive), expected not to be null.523 * @param endInclusive the end value (inclusive), expected not to be null.524 * @return this assertion object.525 *526 * @throws AssertionError if the actual value is {@code null}.527 * @throws NullPointerException if start value is {@code null}.528 * @throws NullPointerException if end value is {@code null}.529 * @throws DateTimeParseException if any of the given String can't be converted to a {@link OffsetTime}.530 * @throws AssertionError if the actual value is not in [start, end] period.531 *532 * @since 3.7.1533 */534 public SELF isBetween(String startInclusive, String endInclusive) {535 return isBetween(parse(startInclusive), parse(endInclusive));536 }537 /**538 * Verifies that the actual {@link OffsetTime} is in the ]start, end[ period (start and end excluded).539 * <p>540 * Example:541 * <pre><code class='java'> OffsetTime offsetTime = OffsetTime.now();542 *543 * // assertion succeeds:544 * assertThat(offsetTime).isStrictlyBetween(offsetTime.minusSeconds(1), offsetTime.plusSeconds(1));545 *546 * // assertions fail:547 * assertThat(offsetTime).isStrictlyBetween(offsetTime.minusSeconds(10), offsetTime.minusSeconds(1));548 * assertThat(offsetTime).isStrictlyBetween(offsetTime.plusSeconds(1), offsetTime.plusSeconds(10));549 * assertThat(offsetTime).isStrictlyBetween(offsetTime, offsetTime.plusSeconds(1));550 * assertThat(offsetTime).isStrictlyBetween(offsetTime.minusSeconds(1), offsetTime);</code></pre>551 *552 * @param startExclusive the start value (exclusive), expected not to be null.553 * @param endExclusive the end value (exclusive), expected not to be null.554 * @return this assertion object.555 * @throws AssertionError if the actual value is {@code null}.556 * @throws NullPointerException if start value is {@code null}.557 * @throws NullPointerException if end value is {@code null}.558 * @throws AssertionError if the actual value is not in ]start, end[ period.559 *560 * @since 3.7.1561 */562 public SELF isStrictlyBetween(OffsetTime startExclusive, OffsetTime endExclusive) {563 comparables.assertIsBetween(info, actual, startExclusive, endExclusive, false, false);564 return myself;565 }566 /**567 * Same assertion as {@link #isStrictlyBetween(OffsetTime, OffsetTime)} but here you pass {@link OffsetTime} String representations568 * which must follow <a href="http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_OFFSET_TIME">ISO OffsetTime format</a>569 * to allow calling {@link OffsetTime#parse(CharSequence)} method.570 * <p>571 * Example:572 * <pre><code class='java'> OffsetTime oneAm = OffsetTime.parse("01:00:00+02:00");573 *574 * // assertion succeeds:575 * assertThat(oneAm).isStrictlyBetween("00:59:59+02:00", "01:00:01+02:00");576 *577 * // assertions fail:578 * assertThat(oneAm).isStrictlyBetween("02:00:00+02:00", "03:00:00+02:00");579 * assertThat(oneAm).isStrictlyBetween("00:59:59+02:00", "01:00:00+02:00");580 * assertThat(oneAm).isStrictlyBetween("01:00:00+02:00", "01:00:01+02:00");</code></pre>581 *582 * @param startExclusive the start value (exclusive), expected not to be null.583 * @param endExclusive the end value (exclusive), expected not to be null.584 * @return this assertion object.585 *586 * @throws AssertionError if the actual value is {@code null}.587 * @throws NullPointerException if start value is {@code null}.588 * @throws NullPointerException if end value is {@code null}.589 * @throws DateTimeParseException if any of the given String can't be converted to a {@link OffsetTime}.590 * @throws AssertionError if the actual value is not in ]start, end[ period.591 *592 * @since 3.7.1593 */594 public SELF isStrictlyBetween(String startExclusive, String endExclusive) {595 return isStrictlyBetween(parse(startExclusive), parse(endExclusive));596 }597 /**598 * {@inheritDoc}599 */600 @Override601 protected OffsetTime parse(String offsetTimeAsString) {602 return OffsetTime.parse(offsetTimeAsString);603 }604 /**605 * Returns true if both OffsetTime are in the same hour, minute and second, false606 * otherwise.607 *608 * @param actual the actual OffsetTime. expected not be null609 * @param other the other OffsetTime. expected not be null610 * @return true if both OffsetTime are in the same year, month and day of month, hour, minute and second, false611 * otherwise.612 */613 private static boolean areEqualIgnoringNanos(OffsetTime actual, OffsetTime other) {614 return areEqualIgnoringSeconds(actual, other) && haveSameSecond(actual, other);615 }616 /**...

Full Screen

Full Screen

parse

Using AI Code Generation

copy

Full Screen

1import java.time.OffsetTime;2import java.time.ZoneOffset;3import org.assertj.core.api.Assertions;4public class OffsetTimeAssertionDemo {5 public static void main(String[] args) {6 OffsetTime offsetTime = OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC);7 Assertions.assertThat(offsetTime)8 .hasHour(12)9 .hasMinute(0)10 .hasSecond(0)11 .hasNano(0)12 .hasOffset(ZoneOffset.UTC);13 }14}

Full Screen

Full Screen

parse

Using AI Code Generation

copy

Full Screen

1Time time = new Time(12, 0, 0);2OffsetTime offsetTime = OffsetTime.of(time, ZoneOffset.ofHours(2));3OffsetTime expected = OffsetTime.of(time, ZoneOffset.ofHours(1));4assertThat(offsetTime).isEqualTo(expected, within(1, ChronoUnit.HOURS));5assertThat(offsetTime).isEqualTo(expected, within(2, ChronoUnit.HOURS));6public class OffsetTimeAssertBaseTest {7 private OffsetTimeAssert assertions;8 public void setUp() {9 OffsetTime offsetTime = OffsetTime.of(LocalTime.of(3, 0, 5), ZoneOffset.ofHours(1));10 assertions = new OffsetTimeAssert(offsetTime);11 }12 public void testIsEqualTo() {13 OffsetTime offsetTime = OffsetTime.of(LocalTime.of(3, 0, 5), ZoneOffset.ofHours(1));14 Assertions.assertThat(assertions.isEqualTo(offsetTime)).isTrue();15 Assertions.assertThat(assertions.isEqualTo(offsetTime)).isTrue();16 }17 public void testIsNotEqualTo() {18 OffsetTime offsetTime = OffsetTime.of(LocalTime.of(3, 0, 5), ZoneOffset.ofHours(2));19 Assertions.assertThat(assertions.isNotEqualTo(offsetTime)).isTrue();20 }21 public void testIsEqualToIgnoringSeconds() {22 OffsetTime offsetTime = OffsetTime.of(LocalTime.of(3, 0, 0), ZoneOffset.ofHours(1));23 Assertions.assertThat(assertions.isEqualToIgnoringSeconds(offsetTime)).isTrue();24 }25 public void testIsNotEqualToIgnoringSeconds() {26 OffsetTime offsetTime = OffsetTime.of(LocalTime.of(3, 0, 0), ZoneOffset.ofHours(2));27 Assertions.assertThat(assertions.isNotEqualToIgnoringSeconds(offsetTime)).isTrue();28 }29 public void testIsEqualToIgnoringNanos() {30 OffsetTime offsetTime = OffsetTime.of(LocalTime.of(3, 0, 5, 0), ZoneOffset.ofHours(1));

Full Screen

Full Screen

parse

Using AI Code Generation

copy

Full Screen

1import static org.assertj.core.api.Assertions.*;2import java.time.OffsetTime;3import org.junit.Test;4public class AbstractOffsetTimeAssert_parse_Test {5 public void parse_assertion() {6 OffsetTime offsetTime = OffsetTime.parse("10:15:30+01:00");7 assertThat(offsetTime).isEqualTo("10:15:30+01:00");8 }9}10package org.kodejava.example.assertj;11import static org.assertj.core.api.Assertions.assertThat;12import java.time.OffsetTime;13import java.time.format.DateTimeFormatter;14import org.junit.Test;15public class AbstractOffsetTimeAssert_parse_Format_Test {16 public void parse_format_assertion() {17 OffsetTime offsetTime = OffsetTime.parse("10:15:30+01:00",18 DateTimeFormatter.ISO_OFFSET_TIME);19 assertThat(offsetTime).isEqualTo("10:15:30+01:00");20 }21}221. AssertJ OffsetTimeAssert isEqualTo() example 2. AssertJ OffsetTimeAssert isEqualToIgnoringNanos() example 3. AssertJ OffsetTimeAssert isEqualToIgnoringSeconds() example 4. AssertJ OffsetTimeAssert isEqualToIgnoringMillis() example 5. AssertJ OffsetTimeAssert isEqualToIgnoringHours() example 6. AssertJ OffsetTimeAssert isEqualToIgnoringMinutes() example 7. AssertJ OffsetTimeAssert isBefore() example 8. AssertJ OffsetTimeAssert isAfter() example 9. AssertJ OffsetTimeAssert isBetween() example 10. AssertJ OffsetTimeAssert isStrictlyBetween() example 11. AssertJ OffsetTimeAssert isNotEqualTo() example 12. AssertJ OffsetTimeAssert isNotBetween() example 13. AssertJ OffsetTimeAssert isNotStrictlyBetween() example 14. AssertJ OffsetTimeAssert isBeforeOrEqualTo() example 15. Assert

Full Screen

Full Screen

parse

Using AI Code Generation

copy

Full Screen

1import static org.assertj.core.api.Assertions.assertThat;2import java.time.OffsetTime;3public class OffsetTimeAssertParseExample {4 public static void main(String[] args) {5 OffsetTime offsetTime = OffsetTime.parse("09:30:00+02:00");6 assertThat(offsetTime).isEqualTo(OffsetTime.parse("09:30:00+02:00"));7 }8}9 at org.junit.Assert.assertEquals(Assert.java:115)10 at org.junit.Assert.assertEquals(Assert.java:144)11 at OffsetTimeAssertParseExample.main(OffsetTimeAssertParseExample.java:10)12 at org.junit.Assert.assertEquals(Assert.java:115)13 at org.junit.Assert.assertEquals(Assert.java:144)14 at OffsetTimeAssertParseExample.main(OffsetTimeAssertParseExample.java:10)15import static org.assertj.core.api.Assertions.assertThat;16import java.time.OffsetTime;17public class OffsetTimeAssertParseExample {18 public static void main(String[] args) {19 OffsetTime offsetTime = OffsetTime.parse("09:30:00+02:00");20 assertThat(offsetTime).isEqualTo(OffsetTime.parse("09:30:00+02:00"));21 }22}23 at org.junit.Assert.assertEquals(Assert.java:115)24 at org.junit.Assert.assertEquals(Assert.java:144)25 at OffsetTimeAssertParseExample.main(OffsetTimeAssertParseExample.java:10)26 at org.junit.Assert.assertEquals(Assert.java:115)27 at org.junit.Assert.assertEquals(Assert.java

Full Screen

Full Screen

parse

Using AI Code Generation

copy

Full Screen

1 String[] actual = new String[lines.length];2 for (int i = 0; i < lines.length; i++) {3 }4 assertArrayEquals(expected, actual);5 }6}7public class LineCounter {8 public static void main(String[] args) throws IOException {9 File file = new File("C:\\Users\\user\\IdeaProjects\\LineCounter\\src\\test\\resources\\file.txt");10 int counter = 0;

Full Screen

Full Screen

parse

Using AI Code Generation

copy

Full Screen

1assertThat(offsetTime).isEqualTo(parse("10:15:30+01:00"));2assertThat(offsetTime).isEqualToIgnoringNanos(parse("10:15:30+01:00"));3assertThat(offsetTime).isEqualToIgnoringSeconds(parse("10:15:30+01:00"));4assertThat(offsetTime).isEqualToIgnoringHours(parse("10:15:30+01:00"));5assertThat(offsetTime).isEqualToIgnoringMinutes(parse("10:15:30+01:00"));6assertThat(offsetTime).isEqualToIgnoringNanos(parse("10:15:30+01:00"));

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