Package org.assertj.core.api
Class AbstractPeriodAssert<SELF extends AbstractPeriodAssert<SELF>>
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,Period>
org.assertj.core.api.AbstractPeriodAssert<SELF>
- All Implemented Interfaces:
Assert<SELF,
,Period> Descriptable<SELF>
,ExtensionPoints<SELF,
Period>
- Direct Known Subclasses:
PeriodAssert
public abstract class AbstractPeriodAssert<SELF extends AbstractPeriodAssert<SELF>>
extends AbstractAssert<SELF,Period>
Assertions for
Period
type.- Since:
- 3.17.0
- Author:
- Hayden Meloche
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractPeriodAssert
(Period period, Class<?> selfType) Creates a newAbstractPeriodAssert
-
Method Summary
Modifier and TypeMethodDescriptionhasDays
(int expectedDays) Verifies that the actualPeriod
has the given days.hasMonths
(int expectedMonths) Verifies that the actualPeriod
has the given months.hasYears
(int expectedYears) Verifies that the actualPeriod
has the given years.Verifies that the actualPeriod
is negative (i.e.Verifies that the actualPeriod
is positive (i.e.Methods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs, describedAs
-
Constructor Details
-
AbstractPeriodAssert
Creates a newAbstractPeriodAssert
- Parameters:
period
- the actual value to verifyselfType
- the "self type"
-
-
Method Details
-
hasYears
Verifies that the actualPeriod
has the given years.Example :
// assertion will pass assertThat(Period.ofYears(5)).hasYears(5); // assertion will fail assertThat(Period.ofYears(5)).hasYears(1);
- Parameters:
expectedYears
- the expected years value- Returns:
- this assertion object
- Throws:
AssertionError
- if the actualPeriod
isnull
AssertionError
- if the actualPeriod
does not have the given years- Since:
- 3.17.0
-
hasMonths
Verifies that the actualPeriod
has the given months.Example :
// assertion will pass assertThat(Period.ofMonths(5)).hasMonths(5); // assertion will fail assertThat(Period.ofMonths(5)).hasMonths(1);
- Parameters:
expectedMonths
- the expected months value- Returns:
- this assertion object
- Throws:
AssertionError
- if the actualPeriod
isnull
AssertionError
- if the actualPeriod
does not have the given months- Since:
- 3.17.0
-
hasDays
Verifies that the actualPeriod
has the given days.Example :
// assertion will pass assertThat(Period.ofDays(5)).hasDays(5); // assertion will fail assertThat(Period.ofDays(5)).hasDays(1);
- Parameters:
expectedDays
- the expected days value- Returns:
- this assertion object
- Throws:
AssertionError
- if the actualPeriod
isnull
AssertionError
- if the actualPeriod
does not have the given days- Since:
- 3.17.0
-
isPositive
Verifies that the actualPeriod
is positive (i.e. is greater thanPeriod.ZERO
).Example :
// assertion will pass assertThat(Period.ofMonths(5)).isPositive(); // assertion will fail assertThat(Period.ofMonths(-2)).isPositive();
- Returns:
- this assertion object
- Throws:
AssertionError
- if the actualPeriod
isnull
AssertionError
- if the actualPeriod
is not greater thanPeriod.ZERO
- Since:
- 3.17.0
-
isNegative
Verifies that the actualPeriod
is negative (i.e. is less thanPeriod.ZERO
).Example :
// assertion will pass assertThat(Period.ofMonths(-5)).isNegative(); // assertion will fail assertThat(Period.ofMonths(2)).isNegative();
- Returns:
- this assertion object
- Throws:
AssertionError
- if the actualPeriod
isnull
AssertionError
- if the actualPeriod
is not greater thanPeriod.ZERO
- Since:
- 3.17.0
-