public abstract class AbstractLocalTimeAssert<S extends AbstractLocalTimeAssert<S>> extends AbstractAssert<S,java.time.LocalTime>
LocalTime type from new Date & Time API introduced in Java 8.| Modifier and Type | Field and Description |
|---|---|
static String |
NULL_LOCAL_TIME_PARAMETER_MESSAGE |
actual, info, myself| Modifier | Constructor and Description |
|---|---|
protected |
AbstractLocalTimeAssert(java.time.LocalTime actual,
Class<?> selfType)
Creates a new
. |
| Modifier and Type | Method and Description |
|---|---|
protected java.time.LocalTime |
getActual() |
S |
hasSameHourAs(java.time.LocalTime other)
Verifies that actual and given
LocalTime have same hour fields (minute, second and nanosecond fields are
ignored in comparison). |
S |
isAfter(java.time.LocalTime other)
Verifies that the actual
LocalTime is strictly after the given one. |
S |
isAfter(String localTimeAsString)
Same assertion as
isAfter(LocalTime) but the LocalTime is built from given a String that
must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method. |
S |
isAfterOrEqualTo(java.time.LocalTime other)
Verifies that the actual
LocalTime is after or equals to the given one. |
S |
isAfterOrEqualTo(String localTimeAsString)
Same assertion as
isAfterOrEqualTo(LocalTime) but the LocalTime is built from given
String, which must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method. |
S |
isBefore(java.time.LocalTime other)
Verifies that the actual
LocalTime is strictly before the given one. |
S |
isBefore(String localTimeAsString)
Same assertion as
isBefore(LocalTime) but the LocalTime is built from given String, which
must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method. |
S |
isBeforeOrEqualTo(java.time.LocalTime other)
Verifies that the actual
LocalTime is before or equals to the given one. |
S |
isBeforeOrEqualTo(String localTimeAsString)
Same assertion as
isBeforeOrEqualTo(LocalTime) but the LocalTime is built from given
String, which must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method. |
S |
isEqualTo(String localTimeAsString)
Same assertion as
AbstractAssert.isEqualTo(Object) (where Object is expected to be LocalTime) but here you
pass LocalTime String representation that must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method. |
S |
isEqualToIgnoringNanos(java.time.LocalTime other)
Verifies that actual and given
LocalTime have same hour, minute and second fields (nanosecond fields are
ignored in comparison). |
S |
isEqualToIgnoringSeconds(java.time.LocalTime other)
Verifies that actual and given
LocalTime have same hour and minute fields (second and nanosecond fields are
ignored in comparison). |
S |
isIn(String... localTimesAsString)
Same assertion as
AbstractAssert.isIn(Object...) (where Objects are expected to be LocalTime) but here you
pass LocalTime String representations that must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method. |
S |
isNotEqualTo(String localTimeAsString)
Same assertion as
AbstractAssert.isNotEqualTo(Object) (where Object is expected to be LocalTime) but here you
pass LocalTime String representation that must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method. |
S |
isNotIn(String... localTimesAsString)
Same assertion as
AbstractAssert.isNotIn(Object...) (where Objects are expected to be LocalTime) but here you
pass LocalTime String representations that must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method. |
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failure, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, overridingErrorMessage, usingComparator, usingDefaultComparator, withThreadDumpOnErrorpublic static final String NULL_LOCAL_TIME_PARAMETER_MESSAGE
protected AbstractLocalTimeAssert(java.time.LocalTime actual,
Class<?> selfType)
AbstractLocalTimeAssert.selfType - the "self type"actual - the actual value to verifyprotected java.time.LocalTime getActual()
public S isBefore(java.time.LocalTime other)
LocalTime is strictly before the given one.
Example :
assertThat(parse("12:00:00")).isBefore(parse("13:00:00"));
other - the given LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if other LocalTime is null.AssertionError - if the actual LocalTime is not strictly before the given one.public S isBefore(String localTimeAsString)
isBefore(LocalTime) but the LocalTime is built from given String, which
must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method.
Example :
// you can express expected LocalTime as String (AssertJ taking care of the conversion)
assertThat(parse("12:59")).isBefore("13:00");
localTimeAsString - String representing a LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if given String is null or can't be converted to a LocalTime.AssertionError - if the actual LocalTime is not strictly before the LocalTime built
from given String.public S isBeforeOrEqualTo(java.time.LocalTime other)
LocalTime is before or equals to the given one.
Example :
assertThat(parse("12:00:00")).isBeforeOrEqualTo(parse("12:00:00"))
.isBeforeOrEqualTo(parse("12:00:01"));
other - the given LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if other LocalTime is null.AssertionError - if the actual LocalTime is not before or equals to the given one.public S isBeforeOrEqualTo(String localTimeAsString)
isBeforeOrEqualTo(LocalTime) but the LocalTime is built from given
String, which must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method.
Example :
// you can express expected LocalTime as String (AssertJ taking care of the conversion)
assertThat(parse("12:00:00")).isBeforeOrEqualTo("12:00:00")
.isBeforeOrEqualTo("13:00:00");
localTimeAsString - String representing a LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if given String is null or can't be converted to a LocalTime.AssertionError - if the actual LocalTime is not before or equals to the LocalTime built from
given String.public S isAfterOrEqualTo(java.time.LocalTime other)
LocalTime is after or equals to the given one.
Example :
assertThat(parse("13:00:00")).isAfterOrEqualTo(parse("13:00:00"))
.isAfterOrEqualTo(parse("12:00:00"));
other - the given LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if other LocalTime is null.AssertionError - if the actual LocalTime is not after or equals to the given one.public S isAfterOrEqualTo(String localTimeAsString)
isAfterOrEqualTo(LocalTime) but the LocalTime is built from given
String, which must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method.
Example :
// you can express expected LocalTime as String (AssertJ taking care of the conversion)
assertThat(parse("13:00:00")).isAfterOrEqualTo("13:00:00")
.isAfterOrEqualTo("12:00:00");
localTimeAsString - String representing a LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if given String is null or can't be converted to a LocalTime.AssertionError - if the actual LocalTime is not after or equals to the LocalTime built from
given String.public S isAfter(java.time.LocalTime other)
LocalTime is strictly after the given one.
Example :
assertThat(parse("13:00:00")).isAfter(parse("12:00:00"));
other - the given LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if other LocalTime is null.AssertionError - if the actual LocalTime is not strictly after the given one.public S isAfter(String localTimeAsString)
isAfter(LocalTime) but the LocalTime is built from given a String that
must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method.
Example :
// you can express expected LocalTime as String (AssertJ taking care of the conversion)
assertThat(parse("13:00:00")).isAfter("12:00:00");
localTimeAsString - String representing a LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if given String is null or can't be converted to a LocalTime.AssertionError - if the actual LocalTime is not strictly after the LocalTime built
from given String.public S isEqualTo(String localTimeAsString)
AbstractAssert.isEqualTo(Object) (where Object is expected to be LocalTime) but here you
pass LocalTime String representation that must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method.
Example :
// you can express expected LocalTime as String (AssertJ taking care of the conversion)
assertThat(parse("13:00:00")).isEqualTo("13:00:00");
localTimeAsString - String representing a LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if given String is null or can't be converted to a LocalTime.AssertionError - if the actual LocalTime is not equal to the LocalTime built from
given String.public S isNotEqualTo(String localTimeAsString)
AbstractAssert.isNotEqualTo(Object) (where Object is expected to be LocalTime) but here you
pass LocalTime String representation that must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method.
Example :
// you can express expected LocalTime as String (AssertJ taking care of the conversion)
assertThat(parse("13:00:00")).isNotEqualTo("12:00:00");
localTimeAsString - String representing a LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if given String is null or can't be converted to a LocalTime.AssertionError - if the actual LocalTime is equal to the LocalTime built from given
String.public S isIn(String... localTimesAsString)
AbstractAssert.isIn(Object...) (where Objects are expected to be LocalTime) but here you
pass LocalTime String representations that must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method.
Example :
// you can express expected LocalTimes as String (AssertJ taking care of the conversion)
assertThat(parse("13:00:00")).isIn("12:00:00", "13:00:00");
localTimesAsString - String array representing LocalTimes.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if given String is null or can't be converted to a LocalTime.AssertionError - if the actual LocalTime is not in the LocalTimes built from given
Strings.public S isNotIn(String... localTimesAsString)
AbstractAssert.isNotIn(Object...) (where Objects are expected to be LocalTime) but here you
pass LocalTime String representations that must follow ISO LocalTime format to allow calling LocalTime.parse(CharSequence) method.
Example :
// you can express expected LocalTimes as String (AssertJ taking care of the conversion)
assertThat(parse("13:00:00")).isNotIn("12:00:00", "14:00:00");
localTimesAsString - Array of String representing a LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if given String is null or can't be converted to a LocalTime.AssertionError - if the actual LocalTime is in the LocalTimes built from given
Strings.public S isEqualToIgnoringNanos(java.time.LocalTime other)
LocalTime have same hour, minute and second fields (nanosecond fields are
ignored in comparison).
Assertion can fail with localTimes in same chronological nanosecond time window, e.g :
23:00:01.000000000 and 23:00:00.999999999.
Assertion fails as second fields differ even if time difference is only 1ns.
Code example :
// successfull assertions
LocalTime localTime1 = LocalTime.of(12, 0, 1, 0);
LocalTime localTime2 = LocalTime.of(12, 0, 1, 456);
assertThat(localTime1).isEqualToIgnoringNanos(localTime2);
// failing assertions (even if time difference is only 1ns)
LocalTime localTimeA = LocalTime.of(12, 0, 1, 0);
LocalTime localTimeB = LocalTime.of(12, 0, 0, 999999999);
assertThat(localTimeA).isEqualToIgnoringNanos(localTimeB);
other - the given LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if other LocalTime is null.AssertionError - if the actual LocalTime is are not equal with nanoseconds ignored.public S isEqualToIgnoringSeconds(java.time.LocalTime other)
LocalTime have same hour and minute fields (second and nanosecond fields are
ignored in comparison).
Assertion can fail with LocalTimes in same chronological second time window, e.g :
23:01:00.000 and 23:00:59.000.
Assertion fails as minute fields differ even if time difference is only 1s.
Code example :
// successful assertions
LocalTime localTime1 = LocalTime.of(23, 50, 0, 0);
LocalTime localTime2 = LocalTime.of(23, 50, 10, 456);
assertThat(localTime1).isEqualToIgnoringSeconds(localTime2);
// failing assertions (even if time difference is only 1ms)
LocalTime localTimeA = LocalTime.of(23, 50, 00, 000);
LocalTime localTimeB = LocalTime.of(23, 49, 59, 999);
assertThat(localTimeA).isEqualToIgnoringSeconds(localTimeB);
other - the given LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if other LocalTime is null.AssertionError - if the actual LocalTime is are not equal with second and nanosecond fields
ignored.public S hasSameHourAs(java.time.LocalTime other)
LocalTime have same hour fields (minute, second and nanosecond fields are
ignored in comparison).
Assertion can fail with localTimes in same chronological second time window, e.g :
01:00:00.000 and 00:59:59.000.
Time difference is only 1s but hour fields differ.
Code example :
// successful assertions
LocalTime localTime1 = LocalTime.of(23, 50, 0, 0);
LocalTime localTime2 = LocalTime.of(23, 00, 2, 7);
assertThat(localTime1).hasSameHourAs(localTime2);
// failing assertions (even if time difference is only 1ms)
LocalTime localTimeA = LocalTime.of(01, 00, 00, 000);
LocalTime localTimeB = LocalTime.of(00, 59, 59, 999);
assertThat(localTimeA).hasSameHourAs(localTimeB);
other - the given LocalTime.AssertionError - if the actual LocalTime is null.IllegalArgumentException - if other LocalTime is null.AssertionError - if the actual LocalTime is are not equal ignoring minute, second and nanosecond
fields.Copyright © 2014-2015 AssertJ. All Rights Reserved.