| java.lang.Object org.springunit.examples.CompositeDate
CompositeDate | public class CompositeDate implements Comparable<CompositeDate>,Serializable(Code) | | Simple domain object class to be used for demonstrating
Data Driven Tests.
CompositeDate is composed of a year, month and day of year.
The fact that there are many constraints on the allowed
combinations makes for interesting test cases.
Further, operations like increment and decrement on
each of the fields leads to many other boundary
conditions for which to test.
The following are groundrules set by the class:
- A year may be any positive or negative integer
- A month may be any integer between 1 and 12, inclusive
- A day may be any integer between 1 and 31, inclusive
These being preconditions imposed on clients, the class
does not check, for instance,
for days greater than 31, or months greater than 12.
Of course, not all combinations of year, month and day
that satisfy these preconditions are valid. These are
validated internally by the class.
author: Ted.Velkoff |
Constructor Summary | |
public | CompositeDate(int year, int month, int day) |
Method Summary | |
public int | compareTo(CompositeDate that) Is this less than, equal to, or greater than that?
Parameters: that - Object to be compared with this. | public boolean | decrementDay() | public boolean | decrementMonth() | public boolean | decrementYear() Decrement by one year. | public boolean | equals(Object obj) | public int | getDay() | public int | getMonth() | public int | getYear() | public int | hashCode() | public boolean | incrementDay() | public boolean | incrementMonth() | public boolean | incrementYear() | public static boolean | isValidDate(int year, int month, int day) | public static boolean | isValidLeapDay(int year, int month, int day) | public static boolean | isValidMonthAndDay(int month, int day) | public void | setDay(int day) | public void | setMonth(int month) | public void | setYear(int year) | public String | toString() | protected static void | validateDate(int year, int month, int day) | protected static void | validateLeapDay(int year, int month, int day) | protected static void | validateMonthAndDay(int month, int day) |
CompositeDate | public CompositeDate(int year, int month, int day) throws InvalidDateException(Code) | | Create CompositeDate having day, month and year.
"1 <= day && day <= 31")
"1 <= month && month <= 12")
throws: InvalidDateException - if day, month and year donot specify a valid date |
compareTo | public int compareTo(CompositeDate that)(Code) | | Is this less than, equal to, or greater than that?
Parameters: that - Object to be compared with this. boolean |
equals | public boolean equals(Object obj)(Code) | | Is this equal to obj?
|
getDay | public int getDay()(Code) | | Returns the day. |
getMonth | public int getMonth()(Code) | | Returns the month. |
getYear | public int getYear()(Code) | | Returns the year. |
hashCode | public int hashCode()(Code) | | Hash code.
|
isValidDate | public static boolean isValidDate(int year, int month, int day)(Code) | | Is combination of year , month ,
and day valid?
"1 <= month && month <= 12")
"1 <= day && day <= 31")
true if valid, false otherwise |
isValidLeapDay | public static boolean isValidLeapDay(int year, int month, int day)(Code) | | Is combination of year , month ,
and day a valid leap day?
true if valid, false otherwise |
isValidMonthAndDay | public static boolean isValidMonthAndDay(int month, int day)(Code) | | Is combination of month
and day a valid month/day pair?
"1 <= month && month <= 12")
"1 <= day && day <= 31")
true if valid, false otherwise |
toString | public String toString()(Code) | | String representation.
|
validateDate | protected static void validateDate(int year, int month, int day) throws InvalidDateException(Code) | | Determine whether the combination of day, month and year
is valid and throw InvalidDateException if not.
|
validateLeapDay | protected static void validateLeapDay(int year, int month, int day) throws InvalidDateException(Code) | | Determine whether the combination of day, month and year
is a leap day and throw InvalidDateException if it is not
a valid leap day.
|
validateMonthAndDay | protected static void validateMonthAndDay(int month, int day) throws InvalidDateException(Code) | | Determine whether the combination of day, month and year
is a leap day and throw InvalidDateException if it is not
a valid leap day.
|
|
|