Search in sources :

Example 1 with Company

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);
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) Company(com.orientechnologies.orient.test.domain.business.Company) Address(com.orientechnologies.orient.test.domain.business.Address) Test(org.testng.annotations.Test)

Example 2 with 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);
    }
}
Also used : Company(com.orientechnologies.orient.test.domain.business.Company) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 3 with Company

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);
    }
}
Also used : Company(com.orientechnologies.orient.test.domain.business.Company) Address(com.orientechnologies.orient.test.domain.business.Address) Test(org.testng.annotations.Test)

Example 4 with 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);
}
Also used : Company(com.orientechnologies.orient.test.domain.business.Company) Test(org.testng.annotations.Test)

Example 5 with Company

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);
}
Also used : Account(com.orientechnologies.orient.test.domain.business.Account) Company(com.orientechnologies.orient.test.domain.business.Company) Test(org.testng.annotations.Test)

Aggregations

Company (com.orientechnologies.orient.test.domain.business.Company)8 Test (org.testng.annotations.Test)8 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2 Account (com.orientechnologies.orient.test.domain.business.Account)2 Address (com.orientechnologies.orient.test.domain.business.Address)2 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)1