Class Assert

java.lang.Object
de.hybris.platform.testframework.Assert

public class Assert extends Object
Collection of static assert methods not provided by the JUnit framework. Use it equivalent to the JUnit Assert class by a static import.
  • Constructor Details

    • Assert

      public Assert()
  • Method Details

    • assertCollectionElements

      public static void assertCollectionElements(Collection actual, Object... objects)
      Asserts that actual collection contains only given objects.
      Parameters:
      actual - collection which has to contain only given objects
      objects - objects that has to be existent in given collection and no other one
    • assertCollection

      public static void assertCollection(Collection expected, Collection actual)
      Asserts that expected and actual collection contain the same elements and have the same size.
      Parameters:
      expected - collection used as reference collection for the actual one
      actual - collection which has to have exactly the same elements as the expected one
    • assertValueInRange

      public static <T extends Comparable> void assertValueInRange(T lowerLimit, T upperLimit, T actual)
      Asserts that expected value belongs to a given numerical range .
      Parameters:
      lowerLimit - lower limit of the expected range
      upperLimit - upper limit of the expected range
      actual - actual value
    • assertValueInRange

      public static <T extends Comparable> void assertValueInRange(String message, T lowerLimit, T upperLimit, T actual)
      Asserts that expected value belongs to a given numerical range .
      Parameters:
      message - Failure message
      lowerLimit - lower limit of the expected range
      upperLimit - upper limit of the expected range
      actual - actual value
    • assertCollection

      public static void assertCollection(String message, Collection expected, Collection actual)
      Asserts that expected and actual collection contain the same elements and have the same size.
      Parameters:
      expected - collection used as reference collection for the actual one
      actual - collection which has to have exactly the same elements as the expected one
      message - to show if assertion fires
    • singleElement

      protected <T> T singleElement(Collection<T> collection)
      Gets the single element of the collection, or fail.
      Type Parameters:
      T - type of the element
      Parameters:
      collection - collection from which the single element is needed
      Returns:
      the single element contained in given collection
    • set

      public static final Set set()
      Gets an immutable empty set.
      Returns:
      an immutable empty set
    • set

      public static final Set set(Object object)
      Returns an immutable set containing the given argument.
      Parameters:
      object - element
      Returns:
      immutable set containing the given argument
    • set

      public static final Set set(Object object1, Object object2)
      * Returns an immutable set containing the two given arguments.
      Parameters:
      object1 - first element
      object2 - second element
      Returns:
      immutable set containing the two given arguments
    • set

      public static final Set set(Object object1, Object object2, Object object3)
      Returns an immutable set containing the three given arguments.
      Parameters:
      object1 - first element
      object2 - second element
      object3 - third element
      Returns:
      immutable set containing the three given arguments
    • set

      public static final Set set(Object object1, Object object2, Object object3, Object object4)
      Returns an immutable set containing the four given arguments.
      Parameters:
      object1 - first element
      object2 - second element
      object3 - third element
      object4 - fourth element
      Returns:
      immutable set containing the four given arguments
    • toList

      public static final <T> List<T> toList(Collection<T> collection)
      Converts the given collection to a list.
      Type Parameters:
      T - type of collection elements
      Parameters:
      collection - collection to convert
      Returns:
      list of elements of given collection
    • list

      public static final List list()
      Returns an immutable empty list.
      Returns:
      immutable empty list
    • list

      public static final List list(Object object)
      Returns an immutable list containing the given argument. *
      Parameters:
      object - element
      Returns:
      immutable list containing the given argument
    • list

      public static final List list(Object object1, Object object2)
      Returns a list containing the two given arguments. *
      Parameters:
      object1 - first element
      object2 - second element
      Returns:
      immutable list containing the two given arguments
    • list

      public static final List list(Object object1, Object object2, Object object3)
      Returns a list containing the three given arguments.
      Parameters:
      object1 - first element
      object2 - second element
      object3 - third element
      Returns:
      immutable list containing the three given arguments
    • list

      public static final List list(Object object1, Object object2, Object object3, Object object4)
      Returns an immutable list containing the four given arguments.
      Parameters:
      object1 - first element
      object2 - second element
      object3 - third element
      object4 - fourth element
      Returns:
      immutable list containing the four given arguments
    • assertEquals

      public static void assertEquals(Object expected, Object actual)
      Extend equality check for objects. Tests the Object.equals(Object) method in both directions and compares the result of Object.hashCode().
    • assertNotEquals

      public static void assertNotEquals(Object expected, Object actual)
      Asserts that two objects are not equal. Throws an AssertionFailedError if they are equal.
    • assertNotEquals

      public static void assertNotEquals(String message, Object expected, Object actual)
      Asserts that two objects are not equal. Throws an AssertionFailedError if they are equal.