@Test public void testRemove() { int oldSize = questionDao.list().size(); Question question = questionDao.find(1); questionDao.delete(question); int newSize = questionDao.list().size(); assertFalse(oldSize != newSize); }
@Test public void testAdd() { int oldSize = questionDao.list().size(); Question question = new Question("Are you OK?", 2); questionDao.add(question); int newSize = questionDao.list().size(); assertFalse(oldSize == newSize); }
public void removeEntity(int rowIndex) { GenericDao<Bid> bidDao = DaoManager.getInstance().getBidDao(); Good entity = (Good) items.get(rowIndex); for (Bid b : entity.getBids()) { bidDao.delete(b); } items.remove(rowIndex); fireTableDataChanged(); DAO.delete((T) entity); }
@Test public void testFindAll() throws Exception { log.warn("------------------------------------------------------------------"); log.warn( "started ParkingEmployeeAndSpace test: a single parking space and single employee through import"); Collection<ParkingEmployee> allEmployees = empDao.findAll(); assertEquals(1, allEmployees.size()); Collection<ParkingSpace> allSpaces = parkDao.findAll(); assertEquals(1, allSpaces.size()); }
// verifying that the relation and the traversal from the owned to the // owning side works @Test public void testGettingEmployeeFromParking() { List<ParkingSpace> allSpaces = parkDao.findAll(); ParkingSpace d = allSpaces.get(0); assertNotNull(d.getEmployee()); }
// verifying that the relation and the traversal from the owning to the // owned side works @Test public void testGettingParkingFromEmployee() { List<ParkingEmployee> allEmployees = empDao.findAll(); ParkingEmployee e = allEmployees.get(0); assertNotNull(e.getParking()); }
public void update(Subject t, List objList, String id) { if (id != null && "".equals(id)) { this.infoattrDao.delete(id); } if (objList != null && objList.size() > 0) { for (int i = 0; i < objList.size(); i++) { this.infoattrDao.insert((Infoattr) objList.get(i)); } } super.update(t); }
@Test public void testFindAll() throws Exception { log.warn("------------------------------------------------------------------"); log.warn("started findAll test"); Collection<Employee> allEmployees = dao.findAll(); log.info("found {} employees", allEmployees.size()); for (Employee e : allEmployees) { log.info("found employee: {}", e); } }
@Override public void delete(String id) { super.delete(id); String[] ids = id.split(","); for (int i = 0; i < ids.length; i++) { Subject subject = super.get(ids[i].trim()); if (subject != null && subject.getInfoattr_id() != null && !subject.getInfoattr_id().equals("")) { String infoattr_id = subject.getInfoattr_id(); this.infoattrDao.delete(infoattr_id); } } }
@Override public void delete(String name) throws Exception { if (!existsCollection(name)) throw new InvalidCollectionException("Collection " + name + " does not exists"); // get the helper class GenericDao gdao = GenericDao.getInstance(); // begin transaction DbHelper.requestTransaction(); try { // delete all vertices linked to objects in this class String deleteVertices = "delete vertex _bb_nodevertex where _node.@class=?"; Object[] params = {name}; gdao.executeCommand(deleteVertices, params); // delete vertices linked to the collection entry in the _bb_collection class // note: the params are equals to the previous one (just the collection name) String deleteVertices2 = "delete vertex _bb_nodevertex where _node.@class='_bb_collection' and _node.name=?"; gdao.executeCommand(deleteVertices2, params); // delete this collection from the list of declared collections // note: the params are equals to the previous one (just the collection name) String deleteFromCollections = "delete from _bb_collection where name =?"; gdao.executeCommand(deleteFromCollections, params); // delete all records belonging to the dropping collection.... // it could be done dropping the class, but in this case we not should be able to perform a // rollback String deleteAllRecords = "delete from " + name; gdao.executeCommand(deleteAllRecords, new Object[] {}); // commit DbHelper.commitTransaction(); // drop the collection class outside collection String dropCollection = "drop class " + name; gdao.executeCommand(dropCollection, new Object[] {}); } catch (Exception e) { // rollback in case of error DbHelper.rollbackTransaction(); if (Logger.isDebugEnabled()) Logger.debug("An error occured deleting the collection " + name, e); throw e; } } // delete
@Before public void before() { dao.setKlazz(Employee.class); }
public void addEntity(T item) { DAO.create(item); fireTableDataChanged(); }
@Override public int getRowCount() { items = DAO.findAll(); return items.size(); }
@Test public void testList() { List<Question> list = questionDao.list(); assertNotNull(list); assertFalse(list.isEmpty()); }
public List<ODocument> getLinks(QueryParams criteria) throws SqlInjectionException { GenericDao gdao = GenericDao.getInstance(); return gdao.executeQuery(VIEW_BASE, criteria); }
@Before public void before() { empDao.setKlazz(ParkingEmployee.class); parkDao.setKlazz(ParkingSpace.class); }