Package com.orientechnologies.orient.test.domain.business

Examples of com.orientechnologies.orient.test.domain.business.Account


  public void queryPerFloat() {
    final List<Account> result = database.query(new OSQLSynchQuery<ODocument>("select * from Account where salary = 500.10"));

    Assert.assertTrue(result.size() > 0);

    Account account;
    for (int i = 0; i < result.size(); ++i) {
      account = result.get(i);

      Assert.assertEquals(account.getSalary(), 500.10f);
    }
  }
View Full Code Here


  @Test(dependsOnMethods = "testUpdate")
  public void testEmbeddedBinary() {
    database.getMetadata().getSchema().reload();

    Account a = new Account(0, "Chris", "Martin");
    a.setThumbnail(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
    a = database.save(a);
    database.close();

    database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
    Account aa = (Account) database.load((ORID) a.getRid());
    Assert.assertNotNull(a.getThumbnail());
    Assert.assertNotNull(aa.getThumbnail());
    byte[] b = aa.getThumbnail();
    for (int i = 0; i < 10; ++i)
      Assert.assertEquals(b[i], i);
  }
View Full Code Here

    // check if the database exists and clean before running tests
    OObjectDatabaseTx database = new OObjectDatabaseTx(url);
    database.open("admin", "admin");

    try {
      Account account = new Account();
      account.setName("John Grisham");
      account = database.save(account);

      Address address1 = new Address();
      address1.setStreet("Mulholland drive");

      Address address2 = new Address();
      address2.setStreet("Via Veneto");

      List<Address> addresses = new ArrayList<Address>();
      addresses.add(address1);
      addresses.add(address2);
      account.setAddresses(addresses);

      account = database.save(account);

      database.commit();

      String originalName = account.getName();

      database.begin(TXTYPE.OPTIMISTIC);

      Assert.assertEquals(account.getAddresses().size(), 2);
      account.getAddresses().remove(1); // delete one of the objects in the Books collection to see how rollback behaves
      Assert.assertEquals(account.getAddresses().size(), 1);
      account.setName("New Name"); // change an attribute to see if the change is rolled back
      account = database.save(account);

      Assert.assertEquals(account.getAddresses().size(), 1); // before rollback this is fine because one of the books was removed

      database.rollback(); // rollback the transaction

      account = database.reload(account, true); // ignore cache, get a copy of author from the datastore
      Assert.assertEquals(account.getAddresses().size(), 2); // this is fine, author still linked to 2 books
      Assert.assertEquals(account.getName(), originalName); // name is restored

      int bookCount = 0;
      for (Address b : database.browseClass(Address.class)) {
        if (b.getStreet().equals("Mulholland drive") || b.getStreet().equals("Via Veneto"))
          bookCount++;
View Full Code Here

    database.begin(TXTYPE.NOTX);
  }

  @Override
  public void cycle() {
    account = new Account((int) data.getCyclesDone(), "Luca", "Garulli");
    account.setBirthDate(date);
    account.setSalary(3000f + data.getCyclesDone());

    database.save(account);
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.test.domain.business.Account

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.