Skip to content
Snippets Groups Projects
Commit 14c25f92 authored by felmer's avatar felmer
Browse files

SampleListingWorker fixed, SampleListingWorkerTest fixed and extended

SVN: 18167
parent e4259972
No related merge requests found
......@@ -472,6 +472,10 @@ final class SampleListingWorker extends AbstractLister
private Iterable<SampleRecord> tryGetIteratorForParentSamples()
{
Collection<Long> ids = criteria.getChildrenSampleIds();
if (ids.isEmpty())
{
return null;
}
return query.getParentSamplesForChildren(parentRelationhipTypeId, new LongOpenHashSet(ids));
}
......
......@@ -171,7 +171,7 @@ public final class ListOrSearchSampleCriteria extends ListSampleCriteria
{
if (listCriteria == null)
{
return null;
return Collections.<Long>emptySet();
}
Collection<Long> childrenSampleIds = listCriteria.getChildrenSampleIds();
if (childrenSampleIds != null)
......@@ -183,10 +183,7 @@ public final class ListOrSearchSampleCriteria extends ListSampleCriteria
{
return Collections.<Long>emptySet();
}
else
{
return Collections.<Long>singleton(childSampleId.getId());
}
return Collections.<Long>singleton(childSampleId.getId());
}
@Override
......
......@@ -177,6 +177,34 @@ public class SampleListingWorkerTest extends AbstractDAOTest
checkSpace(s);
}
}
@Test
public void testListSamplesForChildren()
{
final ListSampleCriteria baseCriteria =
ListSampleCriteria.createForChildren(Arrays.asList(CHILDREN_IDS));
final ListOrSearchSampleCriteria criteria = new ListOrSearchSampleCriteria(baseCriteria);
final SampleListingWorker worker =
SampleListingWorker.create(criteria, BASE_INDEX_URL, sampleListerDAO, secondaryDAO);
final List<Sample> list = worker.load();
assertEquals(2, list.size());
for (Sample s : list)
{
long sId = s.getId().longValue();
long pId = s.getGeneratedFrom().getId().longValue();
if (sId == PARENT1_ID)
{
assertTrue(pId == GRANDPARENT1_ID);
} else if (sId == PARENT2_ID)
{
assertTrue(pId == GRANDPARENT2_ID);
} else
{
fail("unexpected parent id " + pId);
}
checkSpace(s);
}
}
@Test
public void testListSamplesForExperiment()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment