HibernateDrugPurchaseOrderDAO implements DrugPurchaseOrderDAO { public List<DrugPurchaseOrder> getAllDrugPurchaseOrdersNotReceived() { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(DrugPurchaseOrder.class); criteria.add(Restrictions.eq("received", false)); List<DrugPurchaseOrder> drugPurchaseOrders = new ArrayList<DrugPurchaseOrder>(); drugPurchaseOrders.addAll(criteria.list()); return drugPurchaseOrders; }  void setSessionFactory(SessionFactory sessionFactory); DrugPurchaseOrder saveDrugPurchaseOrder(DrugPurchaseOrder drugPurchaseOrder); DrugPurchaseOrder getDrugPurchaseOrderByUuid(String uuid); List<DrugPurchaseOrder> getAllDrugPurchaseOrders(); List<DrugPurchaseOrder> getAllDrugPurchaseOrdersNotReceived(); DrugPurchaseOrder updateDrugPurchaseOrder(DrugPurchaseOrder drugPurchaseOrder); void deleteDrugPurchaseOrder(DrugPurchaseOrder drugPurchaseOrder); List<DrugPurchaseOrder> getDrugPurchaseOrderByProvider(Integer providerId); @Override List<DrugPurchaseOrder> getDrugPurchaseOrderByDispenseLocation(Integer dispenseLocation); @Override List<DrugPurchaseOrder> getDrugPurchaseOrderByStockLocation(Integer stockLocation);  }
@Test public void testGetAllDrugPurchaseOrdersNotReceived() { List<DrugPurchaseOrder> allDrugPurchaseOrders = dao.getAllDrugPurchaseOrders(); int size = allDrugPurchaseOrders.size(); for (DrugPurchaseOrder dpOrder : allDrugPurchaseOrders) { if (dpOrder.isReceived()) { size--; } } assertEquals(size, 1); }