use of com.orientechnologies.orient.test.domain.business.Company in project orientdb by orientechnologies.
the class CRUDObjectInheritanceTest method create.
@Test
public void create() {
database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.business");
database.command(new OCommandSQL("delete from Company")).execute();
startRecordNumber = database.countClass("Company");
Company company;
for (long i = startRecordNumber; i < startRecordNumber + TOT_RECORDS; ++i) {
company = database.newInstance(Company.class, (int) i, "Microsoft" + i);
company.setEmployees((int) (100000 + i));
company.getAddresses().add(new Address("Headquarter", redmond, "WA 98073-9717"));
database.save(company);
}
}
use of com.orientechnologies.orient.test.domain.business.Company in project orientdb by orientechnologies.
the class CRUDObjectInheritanceTest method queryPerSuperType.
@Test(dependsOnMethods = "queryByBaseType")
public void queryPerSuperType() {
final List<Company> result = database.query(new OSQLSynchQuery<ODocument>("select * from Company where name.length() > 0"));
Assert.assertTrue(result.size() == TOT_RECORDS);
Company account;
for (int i = 0; i < result.size(); ++i) {
account = result.get(i);
Assert.assertNotSame(account.getName().length(), 0);
}
}
use of com.orientechnologies.orient.test.domain.business.Company in project orientdb by orientechnologies.
the class CRUDObjectInheritanceTestSchemaFull method create.
@Test
public void create() {
database.getMetadata().getSchema().reload();
database.getMetadata().getSchema().synchronizeSchema();
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();
}
startRecordNumber = database.countClass("Company");
Company company;
for (long i = startRecordNumber; i < startRecordNumber + TOT_RECORDS; ++i) {
company = database.newInstance(Company.class, (int) i, "Microsoft" + i);
company.setEmployees((int) (100000 + i));
company.getAddresses().add(new Address("Headquarter", redmond, "WA 98073-9717"));
database.save(company);
}
}
use of com.orientechnologies.orient.test.domain.business.Company in project orientdb by orientechnologies.
the class CRUDObjectInheritanceTestSchemaFull method deleteFirst.
@Test(dependsOnMethods = "queryPerSuperType")
public void deleteFirst() {
database.setAutomaticSchemaGeneration(true);
startRecordNumber = database.countClass("Company");
// DELETE ALL THE RECORD IN THE CLUSTER
OObjectIteratorClass<Company> companyClusterIterator = database.browseClass("Company");
for (Company obj : companyClusterIterator) {
if (obj.getId() == 1) {
database.delete(obj);
break;
}
}
Assert.assertEquals(database.countClass("Company"), startRecordNumber - 1);
}
use of com.orientechnologies.orient.test.domain.business.Company in project orientdb by orientechnologies.
the class CRUDObjectInheritanceTestSchemaFull method queryByBaseType.
@Test(dependsOnMethods = "testCreate")
public void queryByBaseType() {
database.setAutomaticSchemaGeneration(true);
final List<Account> result = database.query(new OSQLSynchQuery<Account>("select from Company where name.length() > 0"));
Assert.assertTrue(result.size() > 0);
Assert.assertEquals(result.size() - startRecordNumber, TOT_RECORDS);
int companyRecords = 0;
Account account;
for (int i = 0; i < result.size(); ++i) {
account = result.get(i);
if (account instanceof Company)
companyRecords++;
Assert.assertNotSame(account.getName().length(), 0);
}
Assert.assertEquals(companyRecords, TOT_RECORDS);
}
Aggregations