org.jbpm.test.assertion
Class QueryAssertions

java.lang.Object
  extended by org.jbpm.test.assertion.QueryAssertions

public class QueryAssertions
extends java.lang.Object

Utility class with assertions for query test.

Author:
Joram Barrez

Method Summary
static
<T> void
assertOrderIsNatural(java.lang.Class<T> clazz, java.lang.String property, java.util.List<T> listOrderedAsc, java.util.List<T> listOrderedDesc, int nrOfExpectedElements)
          Does the same as the assertOrderOnProperty assertion, but instead of checking if the resulting list have the correct elements now it is checked if the elements are naturally ordered ascending and descending on the given property.
static
<T> void
assertOrderOnProperty(java.lang.Class<T> clazz, java.lang.String property, java.util.List<T> listOrderedAsc, java.util.List<T> listOrderedDesc, java.util.List<?> expectedValuesAsc)
          Assertion to be used to check if the result of a certain XXXQuery produces the correct result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

assertOrderOnProperty

public static <T> void assertOrderOnProperty(java.lang.Class<T> clazz,
                                             java.lang.String property,
                                             java.util.List<T> listOrderedAsc,
                                             java.util.List<T> listOrderedDesc,
                                             java.util.List<?> expectedValuesAsc)
Assertion to be used to check if the result of a certain XXXQuery produces the correct result. Example usage: List taskListAsc = taskService.createTaskQuery().orderAsc(property).list(); List taskListDesc = taskService.createTaskQuery().orderDesc(property).list(); QueryAssertions.assertOrderOnProperty(Task.class, property, taskListAsc, taskListDesc, Arrays.asList("a", "b", "c")); The assertion will do the following assertions:

Type Parameters:
T - The return type of the XXXQuery
Parameters:
clazz - Due to generics mumbo-jumbo, it's required to provide the class of the generic type T. If only we could do T.getClass() ...
property - The property on which the query was ordered
listOrderedAsc - The list resulting from executing the query with an 'order by asc'
listOrderedDesc - The list resulting from executing the query with an 'order by desc'
expectedValuesAsc - The hard coded list of expected elements, in ascending order. The assertion for the descending case will be done by reversing this list

assertOrderIsNatural

public static <T> void assertOrderIsNatural(java.lang.Class<T> clazz,
                                            java.lang.String property,
                                            java.util.List<T> listOrderedAsc,
                                            java.util.List<T> listOrderedDesc,
                                            int nrOfExpectedElements)
Does the same as the assertOrderOnProperty assertion, but instead of checking if the resulting list have the correct elements now it is checked if the elements are naturally ordered ascending and descending on the given property.



Copyright © 2010 JBoss Community. All Rights Reserved.