Set test = new HashSet(); Iterator i = result.iterator(); while (i.hasNext()){ Object o = i.next(); if (o instanceof Image) { test.add(o); } else if (o instanceof Dataset) { Dataset dd = (Dataset) o; test.addAll(dd.getImages()); } else if (o instanceof Project) { Project pd = (Project) o; Iterator p = pd.getDatasets().iterator(); while (p.hasNext()){ Dataset dd = (Dataset) p.next(); test.addAll(dd.getImages()); } } }
Set test = Utils.getImagesinPID(result);
    public void testContainedImages(){        // Something        Set result = (Set) testFindPDIHierarchies();        assertTrue(nonNull, result != null && result.size() != 0);        // Not to much        Set test = new HashSet();        Iterator i = result.iterator();        while (i.hasNext()){            Object o = i.next();            if (o instanceof Image) {                test.add(o);            } else if (o instanceof Dataset) {                Dataset dd = (Dataset) o;                test.addAll(dd.getImages());            } else if (o instanceof Project) {                Project pd = (Project) o;                Iterator p = pd.getDatasets().iterator();                while (p.hasNext()){                    Dataset dd = (Dataset) p.next();                    test.addAll(dd.getImages());                }            }        }        assertTrue("There should only be as many images as in the data.imagesPDI", test.size() == this.getData().imgsPDI.size());//      TODO Make sure joins aren't leaving anything out because of empties!    }