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

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


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

  @Test
  public void queryWithRidAsParameters() {
    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);
  }
View Full Code Here

  @Test
  public void queryWithRidStringAsParameters() {
    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);
  }
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);
  }
View Full Code Here

    Assert.assertTrue(false);
  }

  @Test(dependsOnMethods = "testHooksIsRegistered")
  public void testHookCreate() throws IOException {
    p = new Profile("HookTest");

    // TEST HOOKS ON CREATE
    Assert.assertEquals(callbackCount, 0);
    database.save(p);
    Assert.assertEquals(callbackCount, 11);
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

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.