public void insertProducts() { if (server.find(Product.class).findCount() > 0) { return; } server.execute( () -> { Product p = new Product(); p.setName("Chair"); p.setSku("C001"); server.save(p); p = new Product(); p.setName("Desk"); p.setSku("DSK1"); server.save(p); p = new Product(); p.setName("Computer"); p.setSku("C002"); server.save(p); p = new Product(); p.setName("Printer"); p.setSku("C003"); server.save(p); }); }
public void insertCountries() { if (server.find(Country.class).findCount() > 0) { return; } server.execute( () -> { Country c = new Country(); c.setCode("NZ"); c.setName("New Zealand"); server.save(c); Country au = new Country(); au.setCode("AU"); au.setName("Australia"); server.save(au); }); }
public static synchronized void reset() { if (runOnce) { return; } final ResetBasicData me = new ResetBasicData(); server.execute( () -> { if (server.find(Product.class).findCount() > 0) { // we can't really delete this base data as // the test rely on the products being in there return; } // me.deleteAll(); me.insertCountries(); me.insertProducts(); me.insertTestCustAndOrders(); }); runOnce = true; }
public void execute() { server.execute(this, null); }