### Question:
IRODSStarringServiceImpl extends AbstractIRODSTaggingService implements IRODSStarringService { @Override public List<IRODSStarredFileOrCollection> listStarredCollections(final int pagingOffset) throws JargonException { log.info("listStarredCollections()"); List<AVUQueryElement> avuQueryElements = buildAVUQueryForStarred(); List<IRODSStarredFileOrCollection> irodsStarredFiles = new ArrayList<>(); log.info("querying metadata as a collection to look for starred"); CollectionAO collectionAO = getIrodsAccessObjectFactory().getCollectionAO(getIrodsAccount()); try { List<MetaDataAndDomainData> metadata = collectionAO.findMetadataValuesByMetadataQuery(avuQueryElements); for (MetaDataAndDomainData metadataAndDomainData : metadata) { log.debug("adding starred file:{}", metadataAndDomainData); irodsStarredFiles.add(transformMetadataValueToStarValue(metadataAndDomainData)); } } catch (JargonQueryException e) { throw new JargonException("error querying for metadata", e); } return irodsStarredFiles; } IRODSStarringServiceImpl(final IRODSAccessObjectFactory irodsAccessObjectFactory,
			final IRODSAccount irodsAccount); @Override IRODSStarredFileOrCollection findStarredForAbsolutePath(final String irodsAbsolutePath); @Override void starFileOrCollection(final String irodsAbsolutePath, final String description); @Override void unstarFileOrCollection(final String irodsAbsolutePath); @Override List<IRODSStarredFileOrCollection> listStarredCollections(final int pagingOffset); @Override List<IRODSStarredFileOrCollection> listStarredDataObjects(final int pagingOffset); static final Logger log; }### Answer:
@SuppressWarnings("unchecked") @Test public void testListStarredCollections() throws Exception { String absolutePath = "/absolute/path/to/coll"; String description = "description"; IRODSAccessObjectFactory irodsAccessObjectFactory = Mockito.mock(IRODSAccessObjectFactory.class); CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = Mockito .mock(CollectionAndDataObjectListAndSearchAO.class); DataObjectAO dataObjectAO = Mockito.mock(DataObjectAO.class); CollectionAO collectionAO = Mockito.mock(CollectionAO.class); MetaDataAndDomainData metadataAndDomainData = MetaDataAndDomainData.instance(MetadataDomain.COLLECTION, "1", absolutePath, 1, description, irodsAccount.getUserName(), UserTaggingConstants.STAR_AVU_UNIT); List<MetaDataAndDomainData> metadataList = new ArrayList<MetaDataAndDomainData>(); metadataList.add(metadataAndDomainData); Mockito.when(collectionAO.findMetadataValuesByMetadataQuery(Matchers.anyList())).thenReturn(metadataList); Mockito.when(irodsAccessObjectFactory.getCollectionAndDataObjectListAndSearchAO(irodsAccount)) .thenReturn(collectionAndDataObjectListAndSearchAO); Mockito.when(irodsAccessObjectFactory.getCollectionAO(irodsAccount)).thenReturn(collectionAO); Mockito.when(irodsAccessObjectFactory.getDataObjectAO(irodsAccount)).thenReturn(dataObjectAO); IRODSStarringService irodsStarringService = new IRODSStarringServiceImpl(irodsAccessObjectFactory, irodsAccount); List<IRODSStarredFileOrCollection> collections = irodsStarringService.listStarredCollections(0); Assert.assertEquals("did not find the one metadata value", 1, collections.size()); }