Search in sources :

Example 6 with City

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

Example 7 with City

use of com.orientechnologies.orient.test.domain.business.City in project orientdb by orientechnologies.

the class ObjectDetachingTestSchemaFull method testReloadAndDetachAll.

@Test(dependsOnMethods = "testDetachAllNonProxied")
public void testReloadAndDetachAll() {
    // DELETE PREVIOUS TEST DATA
    database.command(new OCommandSQL("delete from Profile where nick = 'Jack'")).execute();
    // Open db
    // Create the address without country
    Address anAddress = new Address("Godewaersvelde");
    anAddress = database.save(anAddress);
    Address realAddress = database.detachAll(anAddress, true);
    // Create the person
    Profile aPerson = new Profile("Jack", "Jack", "Black", null);
    aPerson.setLocation(realAddress);
    aPerson = database.save(aPerson);
    // Update the address by another way (another process for example)
    City aCity = new City("Paris");
    aCity = database.save(aCity);
    String command = "update " + anAddress.getId() + " set city = " + database.getIdentity(aCity);
    database.command(new OCommandSQL(command)).execute();
    realAddress = database.reload(anAddress, true);
    Assert.assertNotNull(realAddress.getCity());
    // At this point, in OrientDB Studio everything is fine
    // The address has the good country @rid, with version +1
    // Now reload and detachAll the person
    Profile newPerson = database.reload(aPerson, "*:-1", true);
    Profile finalPerson = database.detachAll(newPerson, true);
    // But with the reload, the country is null
    // out = null
    Assert.assertNotNull(finalPerson.getLocation().getCity());
    // Same problem with query and detachAll
    String query = "select from Profile where name = 'Jack' and surname = 'Black'";
    newPerson = (Profile) database.query(new OSQLSynchQuery<Object>(query), new Object[0]).get(0);
    finalPerson = database.detachAll(newPerson, true);
    // out = null
    Assert.assertNotNull(finalPerson.getLocation().getCity());
// Close db
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) Address(com.orientechnologies.orient.test.domain.business.Address) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) City(com.orientechnologies.orient.test.domain.business.City) Profile(com.orientechnologies.orient.test.domain.whiz.Profile) Test(org.testng.annotations.Test) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest)

Example 8 with City

use of com.orientechnologies.orient.test.domain.business.City in project orientdb by orientechnologies.

the class ObjectDetachingTestSchemaFull method testJPALongIdAnnotation.

@Test(dependsOnMethods = "createAnnotatedObjects")
public void testJPALongIdAnnotation() {
    // BROWSE ALL THE OBJECTS
    Assert.assertTrue(database.countClass(City.class) > 0);
    for (City c : database.browseClass(City.class)) {
        c.getId();
        Assert.assertNotNull(c.getId());
    }
}
Also used : City(com.orientechnologies.orient.test.domain.business.City) Test(org.testng.annotations.Test) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest)

Example 9 with City

use of com.orientechnologies.orient.test.domain.business.City in project orientdb by orientechnologies.

the class CRUDObjectPhysicalTest method createLinked.

@Test(dependsOnMethods = "testUpdate")
public void createLinked() {
    long profiles = database.countClass("Profile");
    Profile neo = new Profile("Neo").setValue("test").setLocation(new Address("residence", new City(new Country("Spain"), "Madrid"), "Rio de Castilla"));
    neo.addFollowing(new Profile("Morpheus"));
    neo.addFollowing(new Profile("Trinity"));
    database.save(neo);
    Assert.assertEquals(database.countClass("Profile"), profiles + 3);
}
Also used : Address(com.orientechnologies.orient.test.domain.business.Address) Country(com.orientechnologies.orient.test.domain.business.Country) City(com.orientechnologies.orient.test.domain.business.City) Profile(com.orientechnologies.orient.test.domain.whiz.Profile) Test(org.testng.annotations.Test)

Example 10 with City

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

Aggregations

City (com.orientechnologies.orient.test.domain.business.City)10 Test (org.testng.annotations.Test)9 Address (com.orientechnologies.orient.test.domain.business.Address)6 Country (com.orientechnologies.orient.test.domain.business.Country)6 Profile (com.orientechnologies.orient.test.domain.whiz.Profile)6 EnumTest (com.orientechnologies.orient.test.domain.base.EnumTest)5 Account (com.orientechnologies.orient.test.domain.business.Account)4 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)2 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)2