EmpireBatchItemDao extends EmpireDao implements BatchItemDao { @Override public BatchItem find(int id) { DBRecord dbr = new DBRecord(); try { dbr.read(table, id, getConnection()); BatchItem item = new BatchItem(); dbr.getBeanProperties(item); return item; } finally { dbr.close(); } } EmpireBatchItemDao(ProarcDatabase db); @Override BatchItem create(); @Override void update(BatchItem item); @Override BatchItem find(int id); @Override List<BatchItem> find(int batchId, String pid, String dsId, String state, String type); @Override void removeItems(int batchId);  }
@Test public void testFind() throws Exception { IDataSet db = database( support.loadFlatXmlDataStream(getClass(), "user.xml"), support.loadFlatXmlDataStream(getClass(), "batch.xml"), support.loadFlatXmlDataStream(getClass(), "batch_item.xml") ); support.cleanInsert(support.getConnection(tx), db); tx.commit(); BatchItem item = dao.find(1); assertNotNull(item); assertEquals(1, (int) item.getId()); }
@Test public void testFind_Items() throws Exception { IDataSet db = database( support.loadFlatXmlDataStream(getClass(), "user.xml"), support.loadFlatXmlDataStream(getClass(), "batch_with_items.xml") ); support.cleanInsert(support.getConnection(tx), db); tx.commit(); List<BatchItem> items = dao.find(2, null, null, null, Type.OBJECT.name()); assertEquals(4, items.size()); items = dao.find(2, null, null, ObjectState.EXCLUDED.name(), Type.OBJECT.name()); assertEquals(1, items.size()); items = dao.find(2, "pid:item:2", null, null, Type.FILE.name()); assertEquals(2, items.size()); }