private Iterator < Tuple > getSatisfyingTuples ( final TestCaseDef testCase , VarTupleSet varTupleSet ) { final Comparator < VarBindingDef > byUsage = byUsage ( varTupleSet ) ; return IteratorUtils . transformedIterator ( // Iterate over all combinations of bindings... new CartesianProduct < VarBindingDef > ( // ...combining members from all sets of bindings... new ArrayList < Set < VarBindingDef > > ( CollectionUtils . collect ( // ...where each set of bindings is derived from a disjunct of unsatisfied test case conditions.... testCase . getRequired ( ) . getDisjuncts ( ) , // ...and contains the set of compatible bindings that could satisfy this disjunct... disjunct -> { Set < String > unsatisfied = CollectionUtils . collect ( disjunct . getAssertions ( ) , assertion -> assertion . getProperty ( ) , new HashSet < String > ( ) ) ; Iterator < VarBindingDef > satisfyingBindings = IteratorUtils . filteredIterator ( getPropertyProviders ( unsatisfied ) . iterator ( ) , binding -> testCase . isCompatible ( binding ) ) ; // ...arranging satisfying bindings in order of decreasing preference... return CollectionUtils . collect ( satisfyingBindings , nopTransformer ( ) , new TreeSet < VarBindingDef > ( byUsage ) ) ; } , // ...arranging sets in a well-defined order for repeatable combinations... new TreeSet < Set < VarBindingDef > > ( varBindingSetSorter_ ) ) ) , // ...ignoring any infeasible combinations... bindings -> Tuple . of ( bindings ) != null ) , // ... forming each combination of satisfying bindings into a tuple... Tuple :: of ) ; }
Returns the set of tuples that could satisfy conditions required by the given test case .