use of com.orientechnologies.orient.test.domain.business.Account in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTestSchemaFull method create.
@Test
public void create() {
createBasicTestSchema();
database.setAutomaticSchemaGeneration(true);
database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.business");
if (url.startsWith(OEngineRemote.NAME)) {
database.getMetadata().reload();
}
database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.base");
if (url.startsWith(OEngineRemote.NAME)) {
database.getMetadata().reload();
}
database.setAutomaticSchemaGeneration(false);
database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.whiz");
if (url.startsWith(OEngineRemote.NAME)) {
database.getMetadata().reload();
}
startRecordNumber = database.countClusterElements("Account");
Account account;
for (long i = startRecordNumber; i < startRecordNumber + TOT_RECORDS; ++i) {
account = new Account((int) i, "Bill", "Gates");
account.setBirthDate(new Date());
account.setSalary(i + 300.10f);
account.getAddresses().add(new Address("Residence", rome, "Piazza Navona, 1"));
database.save(account);
}
}
use of com.orientechnologies.orient.test.domain.business.Account in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTest method readAndBrowseDescendingAndCheckHoleUtilization.
@Test(dependsOnMethods = "testAutoCreateClass")
public void readAndBrowseDescendingAndCheckHoleUtilization() {
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);
for (Account a : database.browseClass(Account.class)) {
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 queryPerFloat.
@Test(dependsOnMethods = "checkLazyLoadingOff")
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);
}
}
use of com.orientechnologies.orient.test.domain.business.Account in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTest method synchQueryCollectionsFetchNoLazyLoad.
@Test(dependsOnMethods = "testAutoCreateClass")
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) {
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 synchQueryCollectionsFetch.
@Test(dependsOnMethods = "testAutoCreateClass")
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) {
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());
}
Aggregations