Package com.orientechnologies.orient.test.domain.whiz

Examples of com.orientechnologies.orient.test.domain.whiz.Profile


  @Test(dependsOnMethods = "testSaveCircularLink")
  public void testQueryCircular() {
    List<Profile> result = database.query(new OSQLSynchQuery<ODocument>("select * from Profile"));

    Profile parent;
    for (Profile r : result) {

      System.out.println(r.getNick());

      parent = r.getInvitedBy();

      if (parent != null)
        System.out.println("- parent: " + parent.getName() + " " + parent.getSurname());
    }
  }
View Full Code Here


  @Test(dependsOnMethods = "testQueryCircular")
  public void testSaveMultiCircular() {
    startRecordNumber = database.countClusterElements("Profile");

    Profile bObama = new Profile("ThePresident", "Barack", "Obama", null);
    bObama.setLocation(new Address("Residence", new City(new Country("Hawaii"), "Honolulu"), "unknown"));
    bObama.addFollower(new Profile("PresidentSon1", "Malia Ann", "Obama", bObama));
    bObama.addFollower(new Profile("PresidentSon2", "Natasha", "Obama", bObama));

    database.save(bObama);
  }
View Full Code Here

  public void createLinked() {
    database = ODatabaseObjectPool.global().acquire(url, "admin", "admin");

    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);
View Full Code Here

    final List<Profile> result = database.query(new OSQLSynchQuery<Profile>(
        "select from Profile where location.city.country.name = 'Spain'"));

    Assert.assertTrue(result.size() > 0);

    Profile profile;
    for (int i = 0; i < result.size(); ++i) {
      profile = result.get(i);

      Assert.assertEquals(profile.getLocation().getCity().getCountry().getName(), "Spain");
    }

    database.close();
  }
View Full Code Here

    params.put("surname", "Obama");

    List<Profile> result = database.query(query, params);
    Assert.assertTrue(result.size() != 0);

    Profile obama = result.get(0);

    result = database.query(new OSQLSynchQuery<Profile>("select from Profile where followings contains ( @Rid = :who )"), obama);
    Assert.assertTrue(result.size() != 0);

    database.close();
View Full Code Here

    final long beginProfiles = database.countClusterElements("Profile");
    beginCities = database.countClusterElements("City");

    Country italy = database.newInstance(Country.class, "Italy");

    Profile garibaldi = database.newInstance(Profile.class, "GGaribaldi", "Giuseppe", "Garibaldi", null);
    garibaldi.setLocation(database.newInstance(Address.class, "Residence", database.newInstance(City.class, italy, "Rome"),
        "Piazza Navona, 1"));

    Profile bonaparte = database.newInstance(Profile.class, "NBonaparte", "Napoleone", "Bonaparte", garibaldi);
    bonaparte.setLocation(database.newInstance(Address.class, "Residence", garibaldi.getLocation().getCity(),
        "Piazza di Spagna, 111"));
    database.save(bonaparte);

    Assert.assertEquals(database.countClusterElements("Profile"), beginProfiles + 2);
  }
View Full Code Here

  @Test(dependsOnMethods = "testCitySaving")
  public void testCityEquality() {
    List<Profile> resultset = database.query(new OSQLSynchQuery<Object>("select from profile where location.city.name = 'Rome'"));
    Assert.assertEquals(resultset.size(), 2);

    Profile p1 = resultset.get(0);
    Profile p2 = resultset.get(1);

    Assert.assertNotSame(p1, p2);
    Assert.assertSame(OObjectEntitySerializer.getDocument((Proxy) p1.getLocation().getCity()),
        OObjectEntitySerializer.getDocument((Proxy) p2.getLocation().getCity()));
  }
View Full Code Here

        OObjectEntitySerializer.getDocument((Proxy) p2.getLocation().getCity()));
  }

  @Test(dependsOnMethods = "testCityEquality")
  public void testSaveCircularLink() {
    Profile winston = database.newInstance(Profile.class, "WChurcill", "Winston", "Churcill", null);
    winston.setLocation(database.newInstance(Address.class, "Residence",
        database.newInstance(City.class, database.newInstance(Country.class, "England"), "London"), "unknown"));

    Profile nicholas = database.newInstance(Profile.class, "NChurcill", "Nicholas ", "Churcill", winston);
    nicholas.setLocation(winston.getLocation());

    nicholas.setInvitedBy(winston);
    winston.setInvitedBy(nicholas);

    database.save(nicholas);
  }
View Full Code Here

  @Test(dependsOnMethods = "testSaveCircularLink")
  public void testQueryCircular() {
    List<Profile> result = database.query(new OSQLSynchQuery<ODocument>("select * from Profile"));

    Profile parent;
    for (Profile r : result) {

      System.out.println(r.getNick());

      parent = r.getInvitedBy();

      if (parent != null)
        System.out.println("- parent: " + parent.getName() + " " + parent.getSurname());
    }
  }
View Full Code Here

    OObjectDatabaseTx db = OObjectDatabasePool.global().acquire(url, "admin", "admin");
    try {
      db.getEntityManager().registerEntityClass(Profile.class);

      db.begin();
      Profile person = new Profile();
      person.setNick("Guy1");
      person.setName("Guy");
      person.setSurname("Ritchie");
      person = db.save(person);
      db.commit();

      db.begin();
      db.delete(person);
      db.commit();

      db.begin();
      Profile person2 = new Profile();
      person2.setNick("Guy2");
      person2.setName("Guy");
      person2.setSurname("Brush");
      person2 = db.save(person2);
      OObjectIteratorClass<Profile> it = db.browseClass(Profile.class);
      while (it.hasNext()) {
        System.out.println(it.next());
      }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.test.domain.whiz.Profile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.