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 forPeriod
type.- Since:
- 3.17.0
- Author:
- Hayden Meloche
-
-
Field Summary
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, info, myself, objects, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Constructor Description AbstractPeriodAssert(Period period, Class<?> selfType)
Creates a newAbstractPeriodAssert
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SELF
hasDays(int expectedDays)
Verifies that the actualPeriod
has the given days.SELF
hasMonths(int expectedMonths)
Verifies that the actualPeriod
has the given months.SELF
hasYears(int expectedYears)
Verifies that the actualPeriod
has the given years.SELF
isNegative()
Verifies that the actualPeriod
is negative (i.e.SELF
isPositive()
Verifies that the actualPeriod
is positive (i.e.-
Methods inherited from class org.assertj.core.api.AbstractAssert
asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, 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, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveComparison, usingRecursiveComparison, withAssertionState, 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, describedAs
-
-
-
-
Constructor Detail
-
AbstractPeriodAssert
public AbstractPeriodAssert(Period period, Class<?> selfType)
Creates a newAbstractPeriodAssert
- Parameters:
period
- the actual value to verifyselfType
- the "self type"
-
-
Method Detail
-
hasYears
public SELF hasYears(int expectedYears)
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
public SELF hasMonths(int expectedMonths)
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
public SELF hasDays(int expectedDays)
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
public SELF 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
public SELF 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
-
-