Пример #1
0
  @Test
  public void testUpdateByRecord() {
    Connection db = getConnection();
    long app = getAppId();
    try {
      Record record = new Record();
      List<Long> ids = insertRecords();
      long id = ids.get(1);
      ResultSet rs = db.select(app, "Record_number = " + id);
      if (rs.size() != 1) {
        fail("invalid count");
      }
      rs.next();
      record.setId(rs.getId());
      record.setRevision(rs.getRevision());
      record.setString("Single_line_text", "hoge");
      db.updateByRecord(app, record);

      rs = db.select(app, "Single_line_text = \"hoge\"");
      if (rs.size() != 1) {
        fail("failed to update");
      }
      rs.next();
      if (rs.getId() != id) {
        fail("invalid id");
      }
    } catch (Exception e) {
      fail("db exception:" + e.getMessage());
    }
  }
Пример #2
0
  @Test
  public void testDeleteByRecords2() {
    Connection db = getConnection();
    long app = getAppId();
    Record record;
    List<Record> records = new ArrayList<Record>();
    ResultSet rs = null;

    try {

      List<Long> ids = insertRecords();
      rs = db.select(app, "");
      if (rs.size() != 3) {
        fail("invalid count");
      }

      record = new Record();
      rs.next();
      record.setId(rs.getId());
      record.setString("Single_line_text", "hoge");
      db.updateByRecord(app, record);

    } catch (Exception e) {
      fail("db exception:" + e.getMessage());
    }

    try {
      rs.first();
      while (rs.next()) {
        record = new Record();
        record.setId(rs.getId());
        record.setRevision(rs.getRevision());
        record.setString("Single_line_text", "hoge");

        records.add(record);
      }
      db.deleteByRecords(app, records);
      fail("no conflict");
    } catch (Exception e) {
    }
  }