use of com.orientechnologies.orient.test.domain.business.Account in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTestSchemaFull method synchQueryCollectionsFetch.
@Test(dependsOnMethods = "readAndBrowseDescendingAndCheckHoleUtilization")
public void synchQueryCollectionsFetch() {
database.getLocalCache().invalidate();
// BROWSE ALL THE OBJECTS
Set<Integer> ids = new HashSet<Integer>(TOT_RECORDS);
for (int i = 0; i < TOT_RECORDS; i++) ids.add(i);
List<Account> result = database.query(new OSQLSynchQuery<Account>("select from Account").setFetchPlan("*:-1"));
for (Account a : result) {
if (Company.class.isAssignableFrom(a.getClass()))
continue;
int id = a.getId();
Assert.assertTrue(ids.remove(id));
Assert.assertEquals(a.getId(), id);
Assert.assertEquals(a.getName(), "Bill");
Assert.assertEquals(a.getSurname(), "Gates");
Assert.assertEquals(a.getSalary(), id + 300.1f);
Assert.assertEquals(a.getAddresses().size(), 1);
Assert.assertEquals(a.getAddresses().get(0).getCity().getName(), rome.getName());
Assert.assertEquals(a.getAddresses().get(0).getCity().getCountry().getName(), rome.getCountry().getName());
}
Assert.assertTrue(ids.isEmpty());
}
use of com.orientechnologies.orient.test.domain.business.Account in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTestSchemaFull method update.
@Test(dependsOnMethods = "mapEnumAndInternalObjects")
public void update() {
int i = 0;
Account a;
for (Object o : database.browseCluster("Account").setFetchPlan("*:1")) {
a = (Account) o;
if (i % 2 == 0)
a.getAddresses().set(0, new Address("work", new City(new Country("Spain"), "Madrid"), "Plaza central"));
a.setSalary(i + 500.10f);
database.save(a);
i++;
}
}
use of com.orientechnologies.orient.test.domain.business.Account in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTestSchemaFull method synchQueryCollectionsFetchNoLazyLoad.
@Test(dependsOnMethods = "synchQueryCollectionsFetch")
public void synchQueryCollectionsFetchNoLazyLoad() {
database.getLocalCache().invalidate();
database.setLazyLoading(false);
// BROWSE ALL THE OBJECTS
Set<Integer> ids = new HashSet<Integer>(TOT_RECORDS);
for (int i = 0; i < TOT_RECORDS; i++) ids.add(i);
List<Account> result = database.query(new OSQLSynchQuery<Account>("select from Account").setFetchPlan("*:2"));
for (Account a : result) {
if (Company.class.isAssignableFrom(a.getClass()))
continue;
int id = a.getId();
Assert.assertTrue(ids.remove(id));
Assert.assertEquals(a.getId(), id);
Assert.assertEquals(a.getName(), "Bill");
Assert.assertEquals(a.getSurname(), "Gates");
Assert.assertEquals(a.getSalary(), id + 300.1f);
Assert.assertEquals(a.getAddresses().size(), 1);
Assert.assertEquals(a.getAddresses().get(0).getCity().getName(), rome.getName());
Assert.assertEquals(a.getAddresses().get(0).getCity().getCountry().getName(), rome.getCountry().getName());
}
Assert.assertTrue(ids.isEmpty());
}
use of com.orientechnologies.orient.test.domain.business.Account in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTest method update.
@Test(dependsOnMethods = "mapEnumAndInternalObjects")
public void update() {
int i = 0;
Account a;
for (Object o : database.browseClass("Account").setFetchPlan("*:1")) {
a = (Account) o;
if (i % 2 == 0)
a.getAddresses().set(0, new Address("work", new City(new Country("Spain"), "Madrid"), "Plaza central"));
a.setSalary(i + 500.10f);
database.save(a);
i++;
}
}
use of com.orientechnologies.orient.test.domain.business.Account in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTest method testEmbeddedBinary.
@Test(enabled = false, dependsOnMethods = "testCreate")
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);
}
Aggregations