It's all about the answers!

Ask a question

I've been having trouble with getAuthenticatedContributor(). It query for a id that doens't exist in DB.


Ícaro Magnago (1111) | asked Sep 06 '12, 12:46 p.m.
edited Sep 06 '12, 12:51 p.m.
 Hi,

I have a service that get all work items whose the owner is the user logged in. I've used the getAuthenticatedContributor method, but it returns a contributor that doens't exist in DB that I'm using.

 
public IWorkItemHandle[] getWorkItemsByContributor()

      throws TeamRepositoryException {        

               ......

IQueryService queryService = getService(IQueryService.class);

WorkItemQueryModel queryModel = BaseWorkItemQueryModel.WorkItemQueryModel.ROOT;

IItemQuery itemQuery = IItemQuery.FACTORY.newInstance(queryModel);

IContributorHandle contributor = getAuthenticatedContributor();                                                         itemQuery.filter(queryModel.owner()._eq(itemQuery.newItemHandleArg()));        

IItemQueryPage itemQueryPage = queryService.queryItems(itemQuery, new Object[]{contributor}, IQueryService.ITEM_QUERY_MAX_PAGE_SIZE)

IRepositoryItemService repositoryItemService = getService(IRepositoryItemService.class);

IItem[] items = repositoryItemService.fetchItems(itemQueryPage.handlesAsArray(), null);

List<IItem> wis = Arrays.asList(items);

return (IWorkItemHandle[]) wis.toArray(new IWorkItemHandle[wis.size()]);

...

And the unit test class:

The class AbstractSaturnoRemoteServiceTestCase extends AbstractRemoteServiceTestCase

public class SaturnoServiceTest extends AbstractSaturnoRemoteServiceTestCase{ ... 
public void testGetWorkItemsByContributor(){
IContributorHandle contributor = getAuthenticatedContributorHandle(); 
 IWorkItemHandle[] workItems = getSaturnoService().getWorkItemsByContributor(); 
assertNotNull(workItems);
... } 

  I can't figure it out what's wrong. Any suggestion?

Be the first one to answer this question!


Register or to post your answer.