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 forPeriodtype.- Since:
- 3.17.0
- Author:
- Hayden Meloche
-
-
Field Summary
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractPeriodAssert(Period period, Class<?> selfType)Creates a newAbstractPeriodAssert
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SELFhasDays(int expectedDays)Verifies that the actualPeriodhas the given days.SELFhasMonths(int expectedMonths)Verifies that the actualPeriodhas the given months.SELFhasYears(int expectedYears)Verifies that the actualPeriodhas the given years.SELFisNegative()Verifies that the actualPeriodis negative (i.e.SELFisPositive()Verifies that the actualPeriodis positive (i.e.-
Methods inherited from class org.assertj.core.api.AbstractAssert
asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, 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, satisfiesAnyOfForProxy, 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, as, describedAs
-
-
-
-
Constructor Detail
-
AbstractPeriodAssert
protected 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 actualPeriodhas 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 actualPeriodisnullAssertionError- if the actualPerioddoes not have the given years- Since:
- 3.17.0
-
hasMonths
public SELF hasMonths(int expectedMonths)
Verifies that the actualPeriodhas 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 actualPeriodisnullAssertionError- if the actualPerioddoes not have the given months- Since:
- 3.17.0
-
hasDays
public SELF hasDays(int expectedDays)
Verifies that the actualPeriodhas 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 actualPeriodisnullAssertionError- if the actualPerioddoes not have the given days- Since:
- 3.17.0
-
isPositive
public SELF isPositive()
Verifies that the actualPeriodis 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 actualPeriodisnullAssertionError- if the actualPeriodis not greater thanPeriod.ZERO- Since:
- 3.17.0
-
isNegative
public SELF isNegative()
Verifies that the actualPeriodis 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 actualPeriodisnullAssertionError- if the actualPeriodis not greater thanPeriod.ZERO- Since:
- 3.17.0
-
-