use of eu.ggnet.dwoss.stock.ee.eao.StockLocationEao in project dwoss by gg-net.
the class StockLocationEaoIT method testFind.
@Test
public void testFind() throws Exception {
StockLocationEao sls = new StockLocationEao(em);
utx.begin();
em.joinTransaction();
Stock laden = new Stock(0);
laden.setName("Laden");
for (String name : STOCK_LOCATION_NAMES) {
laden.addStockLocation(new StockLocation(name));
}
em.persist(laden);
Stock lager = new Stock(1);
lager.setName("Lager");
for (String name : STOCK_LOCATION_NAMES) {
lager.addStockLocation(new StockLocation(name));
}
em.persist(lager);
utx.commit();
utx.begin();
em.joinTransaction();
List<StockLocation> stockLocations = sls.findAll();
assertEquals(STOCK_LOCATION_NAMES.length * 2, stockLocations.size());
stockLocations = sls.find("%0");
assertEquals(2, stockLocations.size());
assertEquals(STOCK_LOCATION_NAMES[0], stockLocations.get(0).getName());
stockLocations = sls.find("*0");
assertEquals(2, stockLocations.size());
assertEquals(STOCK_LOCATION_NAMES[0], stockLocations.get(0).getName());
stockLocations = sls.find("*5");
assertEquals(2, stockLocations.size());
assertEquals(STOCK_LOCATION_NAMES[5], stockLocations.get(0).getName());
stockLocations = sls.find(laden, "*0");
assertEquals(1, stockLocations.size());
assertEquals(STOCK_LOCATION_NAMES[0], stockLocations.get(0).getName());
assertEquals(laden, stockLocations.get(0).getStock());
utx.commit();
}
Aggregations