Class EPAssertionUtil

java.lang.Object
com.espertech.esper.common.client.scopetest.EPAssertionUtil

public class EPAssertionUtil extends Object
Assertion methods for event processing applications.
  • Constructor Details

    • EPAssertionUtil

      public EPAssertionUtil()
  • Method Details

    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(String[][] expected, String[][] actual)
      Deep compare two 2-dimensional string arrays for the exact same length of arrays and order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(Object[][] actual, String[] propertyNames, Object[][] expected)
      Compare two 2-dimensional arrays, and using property names for messages, against expected values.
      Parameters:
      actual - array of objects
      propertyNames - property names
      expected - expected values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(Collection<Object[]> actual, String[] propertyNames, Object[][] expected)
      Compare the collection of object arrays, and using property names for messages, against expected values.
      Parameters:
      actual - colleciton of array of objects
      propertyNames - property names
      expected - expected values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(EventBean[] expected, Iterator<EventBean> actual)
      Compare the iterator-returned events against the expected events
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrderUnderlying

      public static void assertEqualsExactOrderUnderlying(Object[] expected, Iterator<EventBean> actual)
      Compare the underlying events returned by the iterator to the expected values.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrderUnderlying

      public static void assertEqualsExactOrderUnderlying(Object[] expected, EventBean[] actual)
      Comparing the underlying events to the expected events using equals-semantics.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(Object[][] expected, List<Object[]> actual)
      Compare the objects in the 2-dimension object arrays assuming the exact same order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(Object[] expected, Object[] actual)
      Compare the objects in the two object arrays assuming the exact same order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(String message, Object[] expected, Object[] actual)
      Compare the objects in the two object arrays assuming the exact same order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
      message - an optional message that can be output when assrtion fails
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(Object[] expected, Collection actual)
      Compare the objects in the expected arrays and actual collection assuming the exact same order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertSameExactOrder

      public static void assertSameExactOrder(Object[] expected, Object[] actual)
      Reference-equals the objects in the two object arrays assuming the exact same order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(int[] expected, int[] actual)
      Compare the integer values in the two int arrays assuming the exact same order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(int[] expected, Integer[] actual)
      Compare the integer values in the two int arrays assuming the exact same order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(short[] expected, short[] actual)
      Compare the short values in the two short arrays assuming the exact same order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(long[] expected, long[] actual)
      Compare the long values in the long arrays assuming the exact same order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(String[] expected, String[] actual)
      Compare the String values in the two String arrays assuming the exact same order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(boolean[] expected, boolean[] actual)
      Compare the boolean values in the two bool arrays assuming the exact same order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsExactOrder

      public static void assertEqualsExactOrder(Object[] expected, Iterator actual)
      Compare the objects returned by the iterator to the an object array.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsAnyOrder

      public static void assertEqualsAnyOrder(int[] expected, Set<Integer> actual)
      Assert that each integer value in the expected array is contained in the actual array.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsAnyOrder

      public static void assertEqualsAnyOrder(int[] expected, int[] actual)
      Compare the two integer arrays allowing any order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertEqualsAnyOrder

      public static void assertEqualsAnyOrder(Object[] expected, Object[] actual)
      Compare the two object arrays allowing any order.
      Parameters:
      expected - is the expected values
      actual - is the actual values
    • assertPropsPerRow

      public static void assertPropsPerRow(Iterator<EventBean> iterator, SafeIterator<EventBean> safeIterator, String[] propertyNames, Object[][] expected)
      Compare the property values returned by events of both iterators with the expected values, using exact-order semantics.
      Parameters:
      iterator - provides events
      safeIterator - provides events
      propertyNames - array of property names
      expected - expected values
    • assertPropsPerRowAnyOrder

      public static void assertPropsPerRowAnyOrder(Iterator<EventBean> iterator, SafeIterator<EventBean> safeIterator, String[] propertyNames, Object[][] expected)
      Compare the property values returned by events of both iterators with the expected values, using any-order semantics.
      Parameters:
      iterator - provides events
      safeIterator - provides events
      propertyNames - array of property names
      expected - expected values
    • assertPropsPerRowAnyOrder

      public static void assertPropsPerRowAnyOrder(com.espertech.esper.common.internal.collection.UniformPair<EventBean[]> pair, String[] propertyNames, Object[][] expectedNew, Object[][] expectedOld)
      Compare property values for insert and remove stream pair
      Parameters:
      pair - pair
      propertyNames - names
      expectedNew - expected insert-stream values
      expectedOld - expected remove-stream values
    • assertPropsPerRowAnyOrder

      public static void assertPropsPerRowAnyOrder(SafeIterator<EventBean> safeIterator, String[] propertyNames, Object[][] expected)
      Compare the property values returned by events of the iterator with the expected values, using any-order semantics.
      Parameters:
      safeIterator - provides events
      propertyNames - array of property names
      expected - expected values
    • assertPropsPerRowAnyOrder

      public static void assertPropsPerRowAnyOrder(Iterator<EventBean> iterator, String[] propertyNames, Object[][] expected)
      Compare the property values returned by events of the iterator with the expected values, using any-order semantics.
      Parameters:
      iterator - provides events
      propertyNames - array of property names
      expected - expected values
    • assertPropsPerRow

      public static void assertPropsPerRow(Iterator<EventBean> iterator, String[] propertyNames, Object[][] expected)
      Compare the property values returned by events of both iterators with the expected values, using exact-order semantics.
      Parameters:
      iterator - provides events
      propertyNames - array of property names
      expected - expected values
    • assertPropsPerRow

      public static void assertPropsPerRow(Map[] actual, String[] propertyNames, Object[][] expected)
      Compare the Map values identified by property names against expected values.
      Parameters:
      actual - array of Maps, one for each row
      propertyNames - property names
      expected - expected values
    • assertPropsPerRow

      public static void assertPropsPerRow(EventBean[] received, String[] propertyNames, Object[][] expected)
      Compare the property values of events with the expected values, using exact-order semantics.
      Parameters:
      received - provides events
      propertyNames - array of property names
      expected - expected values
    • assertPropsPerRow

      public static void assertPropsPerRow(EventBean[] actual, String[] propertyNames, Object[][] expected, String streamName)
      Compare the property values of events with the expected values, using exact-order semantics.
      Parameters:
      actual - provides events
      propertyNames - array of property names
      expected - expected values
      streamName - an optional name for the stream for use in messages
    • assertPropsPerRowAnyOrder

      public static void assertPropsPerRowAnyOrder(EventBean[] actual, String[] propertyNames, Object[][] expected)
      Compare the property values of events with the expected values, using any-order semantics.
      Parameters:
      actual - provides events
      propertyNames - array of property names
      expected - expected values
    • assertProps

      public static void assertProps(EventBean received, String[] propertyNames, Object[] expected)
      Assert that the property values of a single event match the expected values.
      Parameters:
      received - provides events
      propertyNames - array of property names
      expected - expected values
    • assertProps

      public static void assertProps(com.espertech.esper.common.internal.collection.UniformPair<EventBean> received, String[] propertyNames, Object[] expectedInsert, Object[] expectedRemoved)
      Assert that the property values of a new event and a removed event match the expected insert and removed values.
      Parameters:
      received - provides events
      propertyNames - array of property names
      expectedInsert - expected values insert stream
      expectedRemoved - expected values remove stream
    • assertPropsPerRow

      public static void assertPropsPerRow(com.espertech.esper.common.internal.collection.UniformPair<EventBean[]> received, String[] propertyNames, Object[][] expectedInsert, Object[][] expectedRemoved)
      Assert that the property values of a new event and a removed event match the expected insert and removed values.
      Parameters:
      received - provides events
      propertyNames - array of property names
      expectedInsert - expected values insert stream
      expectedRemoved - expected values remove stream
    • assertPropsPerRow

      public static void assertPropsPerRow(com.espertech.esper.common.internal.collection.UniformPair<EventBean[]> received, String propertyName, Object[] expectedInsert, Object[] expectedRemoved)
      Assert that the property values of the events (insert and remove pair) match the expected insert and removed values for a single property.
      Parameters:
      received - provides events
      propertyName - property name
      expectedInsert - expected values insert stream
      expectedRemoved - expected values remove stream
    • assertUnderlyingPerRow

      public static void assertUnderlyingPerRow(com.espertech.esper.common.internal.collection.UniformPair<EventBean[]> received, Object[] expectedUnderlyingInsert, Object[] expectedUnderlyingRemove)
      Assert that the underlying objects of the events (insert and remove pair) match the expected insert and removed objects.
      Parameters:
      received - provides events
      expectedUnderlyingInsert - expected underlying object insert stream
      expectedUnderlyingRemove - expected underlying object remove stream
    • assertAllPropsSortedByName

      public static void assertAllPropsSortedByName(EventBean received, Object[] expected)
      Asserts that the property values of a single event, using property names as provided by the event type in sorted order by property name, match against the expected values.
      Parameters:
      received - provides events
      expected - expected values
    • assertPropsMap

      public static void assertPropsMap(Map received, String[] propertyNames, Object... expected)
      Compare the values of a Map against the expected values.
      Parameters:
      received - provides properties
      expected - expected values
      propertyNames - property names to assert
    • assertPropsObjectArray

      public static void assertPropsObjectArray(Object[] received, String[] propertyNames, Object... expected)
      Compare the values of a object array (single row) against the expected values.
      Parameters:
      received - provides properties
      expected - expected values
      propertyNames - property names to assert
    • assertEqualsAnyOrder

      public static void assertEqualsAnyOrder(EventBean[][] expected, EventBean[][] actual)
      Compare two 2-dimensional event arrays.
      Parameters:
      expected - expected values
      actual - actual values
    • assertSameAnyOrder

      public static void assertSameAnyOrder(Object[][] expected, Object[][] actual)
      Compare two 2-dimensional object arrays using reference-equals semantics.
      Parameters:
      expected - expected values
      actual - actual values
    • assertAllBooleanTrue

      public static void assertAllBooleanTrue(Object[] objects)
      Asserts that all values in the given object array are boolean-typed values and are true
      Parameters:
      objects - values to assert that they are all true
    • assertTypeEqualsAnyOrder

      public static void assertTypeEqualsAnyOrder(Class[] classes, Object[] objects)
      Assert the class of the objects in the object array matches the expected classes in the classes array.
      Parameters:
      classes - is the expected class
      objects - is the objects to check the class for
    • iteratorToArray

      public static EventBean[] iteratorToArray(Iterator<EventBean> iterator)
      Convert an iterator of event beans to an array of event beans.
      Parameters:
      iterator - to convert
      Returns:
      array of events
    • iteratorToArrayUnderlying

      public static Object[] iteratorToArrayUnderlying(Iterator<EventBean> iterator)
      Convert an iterator of event beans to an array of underlying objects.
      Parameters:
      iterator - to convert
      Returns:
      array of event underlying objects
    • iteratorCount

      public static <T> int iteratorCount(Iterator<T> iterator)
      Count the number of object provided by an iterator.
      Type Parameters:
      T - type
      Parameters:
      iterator - to count
      Returns:
      count
    • assertPropsPerRow

      public static void assertPropsPerRow(EventBean[] received, List<Map<String,Object>> expected)
      Compare properties of events against a list of maps.
      Parameters:
      received - actual events
      expected - expected values
    • assertPropsPerRow

      public static void assertPropsPerRow(Iterator<EventBean> iterator, List<Map<String,Object>> expected)
      Compare properties of events against a list of maps.
      Parameters:
      iterator - actual events
      expected - expected values
    • concatenateArray

      public static Object[] concatenateArray(Object[] srcOne, Object[] srcTwo)
      Concatenate two arrays.
      Parameters:
      srcOne - array to concatenate
      srcTwo - array to concatenate
      Returns:
      concatenated array
    • concatenateArray2Dim

      public static Object[][] concatenateArray2Dim(Object[][] first, Object[][]... more)
      Concatenate two arrays.
      Parameters:
      first - array to concatenate
      more - array to concatenate
      Returns:
      concatenated array
    • concatenateArray

      public static Object[] concatenateArray(Object[]... more)
      Concatenate multiple arrays.
      Parameters:
      more - arrays to concatenate
      Returns:
      concatenated array
    • sort

      public static EventBean[] sort(Iterator<EventBean> events, String property)
      Sort events according to natural ordering of the values or a property.
      Parameters:
      events - to sort
      property - name of property providing sort values
      Returns:
      sorted array
    • sort

      public static EventBean[] sort(EventBean[] events, String property)
      Sort events according to natural ordering of the values or a property.
      Parameters:
      events - to sort
      property - name of property providing sort values
      Returns:
      sorted array
    • assertNotContains

      public static void assertNotContains(String[] stringSet, String... values)
      Assert that a string set does not contain one or more values.
      Parameters:
      stringSet - to compare against
      values - to find
    • assertContains

      public static void assertContains(String[] stringSet, String... values)
      Assert that a string set does contain each of one or more values.
      Parameters:
      stringSet - to compare against
      values - to find
    • getUnderlying

      public static Object[] getUnderlying(EventBean[] events)
      Return an array of underlying objects for an array of events.
      Parameters:
      events - to return underlying objects
      Returns:
      events
    • assertPropsAllValuesSame

      public static void assertPropsAllValuesSame(EventBean received, String[] propertyNames, Object expected)
      Assert that all properties of an event have the same value as passed in.
      Parameters:
      received - to inspect
      propertyNames - property names
      expected - value
    • eventsToObjectArr

      public static Object[] eventsToObjectArr(EventBean[] events, String propertyName)
      Extract the property value of the event property for the given events and return an object array of values.
      Parameters:
      events - to extract value from
      propertyName - name of property to extract values for
      Returns:
      value object array
    • eventsToObjectArr

      public static Object[][] eventsToObjectArr(EventBean[] events, String[] propertyNames)
      Extract the property value of the event properties for the given events and return an object array of values.
      Parameters:
      events - to extract value from
      propertyNames - names of properties to extract values for
      Returns:
      value object array
    • iteratorToObjectArr

      public static Object[] iteratorToObjectArr(Iterator<EventBean> iterator, String propertyName)
      Extract the property value of the event property for the given events and return an object array of values.
      Parameters:
      iterator - events to extract value from
      propertyName - name of property to extract values for
      Returns:
      value object array
    • iteratorToObjectArr

      public static Object[][] iteratorToObjectArr(Iterator<EventBean> iterator, String[] propertyNames)
      Extract the property value of the event properties for the given events and return an object array of values.
      Parameters:
      iterator - events to extract value from
      propertyNames - names of properties to extract values for
      Returns:
      value object array
    • compareEqualsExactOrder

      public static boolean compareEqualsExactOrder(EventBean[] actual, EventBean[] expected)
      Compare the events in the two object arrays assuming the exact same order.
      Parameters:
      actual - is the actual results
      expected - is the expected values
      Returns:
      indicate whether compared successfully
    • compareRefExactOrder

      public static boolean compareRefExactOrder(Object[] actual, Object[] expected)
      Reference-compare the objects in the two object arrays assuming the exact same order.
      Parameters:
      actual - is the actual results
      expected - is the expected values
      Returns:
      indicate whether compared successfully
    • assertPropsPerRow

      public static void assertPropsPerRow(Object[] received, String[] propertyNames, Object[][] expected)
      Assert that property values of rows, wherein each row can either be Map or POJO objects, matches the expected values.
      Parameters:
      received - array of objects may contain Map and POJO events
      propertyNames - property names
      expected - expected value
    • assertPropsPerRow

      public static void assertPropsPerRow(List<Object[]> received, String[] propertyNames, Object[][] expected)
      Assert that property values of rows, wherein each row can either be Map or POJO objects, matches the expected values.
      Parameters:
      received - array of objects may contain Map and POJO events
      propertyNames - property names
      expected - expected value
    • assertProps

      public static void assertProps(Object received, String[] propertyNames, Object[] expected)
      Assert that property values, wherein the row can either be a Map or a POJO object, matches the expected values.
      Parameters:
      received - Map or POJO
      propertyNames - property names
      expected - expected value
    • toObjectArray

      public static Object[] toObjectArray(Object array)
      For a given array, copy the array elements into a new array of Object[] type.
      Parameters:
      array - input array
      Returns:
      object array
    • assertEqualsAllowArray

      public static void assertEqualsAllowArray(String message, Object expected, Object actual)
      Assert that two property values are the same, allowing arrays as properties.
      Parameters:
      message - to use
      expected - expected value
      actual - actual value
    • assertProps

      public static void assertProps(EventBean received, Map<String,Object> expected)
      Assert that the event properties of the event match the properties provided by the map, taking the map properties as the comparison source.
      Parameters:
      received - event
      expected - expected values
    • assertEqualsIgnoreNewline

      public static void assertEqualsIgnoreNewline(String expected, String received)
      Compare two strings removing all newline characters.
      Parameters:
      expected - expected value
      received - received value
    • assertMapOfCollection

      public static void assertMapOfCollection(Map map, String[] keys, String[] expectedList, EPAssertionUtil.AssertionCollectionValueString collectionValue)
      Assert that a map of collections (Map<String, Collection>) has expected keys and values.
      Parameters:
      map - of string keys and collection-type values
      keys - array of key values
      expectedList - for each key a string that is a comma-separated list of values
      collectionValue - the function to apply to each collection value to convert to a string
    • assertNameValuePairs

      public static void assertNameValuePairs(EventBean[] lastData, Object[][] namesAndValues)
      Assert that the event properties match the name-value pairs for each event
      Parameters:
      lastData - array of events
      namesAndValues - array of pairs with the first element the event property name and the second element the expected value