Package com.avaje.tests.model.basic

Examples of com.avaje.tests.model.basic.UTMaster


public class TestUniDirectional extends BaseTestCase {

  @Test
  public void test() {

    UTMaster m = new UTMaster();
    m.setName("mast1");
    m.addDetail(new UTDetail("d11", 10, 20.50));
    m.addDetail(new UTDetail("d12", 3, 5.50));
    m.addDetail(new UTDetail("d13", 5, 1.0));

    Ebean.save(m);

    Assert.assertNotNull(m.getId());
    Assert.assertNotNull(m.getVersion());

    List<UTDetail> details = m.getDetails();
    for (UTDetail utDetail : details) {
      Assert.assertNotNull(utDetail.getId());
      Assert.assertNotNull(utDetail.getVersion());
    }

    UTDetail d4 = new UTDetail("d14", 2, 3.0);
    m.addDetail(d4);

    Ebean.save(m);

    Assert.assertNotNull(d4.getId());
    Integer d4ver = d4.getVersion();
View Full Code Here


    }
  }

  private UTMaster createMasterAndDetails(int masterPos) {

    UTMaster master = createMaster(masterPos);
    List<UTDetail> details = new ArrayList<UTDetail>();

    int count = 2 + random.nextInt(20);

    for (int i = 0; i < count; i++) {

      int qty = 1 + random.nextInt(99);
      double amount = random.nextDouble();

      details.add(createDetail(masterPos + "-" + i, qty, amount));
    }
    master.setDetails(details);
    return master;
  }
View Full Code Here

    master.setDetails(details);
    return master;
  }

  private UTMaster createMaster(int position) {
    UTMaster m = new UTMaster();
    m.setName("batchInsert-master" + position);
    return m;
  }
View Full Code Here

TOP

Related Classes of com.avaje.tests.model.basic.UTMaster

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.