示例#1
0
  @Test
  public void testGetOwnedDevices() {
    Transaction tx = schema.connect(null);
    Person owner;
    Iterable<Device> devQuery;

    owner = tx.retrieve("Person", "1");
    devQuery = tx.query("Device", new IQuery("owner", owner));

    Device d1, d2;
    d1 = devQuery.iterator().next();
    d2 = Persons.getOwnedDevices(tx, owner).iterator().next();
    Assert.assertSame(d1, d2);
  }
示例#2
0
  @Test
  public void testGetActiveSessions() {
    Transaction tx = schema.connect(null);
    Person p, person;
    Iterable<Session> s;
    Boolean expected, actual;

    expected = true;
    p = tx.retrieve("Person", "1");
    person = tx.retrieve("Person", "1");
    s = person.getSessions().stream().filter(Sessions::isLive).collect(Collectors.toList());

    if (Persons.getActiveSessions(p).equals(s)) {
      actual = true;
    } else {
      actual = false;
    }

    Assert.assertEquals(expected, actual);
  }
示例#3
0
  {
    try {
      schema = TempSQLiteRepo.forSchema(RealmSchema.get());
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    Transaction tx;
    Person p;

    tx = schema.connect("testing");
    p = tx.create("Person");
    p.setName("personA");
    p.setSessions(tx.create("Person.sessions"));
    // p.setSessions(new IListing<Session>(Session.class));

    Device dev = tx.create("Device");
    dev.setOwner(p);

    tx.post();
  }