Package io.github.astrapi69.test.base
Class BaseComparatorTestCase<T>
java.lang.Object
io.github.astrapi69.test.base.AbstractTestCase<Integer,Boolean>
io.github.astrapi69.test.base.BaseComparatorTestCase<T>
- Type Parameters:
T
- the generic type of the objects to compare
The abstract class
BaseComparatorTestCase
is for unit tests with Comparator
. An
example is in the unit test class DateComparatorTest
in project silly-collections-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Comparator<T>
The comparator.protected T
The first comparison object.protected T
The other object to compare.Fields inherited from class io.github.astrapi69.test.base.AbstractTestCase
actual, expected
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
assertEquals
(T expected, T actual) Abstract method that have to be implemented from derived classes with the specific unit frameworkprotected abstract void
assertTrue
(Boolean expected) Abstract method that have to be implemented from derived classes with the specific unit frameworkAbstract factory callback method that have to be overwritten for create theList
with objects to sort in the sort scenario.protected abstract Comparator<T>
Abstract factory callback method that have to be overwritten for create the specific comparator objectAbstract factory callback method that have to be overwritten for create the expectedList
with objects to test the sort algorithm in the sort scenario.Abstract factory callback method that have to be overwritten for create theList
with objects to sort in the sort scenario.protected abstract T
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
Abstract factory callback method that have to be overwritten for create the first comparison object in the scenario greater than.protected abstract T
Abstract factory callback method that have to be overwritten for create the first comparison object in the scenario less than.protected T
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
Abstract factory callback method that have to be overwritten for create the other object to compare in the scenario greater than.protected abstract T
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
Test method forComparator.compare(Object, Object)
void
Test scenario when comparison objects are equal.void
Test scenario when a comparison object is greater than the other object to compare.void
Test scenario when a comparison object is less than the other object to compare.
-
Field Details
-
comparator
The comparator. -
o1
The first comparison object. -
o2
The other object to compare.
-
-
Constructor Details
-
BaseComparatorTestCase
public BaseComparatorTestCase()
-
-
Method Details
-
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
Abstract factory callback method that have to be overwritten for create the specific comparator object- Returns:
- the specific comparator
-
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
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
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
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
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
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
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
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:
setUp
in classAbstractTestCase<Integer,
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:
tearDown
in classAbstractTestCase<Integer,
Boolean>
-
testCompare
public void testCompare()Test method forComparator.compare(Object, Object)
-
testEqual
public void testEqual()Test scenario when comparison objects are equal. -
assertTrue
Abstract method that have to be implemented from derived classes with the specific unit framework- Parameters:
expected
- the expected boolean value
-
assertEquals
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.
-