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

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


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

    Country italy = new Country("Italy");

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

    Profile bonaparte = new Profile("NBonaparte", "Napoleone", "Bonaparte", garibaldi);
    bonaparte.setLocation(new Address("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(p1.getLocation().getCity(), p2.getLocation().getCity());
  }
View Full Code Here

    Assert.assertSame(p1.getLocation().getCity(), p2.getLocation().getCity());
  }

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

    Profile nicholas = new Profile("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

  @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

  @Test
  public void queryWithRidAsParameters() {
    database = ODatabaseObjectPool.global().acquire(url, "admin", "admin");
    database.getMetadata().getSchema().reload();

    Profile profile = (Profile) database.browseClass("Profile").next();

    final OSQLSynchQuery<Profile> query = new OSQLSynchQuery<Profile>("select from Profile where @rid = ?");
    List<Profile> result = database.query(query, new ORecordId(profile.getId()));

    Assert.assertEquals(result.size(), 1);

    database.close();
  }
View Full Code Here

  @Test
  public void queryWithRidStringAsParameters() {
    database = ODatabaseObjectPool.global().acquire(url, "admin", "admin");
    database.getMetadata().getSchema().reload();

    Profile profile = (Profile) database.browseClass("Profile").next();

    OSQLSynchQuery<Profile> query = new OSQLSynchQuery<Profile>("select from Profile where @rid = ?");
    List<Profile> result = database.query(query, profile.getId());

    Assert.assertEquals(result.size(), 1);

    // TEST WITHOUT # AS PREFIX
    query = new OSQLSynchQuery<Profile>("select from Profile where @rid = ?");
    result = database.query(query, profile.getId().substring(1));

    Assert.assertEquals(result.size(), 1);

    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

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.