@Test public void testLoadPojosWithIds() { ArrayList<String> repIds = null; List<AbstractPojo> pojos = null; try { // prepare a list of ids Model m = papi.loadCompleteModelWithDbId(mockModelId); m.toStringExtended(); repIds = new ArrayList<String>(); for (Revision r : m.getRevisions()) { Representation oneRep = r.getRepresentations().iterator().next(); repIds.add(oneRep.getDbId()); } // load list pojos = papi.loadPojos(repIds); assertEquals(pojos.size(), repIds.size()); for (AbstractPojo pojo : pojos) { Representation rep = (Representation) pojo; assertTrue(repIds.contains(rep.getDbId())); assertEquals(rep.getModel().getDbId(), mockModelId); } // empty list pojos = papi.loadPojos(new ArrayList<String>()); assertTrue(pojos.isEmpty()); } catch (Exception e) { fail(e.getMessage()); } try { // non-existent id repIds.add(NonExistentClusterId); pojos = papi.loadPojos(repIds); fail(); } catch (IllegalArgumentException e) { assert (true); } try { repIds.remove(NonExistentClusterId); repIds.add(AbcId); pojos = papi.loadPojos(repIds); fail(); } catch (IllegalArgumentException e) { assert (true); } }
@Test public void testLoadPojosWithClass() { try { List<AbstractPojo> pojos = papi.loadPojos(Model.class); assertEquals(pojos.size(), 2); for (AbstractPojo pojo : pojos) { try { // must be able to be cast to Model @SuppressWarnings("unused") Model m = (Model) pojo; } catch (ClassCastException e) { fail(); } } } catch (Exception e) { fail(e.getMessage()); } }