Пример #1
0
 @Test
 public void testFindPager() {
   Pager<PeriodStock> pager = periodStockService.findPager(new ObjectQuery());
   System.out.println("pageNo:" + pager.getPageNo());
   System.out.println("pageSize:" + pager.getPageSize());
   System.out.println("datas:" + pager.getRows());
   System.out.println("totalPages:" + pager.getTotalPages());
   Assert.assertNotNull(pager);
   Assert.assertTrue(pager.getRows().size() > 0);
 }
Пример #2
0
 @Test
 public void testSave() {
   List<Product> allProducts = productService.getAll();
   List<Warehouse> allHouse = warehouseService.getAll();
   List<Employee> allemps = employeeService.getAll();
   // periodStock.setItem(periodStockService.)
   for (int i = 0; i < allProducts.size(); i++) {
     PeriodStock periodStock = new PeriodStock(); // 如果出错请把字符串长度改短
     periodStock.setWarehouse((Warehouse) getRandomObject(allHouse));
     periodStock.setProduct(allProducts.get(i));
     periodStock.setQuantity(new Random().nextInt(20) + 1);
     periodStock.setAmount(new BigDecimal(new Random().nextInt(400)));
     periodStockService.save(periodStock);
   }
 }
Пример #3
0
 @Test
 public void testFindAllStock() {
   ObjectQuery objectQuery = new ObjectQuery();
   QueryGroup qg = new QueryGroup();
   objectQuery.setQueryGroup(qg);
   QueryRule queryRule = new QueryRule("productType.lft", "gt", "0");
   //		queryRule.setRealType(true);
   queryRule.setRootClass(Product.class);
   queryRule.setRootAlia("o");
   objectQuery.getQueryGroup().getRules().add(queryRule);
   objectQuery.setOrderField("quantity");
   objectQuery.setOrderType(ObjectQuery.ORDERDESC);
   List<PeriodStock> pss = periodStockService.findAllStock(objectQuery, null);
   System.out.println("总记录数:" + pss.size());
   //		for (PeriodStock periodStock : pss) {
   //			System.out.println(periodStock);
   //		}
   Assert.assertNotNull(pss);
   //		Assert.assertTrue(pss.size() > 0);
 }