Search in sources :

Example 1 with Account

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

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

Example 3 with Account

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

Example 4 with Account

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

Example 5 with Account

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

Aggregations

Account (com.orientechnologies.orient.test.domain.business.Account)23 Test (org.testng.annotations.Test)21 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)5 Address (com.orientechnologies.orient.test.domain.business.Address)5 City (com.orientechnologies.orient.test.domain.business.City)4 Country (com.orientechnologies.orient.test.domain.business.Country)4 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)3 ORID (com.orientechnologies.orient.core.id.ORID)2 EnumTest (com.orientechnologies.orient.test.domain.base.EnumTest)2 Company (com.orientechnologies.orient.test.domain.business.Company)2 Profile (com.orientechnologies.orient.test.domain.whiz.Profile)2 DatabaseAbstractTest (com.orientechnologies.DatabaseAbstractTest)1 OObjectDatabaseTx (com.orientechnologies.orient.object.db.OObjectDatabaseTx)1 ArrayList (java.util.ArrayList)1