Examples of IUserPersistence


Examples of com.rapleaf.jack.test_project.database_1.iface.IUserPersistence

    return new DatabasesImpl();
  }

  // this test is duplicated because of some weirdness with single quote escaping that appears contstrained to the mock mysql.
  public void testFindAllWithEscapedQuotesInStrings() throws Exception {
    IUserPersistence users = dbs.getDatabase1().users();
    User u1 = users.create("brya'nd", System.currentTimeMillis(), 5, System.currentTimeMillis() + 10, System.currentTimeMillis() + 20, "this is a relatively long string", new byte[]{5, 4, 3, 2, 1}, 1.2d, 3.4d, true);
    User u2 = users.create("thoma\"sk", null, 5, System.currentTimeMillis() + 10, System.currentTimeMillis() + 20, "this is a relatively long string", new byte[]{5, 4, 3, 2, 1}, 1.2d, 3.4d, true);

    assertEquals(Collections.singleton(u1), users.findAll("handle = 'brya\\'nd'"));
    assertEquals(Collections.singleton(u2), users.findAll("handle = 'thoma\"sk'"));
    assertEquals(Collections.singleton(u1), users.findAll("handle = 'brya\\'nd'"));
    assertEquals(Collections.singleton(u2), users.findAll("handle = 'thoma\"sk'"));
  }
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IUserPersistence

    super.setUp();
    dbs.getDatabase1().deleteAll();
  }

  public void testCreate() throws Exception {
    IUserPersistence users = dbs.getDatabase1().users();
    long t0 = System.currentTimeMillis();
    long t1 = t0 + 10;
    long t2 = t0 + 20;
    byte[] someBinary = new byte[]{5, 4, 3, 2, 1};
    User bryand = users.create("bryand", t0, 5, t1, t2, "this is a relatively long string", someBinary, 1.2d, 3.4d, true);
    verifyCreatedUser(users, t0, t1, t2, someBinary, bryand);
  }
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IUserPersistence

    Comment c = new Comment(1, "comment content", 1, postId, System.currentTimeMillis(), getDBS());
    assertNotNull("Post should be findable by foreign key", c.getPost());
  }

  public void testCreateFromMap() throws IOException {
    IUserPersistence users = dbs.getDatabase1().users();
    long t0 = System.currentTimeMillis();
    long t1 = t0 + 10;
    long t2 = t0 + 20;
    byte[] someBinary = new byte[]{5, 4, 3, 2, 1};

    Map<Enum, Object> fieldsMap = new HashMap<Enum, Object>();
    fieldsMap.put(User._Fields.handle, "bryand");
    fieldsMap.put(User._Fields.created_at_millis, t0);
    fieldsMap.put(User._Fields.num_posts, 5);
    fieldsMap.put(User._Fields.some_date, t1);
    fieldsMap.put(User._Fields.some_datetime, t2);
    fieldsMap.put(User._Fields.bio, "this is a relatively long string");
    fieldsMap.put(User._Fields.some_binary, someBinary);
    fieldsMap.put(User._Fields.some_float, 1.2d);
    fieldsMap.put(User._Fields.some_decimal, 3.4d);
    fieldsMap.put(User._Fields.some_boolean, true);

    User bryand = (User)users.create(fieldsMap);
    verifyCreatedUser(users, t0, t1, t2, someBinary, bryand);
  }
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IUserPersistence

    User bryand = (User)users.create(fieldsMap);
    verifyCreatedUser(users, t0, t1, t2, someBinary, bryand);
  }

  public void testCreateWithDefaultValues() throws IOException {
    IUserPersistence users = dbs.getDatabase1().users();
    User user = users.createDefaultInstance();
  }
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IUserPersistence

    // no longer a valid assertion, since we are deep copying objects out of the cache
    // assertTrue(bryand == users.find(bryand.getId()));
  }

  public void testFind() throws Exception {
    IUserPersistence users = dbs.getDatabase1().users();
    long t0 = System.currentTimeMillis();
    long t1 = t0 + 10;
    long t2 = t0 + 20;
    byte[] someBinary = new byte[]{5, 4, 3, 2, 1};
    User bryand = users.create("bryand", t0, 5, t1, t2, "this is a relatively long string", someBinary, 1.2d, 3.4d, true);

    User bryand_again = users.find(bryand.getId());
    assertEquals(bryand.getId(), bryand_again.getId());
    assertEquals("bryand", bryand_again.getHandle());
    assertEquals(Long.valueOf(t0), bryand_again.getCreatedAtMillis());
    assertEquals(5, bryand_again.getNumPosts());
    // need to figure out what the appropriate rounding is...
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IUserPersistence

    assertEquals(3.4, bryand_again.getSomeDecimal());
    assertTrue(bryand_again.isSomeBoolean());
  }

  public void testFindEmptySet() throws Exception {
    IUserPersistence users = dbs.getDatabase1().users();
    Set<User> foundValues = users.find(new HashSet<Long>());
    assertEquals(0, foundValues.size());
  }
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IUserPersistence

    Set<User> foundValues = users.find(new HashSet<Long>());
    assertEquals(0, foundValues.size());
  }

  public void testFindSet() throws Exception {
    IUserPersistence users = dbs.getDatabase1().users();
    long t0 = System.currentTimeMillis();
    long t1 = t0 + 10;
    long t2 = t0 + 20;
    byte[] someBinary = new byte[]{5, 4, 3, 2, 1};
    User bryand = users.create("bryand", t0, 5, t1, t2, "this is a relatively long string", someBinary, 1.2d, 3.4d, true);
    User notBryand = users.create("notBryand", t0, 3, t1, t2, "another relatively long string", someBinary, 1.2d, 3.4d, true);
    users.create("unwanted", t0, 0, t1, t2, "yet another relatively long string", someBinary, 1.2d, 3.4d, true);

    users.clearCacheById(bryand.getId());
    users.clearCacheById(notBryand.getId());
    Set<Long> keysToSearch = new HashSet<Long>();
    keysToSearch.add(bryand.getId());
    keysToSearch.add(notBryand.getId());
    Set<User> foundValues = users.find(keysToSearch);

    assertEquals(2, foundValues.size());
    Iterator<User> iter = foundValues.iterator();
    User bryand_again = null;
    User notBryand_again = null;
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IUserPersistence

    assertEquals(3.4, notBryand_again.getSomeDecimal());
    assertTrue(notBryand_again.isSomeBoolean());
  }

  public void testFindSetFromCache() throws Exception {
    IUserPersistence users = dbs.getDatabase1().users();
    long t0 = System.currentTimeMillis();
    long t1 = t0 + 10;
    long t2 = t0 + 20;
    byte[] someBinary = new byte[]{5, 4, 3, 2, 1};
    User bryand = users.create("bryand", t0, 5, t1, t2, "this is a relatively long string", someBinary, 1.2d, 3.4d, true);
    User notBryand = users.create("notBryand", t0, 3, t1, t2, "another relatively long string", someBinary, 1.2d, 3.4d, true);
    users.create("unwanted", t0, 0, t1, t2, "yet another relatively long string", someBinary, 1.2d, 3.4d, true);

    Set<Long> keysToSearch = new HashSet<Long>();
    keysToSearch.add(bryand.getId());
    keysToSearch.add(notBryand.getId());
    Set<User> foundValues = users.find(keysToSearch);

    assertEquals(2, foundValues.size());
    Iterator<User> iter = foundValues.iterator();
    User bryand_again = users.find(bryand.getId());
    User notBryand_again = users.find(notBryand.getId());
    while (iter.hasNext()) {
      User curUser = iter.next();
      if (curUser.getId() == bryand.getId()) {
        assertEquals(bryand_again, curUser);
      } else if (curUser.getId() == notBryand.getId()) {
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IUserPersistence

      }
    }
  }

  public void testFindCache() throws Exception {
    IUserPersistence users = dbs.getDatabase1().users();
    User user = users.create("bryand", System.currentTimeMillis(), 5, System.currentTimeMillis() + 10, System.currentTimeMillis() + 20, "this is a relatively long string", new byte[]{5, 4, 3, 2, 1}, 1.2d, 3.4d, true);

    User u1 = users.find(user.getId());
    User u2 = users.find(user.getId());
    assertEquals(u1, u2);
  }
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IUserPersistence

    assertTrue(userComments.contains(c2));
    assertTrue(userComments.contains(c3));
  }

  public void testFindAllFromCache() throws Exception {
    IUserPersistence users = dbs.getDatabase1().users();
    User u1 = users.create("bryand", System.currentTimeMillis(), 5, System.currentTimeMillis() + 10, System.currentTimeMillis() + 20, "this is a relatively long string", new byte[]{5, 4, 3, 2, 1}, 1.2d, 3.4d, true);
    User u2 = users.create("thomask", System.currentTimeMillis(), 5, System.currentTimeMillis() + 10, System.currentTimeMillis() + 20, "this is a relatively long string", new byte[]{5, 4, 3, 2, 1}, 1.2d, 3.4d, true);
    User u3 = users.create("emilyl", System.currentTimeMillis(), 5, System.currentTimeMillis() + 10, System.currentTimeMillis() + 20, "this is a relatively long string", new byte[]{5, 4, 3, 2, 1}, 1.2d, 3.4d, true);

    // fills cache
    User u1_1 = users.find(u1.getId());
    User u2_1 = users.find(u2.getId());
    User u3_1 = users.find(u3.getId());

    Set<User> allUsers = users.findAll();
    assertTrue(allUsers.contains(u1));
    assertTrue(allUsers.contains(u2));
    assertTrue(allUsers.contains(u3));

    // make sure findAll returned cached objects
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.