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

public abstract class BaseComparatorTestCase<T> extends AbstractTestCase<Integer,Boolean>
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

    Fields
    Modifier and Type
    Field
    Description
    protected 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    assertEquals(T expected, T actual)
    Abstract method that have to be implemented from derived classes with the specific unit framework
    protected abstract void
    assertTrue(Boolean expected)
    Abstract method that have to be implemented from derived classes with the specific unit framework
    protected abstract List<T>
    Abstract factory callback method that have to be overwritten for create the List 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 object
    protected abstract List<T>
    Abstract factory callback method that have to be overwritten for create the expected List with objects to test the sort algorithm in the sort scenario.
    protected abstract List<T>
    Abstract factory callback method that have to be overwritten for create the List 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
    Sets up method will be invoked before every unit test method
    void
    Tear down method will be invoked after every unit test method

    Note: call super.tearDown() if you overwrite it for set actual and expected to null
    void
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • comparator

      protected Comparator<T> comparator
      The comparator.
    • o1

      protected T o1
      The first comparison object.
    • o2

      protected T o2
      The other object to compare.
  • Constructor Details

    • BaseComparatorTestCase

      public BaseComparatorTestCase()
  • Method Details

    • newActualList

      protected abstract List<T> newActualList()
      Abstract factory callback method that have to be overwritten for create the List with objects to sort in the sort scenario.
      Returns:
      the List with objects to test the sort algorithm
    • newComparator

      protected abstract 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 List<T> newExpectedSortedList()
      Abstract factory callback method that have to be overwritten for create the expected List with objects to test the sort algorithm in the sort scenario.
      Returns:
      the List with objects to test the sort algorithm
    • newExpectedUnsortedList

      protected abstract List<T> newExpectedUnsortedList()
      Abstract factory callback method that have to be overwritten for create the List with objects to sort in the sort scenario.

      Note:This list have to be equal with newActualList()
      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

      public void setUp()
      Sets up method will be invoked before every unit test method
      Overrides:
      setUp in class AbstractTestCase<Integer,Boolean>
    • tearDown

      public void tearDown()
      Tear down method will be invoked after every unit test method

      Note: call super.tearDown() if you overwrite it for set actual and expected to null
      Overrides:
      tearDown in class AbstractTestCase<Integer,Boolean>
    • testCompare

      public void testCompare()
    • testEqual

      public void testEqual()
      Test scenario when comparison objects are equal.
    • assertTrue

      protected abstract void assertTrue(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 value
      actual - 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.