@Test public void testUpdateByRecords() { Connection db = getConnection(); long app = getAppId(); try { Record record; List<Record> records = new ArrayList<Record>(); List<Long> ids = insertRecords(); ResultSet rs = db.select(app, ""); if (rs.size() != 3) { fail("invalid count"); } while (rs.next()) { record = new Record(); record.setId(rs.getId()); record.setRevision(rs.getRevision()); record.setString("Single_line_text", "hoge"); records.add(record); } db.updateByRecords(app, records); rs = db.select(app, "Single_line_text = \"hoge\""); if (rs.size() != 3) { fail("failed to update"); } } catch (Exception e) { fail("db exception:" + e.getMessage()); } }
@Test public void testUpdateByRecords2() { 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"); } 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.updateByRecords(app, records); fail("no conflict"); } catch (Exception e) { } }