Package com.rapleaf.jack.test_project.database_1.models

Examples of com.rapleaf.jack.test_project.database_1.models.Post$Attributes


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

  public void testBelongsTo() 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);

    IPostPersistence posts = dbs.getDatabase1().posts();
    Post p1 = posts.create("title", System.currentTimeMillis(), (int)u1.getId(), 0l);
    assertEquals(u1, p1.getUser());
  }
View Full Code Here


    Post p1 = posts.create("title", System.currentTimeMillis(), (int)u1.getId(), 0l);
    assertEquals(u1, p1.getUser());
  }

  public void testHasOne() 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);

    IImagePersistence images = dbs.getDatabase1().images();
    Image image = images.create((int)u1.getId());
    assertEquals(u1, image.getUser());
  }
View Full Code Here

    Image image = images.create((int)u1.getId());
    assertEquals(u1, image.getUser());
  }

  public void testHasMany() 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);

    IPostPersistence posts = dbs.getDatabase1().posts();
    Post p1 = posts.create("title1", System.currentTimeMillis(), (int)u1.getId(), 0l);
    Post p2 = posts.create("title2", System.currentTimeMillis(), (int)u1.getId(), 0l);
    Post p3 = posts.create("title3", System.currentTimeMillis(), (int)u1.getId(), 0l);
View Full Code Here

    posts.save(post);
    assertEquals(post, posts.find(50));
  }

  public void testFindWithFieldsMap() throws IOException, SQLException {
    IUserPersistence users = dbs.getDatabase1().users();

    User u1 = users.create("a_handle", 2);
    users.save(u1);

    User u2 = users.create("another_handle", 2);

    Set<User> found = users.find(new HashMap<Enum, Object>() {
      {
        put(User._Fields.handle, "a_handle");
        put(User._Fields.some_float, null);
      }
    });
    assertEquals(1, found.size());
    assertTrue(found.contains(u1));

    found = users.find(new HashMap<Enum, Object>() {
      {
        put(User._Fields.num_posts, 2);
      }
    });
    assertEquals(2, found.size());
    assertTrue(found.contains(u1));
    assertTrue(found.contains(u2));

    found = users.query().id(u1.getId()).numPosts(2).find();
    assertEquals(1, found.size());
    assertTrue(found.contains(u1));
  }
View Full Code Here

    assertEquals(1, found.size());
    assertTrue(found.contains(u1));
  }

  public void testFindByField() throws IOException {
    IUserPersistence users = dbs.getDatabase1().users();

    User u1 = users.create("a_handle", 2);
    users.save(u1);

    User u2 = users.create("another_handle", 2);

    Set<User> found = users.findByHandle("a_handle");
    assertEquals(1, found.size());
    assertTrue(found.contains(u1));

    found = users.findByHandle("no_a_handle");
    assertTrue(found.isEmpty());

    found = users.findByNumPosts(2);
    assertEquals(2, found.size());
    assertTrue(found.contains(u1));
    assertTrue(found.contains(u2));
  }
View Full Code Here

  }


  public Image create(final Integer user_id) throws IOException {
    long __id = curId.getAndIncrement();
    Image newInst = new Image(__id, user_id, databases);
    records.put(__id, newInst);
    clearForeignKeyCache();
    return newInst.getCopy();
  }
View Full Code Here



  public Image create() throws IOException {
    long __id = curId.getAndIncrement();
    Image newInst = new Image(__id, null, databases);
    records.put(__id, newInst);
    clearForeignKeyCache();
    return newInst.getCopy();
  }
View Full Code Here

  @Override
  public void setUp() {
    dbs = new DatabasesImpl(DATABASE_CONNECTION1);
    postModel = new Post(0, "Test Post", 100l, 1, 0l);
    imageModel = new Image(0, null, dbs);
    userModel = new User(0l, "handle", 0l, 0, 0l, 0l, "bio", null, 0.0, 0.0, true);
    try {
      dbs.getDatabase1().deleteAll();
      dbs.getDatabase1().users().save(userModel);
    } catch (IOException e) {
View Full Code Here

        } else {
          stmt.setTimestamp(4, new Timestamp(updated_at));
        }
      }
    }, getInsertStatement(Arrays.<String>asList("title", "posted_at_millis", "user_id", "updated_at")));
    Post newInst = new Post(__id, title, posted_at_millis, user_id, updated_at, databases);
    newInst.setCreated(true);
    cachedById.put(__id, newInst);
    clearForeignKeyCache();
    return newInst;
  }
View Full Code Here

  public Post create() throws IOException {
    long __id = realCreate(new AttrSetter() {
      public void set(PreparedStatement stmt) throws SQLException {
      }
    }, getInsertStatement(Arrays.<String>asList()));
    Post newInst = new Post(__id, null, null, null, null, databases);
    newInst.setCreated(true);
    cachedById.put(__id, newInst);
    clearForeignKeyCache();
    return newInst;
  }
View Full Code Here

TOP

Related Classes of com.rapleaf.jack.test_project.database_1.models.Post$Attributes

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.