Package io.github.astrapi69
Class BaseComparatorTestCase<T>
- 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 classBaseComparatorTestCase
is for unit tests withComparator
. An example is in the unit test classDateComparatorTest
in project silly-collections
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Comparator<T>
comparator
The comparator.protected T
o1
The first comparison object.protected T
o2
The 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 java.util.List<T>
newActualList()
Abstract factory callback method that have to be overwritten for create theList
with 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 expectedList
with 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 theList
with objects to sort in the sort scenario.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.protected abstract T
newO1GreaterThan()
Abstract factory callback method that have to be overwritten for create the first comparison object in the scenario greater than.protected abstract T
newO1LessThan()
Abstract factory callback method that have to be overwritten for create the first comparison object in the scenario less than.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.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.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.void
setUp()
Sets up method will be invoked before every unit test methodvoid
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 nullvoid
testCompare()
Test method forComparator.compare(Object, Object)
void
testEqual()
Test scenario when comparison objects are equal.void
testGreaterThan()
Test scenario when a comparison object is greater than the other object to compare.void
testLessThan()
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 theList
with objects to sort in the sort scenario.- Returns:
- the
List
with 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 expectedList
with objects to test the sort algorithm in the sort scenario.- Returns:
- the
List
with 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 theList
with objects to sort in the sort scenario.
Note:This list have to be equal withnewActualList()
- Returns:
- the
List
with 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
@BeforeMethod public void setUp()
Sets up method will be invoked before every unit test method- Overrides:
setUp
in classAbstractTestCase<java.lang.Integer,java.lang.Boolean>
-
tearDown
@AfterMethod 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:
tearDown
in 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.
-
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.
-
-