- java.lang.Object
-
- io.github.astrapi69.AbstractTestCase<java.lang.Integer,java.lang.Boolean>
-
- io.github.astrapi69.BaseComparatorTestCase<T>
-
- Type Parameters:
T- the generic type of the objects to compare
public abstract class BaseComparatorTestCase<T> extends AbstractTestCase<java.lang.Integer,java.lang.Boolean>
The abstract classBaseComparatorTestCaseis for unit tests withComparator. An example is in the unit test classDateComparatorTestin project silly-collections
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Comparator<T>comparatorThe comparator.protected To1The first comparison object.protected To2The other object to compare.-
Fields inherited from class io.github.astrapi69.AbstractTestCase
actual, expected
-
-
Constructor Summary
Constructors Constructor Description BaseComparatorTestCase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidassertEquals(T expected, T actual)Abstract method that have to be implemented from derived classes with the specific unit frameworkprotected abstract voidassertTrue(java.lang.Boolean expected)Abstract method that have to be implemented from derived classes with the specific unit frameworkprotected abstract java.util.List<T>newActualList()Abstract factory callback method that have to be overwritten for create theListwith objects to sort in the sort scenario.protected abstract java.util.Comparator<T>newComparator()Abstract factory callback method that have to be overwritten for create the specific comparator objectprotected abstract java.util.List<T>newExpectedSortedList()Abstract factory callback method that have to be overwritten for create the expectedListwith objects to test the sort algorithm in the sort scenario.protected abstract java.util.List<T>newExpectedUnsortedList()Abstract factory callback method that have to be overwritten for create theListwith objects to sort in the sort scenario.protected abstract TnewO1Equal()Abstract factory callback method that have to be overwritten for create the other object to compare in the scenario that the objects are equal.protected abstract TnewO1GreaterThan()Abstract factory callback method that have to be overwritten for create the first comparison object in the scenario greater than.protected abstract TnewO1LessThan()Abstract factory callback method that have to be overwritten for create the first comparison object in the scenario less than.protected TnewO2Equal()Factory callback method that can be overwritten for create the other object to compare in the scenario that the objects are equal.protected abstract TnewO2GreaterThan()Abstract factory callback method that have to be overwritten for create the other object to compare in the scenario greater than.protected abstract TnewO2LessThan()Abstract factory callback method that have to be overwritten for create the other object to compare in the scenario less than.voidsetUp()Sets up method will be invoked before every unit test methodvoidtearDown()Tear down method will be invoked after every unit test method
Note: callsuper.tearDown()if you overwrite it for set actual and expected to nullvoidtestCompare()Test method forComparator.compare(Object, Object)voidtestEqual()Test scenario when comparison objects are equal.voidtestGreaterThan()Test scenario when a comparison object is greater than the other object to compare.voidtestLessThan()Test scenario when a comparison object is less than the other object to compare.
-
-
-
Method Detail
-
newActualList
protected abstract java.util.List<T> newActualList()
Abstract factory callback method that have to be overwritten for create theListwith objects to sort in the sort scenario.- Returns:
- the
Listwith objects to test the sort algorithm
-
newComparator
protected abstract java.util.Comparator<T> newComparator()
Abstract factory callback method that have to be overwritten for create the specific comparator object- Returns:
- the specific comparator
-
newExpectedSortedList
protected abstract java.util.List<T> newExpectedSortedList()
Abstract factory callback method that have to be overwritten for create the expectedListwith objects to test the sort algorithm in the sort scenario.- Returns:
- the
Listwith objects to test the sort algorithm
-
newExpectedUnsortedList
protected abstract java.util.List<T> newExpectedUnsortedList()
Abstract factory callback method that have to be overwritten for create theListwith objects to sort in the sort scenario.
Note:This list have to be equal withnewActualList()- Returns:
- the
Listwith objects to test the sort algorithm
-
newO1Equal
protected abstract T newO1Equal()
Abstract factory callback method that have to be overwritten for create the other object to compare in the scenario that the objects are equal.- Returns:
- the new created object to compare
-
newO1GreaterThan
protected abstract T newO1GreaterThan()
Abstract factory callback method that have to be overwritten for create the first comparison object in the scenario greater than.- Returns:
- the new created first comparison object
-
newO1LessThan
protected abstract T newO1LessThan()
Abstract factory callback method that have to be overwritten for create the first comparison object in the scenario less than.- Returns:
- the new created first comparison object
-
newO2Equal
protected T newO2Equal()
Factory callback method that can be overwritten for create the other object to compare in the scenario that the objects are equal.- Returns:
- the new created object to compare
-
newO2GreaterThan
protected abstract T newO2GreaterThan()
Abstract factory callback method that have to be overwritten for create the other object to compare in the scenario greater than.- Returns:
- the new created object to compare
-
newO2LessThan
protected abstract T newO2LessThan()
Abstract factory callback method that have to be overwritten for create the other object to compare in the scenario less than.- Returns:
- the new created object to compare
-
setUp
public void setUp()
Sets up method will be invoked before every unit test method- Overrides:
setUpin classAbstractTestCase<java.lang.Integer,java.lang.Boolean>
-
tearDown
public void tearDown()
Tear down method will be invoked after every unit test method
Note: callsuper.tearDown()if you overwrite it for set actual and expected to null- Overrides:
tearDownin classAbstractTestCase<java.lang.Integer,java.lang.Boolean>
-
testCompare
public void testCompare()
Test method forComparator.compare(Object, Object)
-
testEqual
public void testEqual()
Test scenario when comparison objects are equal.
-
assertTrue
protected abstract void assertTrue(java.lang.Boolean expected)
Abstract method that have to be implemented from derived classes with the specific unit framework- Parameters:
expected- the expected boolean value
-
assertEquals
protected abstract void assertEquals(T expected, T actual)
Abstract method that have to be implemented from derived classes with the specific unit framework- Parameters:
expected- the expected valueactual- the actual value
-
testGreaterThan
public void testGreaterThan()
Test scenario when a comparison object is greater than the other object to compare.
-
testLessThan
public void testLessThan()
Test scenario when a comparison object is less than the other object to compare.
-
-