#!/usr/bin/env python

import coral
from coral.util.search.query import *
import coral.util.search.util as U

prj=coral.loadDocument("testMultipleResults.xmi")

target_model=None
query_set=coral.Set()
start_q=None

for root in prj.contents():
    if root.name == "target":
        target_model=root

    if root.name == "query":
        for elem in root.ownedElement:
            if elem.oclIsKindOf(coral.lang.UML14.Association):
                start_q=elem
            query_set.append(elem)

assert target_model
assert not query_set.isEmpty()
assert start_q

# start_q is part of two different results
# check that the search finds both

q2t=search(U.get_all_parts(query_set), target_model, start_q,True)
assert len(q2t) == 4, "Search didn't return all possible results"
